Skip to content

Commit 3c48c4b

Browse files
authored
Merge pull request #6708 from edolstra/run-static-tests
Enable tests for nix-static
2 parents 958b8d1 + 8bbbb6e commit 3c48c4b

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

flake.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,14 +571,19 @@
571571
nativeBuildInputs = nativeBuildDeps;
572572
buildInputs = buildDeps ++ propagatedDeps;
573573

574+
# Work around pkgsStatic disabling all tests.
575+
preHook =
576+
''
577+
doCheck=1
578+
doInstallCheck=1
579+
'';
580+
574581
configureFlags = [ "--sysconfdir=/etc" ];
575582

576583
enableParallelBuilding = true;
577584

578585
makeFlags = "profiledir=$(out)/etc/profile.d";
579586

580-
doCheck = true;
581-
582587
installFlags = "sysconfdir=$(out)/etc";
583588

584589
postInstall = ''
@@ -588,7 +593,6 @@
588593
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
589594
'';
590595

591-
doInstallCheck = true;
592596
installCheckFlags = "sysconfdir=$(out)/etc";
593597

594598
stripAllList = ["bin"];
@@ -597,6 +601,7 @@
597601

598602
hardeningDisable = [ "pie" ];
599603
};
604+
600605
dockerImage =
601606
let
602607
pkgs = nixpkgsFor.${system};

tests/ca/content-addressed.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ rec {
7575
buildCommand = ''
7676
mkdir -p $out/bin
7777
echo ${rootCA} # Just to make it depend on it
78-
echo "" > $out/bin/${name}
78+
echo "#! ${shell}" > $out/bin/${name}
7979
chmod +x $out/bin/${name}
8080
'';
8181
};

tests/common.sh.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export busybox="@sandbox_shell@"
5050
export version=@PACKAGE_VERSION@
5151
export system=@system@
5252

53+
export BUILD_SHARED_LIBS=@BUILD_SHARED_LIBS@
54+
5355
export IMPURE_VAR1=foo
5456
export IMPURE_VAR2=bar
5557

tests/fmt.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ cat << EOF > flake.nix
1818
with import ./config.nix;
1919
mkDerivation {
2020
name = "formatter";
21-
buildCommand = "mkdir -p \$out/bin; cp \${./fmt.simple.sh} \$out/bin/formatter";
21+
buildCommand = ''
22+
mkdir -p \$out/bin
23+
echo "#! ${shell}" > \$out/bin/formatter
24+
cat \${./fmt.simple.sh} >> \$out/bin/formatter
25+
chmod +x \$out/bin/formatter
26+
'';
2227
};
2328
};
2429
}

tests/local.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,8 @@ tests-environment = NIX_REMOTE= $(bash) -e
114114

115115
clean-files += $(d)/common.sh $(d)/config.nix $(d)/ca/config.nix
116116

117-
test-deps += tests/common.sh tests/config.nix tests/ca/config.nix tests/plugins/libplugintest.$(SO_EXT)
117+
test-deps += tests/common.sh tests/config.nix tests/ca/config.nix
118+
119+
ifeq ($(BUILD_SHARED_LIBS), 1)
120+
test-deps += tests/plugins/libplugintest.$(SO_EXT)
121+
endif

tests/plugins.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ source common.sh
22

33
set -o pipefail
44

5+
if [[ $BUILD_SHARED_LIBS != 1 ]]; then
6+
echo "plugins are not supported"
7+
exit 99
8+
fi
9+
510
res=$(nix --option setting-set true --option plugin-files $PWD/plugins/libplugintest* eval --expr builtins.anotherNull)
611

712
[ "$res"x = "nullx" ]

0 commit comments

Comments
 (0)