aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/fixed.builder1.sh3
-rw-r--r--tests/fixed.builder2.sh6
-rw-r--r--tests/fixed.nix.in37
-rw-r--r--tests/fixed.sh18
5 files changed, 67 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3a1e07891..9a718f190 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,11 +12,12 @@ substitutes2.sh: substitutes2.nix
fallback.sh: fallback.nix
gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
user-envs.sh: user-envs.nix
+fixed.sh: fixed.nix
TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
locking.sh parallel.sh build-hook.sh substitutes.sh substitutes2.sh \
fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \
- referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh
+ referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh
XFAIL_TESTS =
@@ -36,5 +37,6 @@ EXTRA_DIST = $(TESTS) \
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
fallback.nix.in \
user-envs.nix.in user-envs.builder.sh \
+ fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
$(wildcard lang/*.nix) $(wildcard lang/*.exp) \
common.sh.in
diff --git a/tests/fixed.builder1.sh b/tests/fixed.builder1.sh
new file mode 100644
index 000000000..2213841a2
--- /dev/null
+++ b/tests/fixed.builder1.sh
@@ -0,0 +1,3 @@
+export PATH=/bin:/usr/bin:$PATH
+
+echo "Hello World!" > $out
diff --git a/tests/fixed.builder2.sh b/tests/fixed.builder2.sh
new file mode 100644
index 000000000..af94c22ac
--- /dev/null
+++ b/tests/fixed.builder2.sh
@@ -0,0 +1,6 @@
+export PATH=/bin:/usr/bin:$PATH
+
+mkdir $out
+mkdir $out/bla
+echo "Hello World!" > $out/foo
+ln -s foo $out/bar
diff --git a/tests/fixed.nix.in b/tests/fixed.nix.in
new file mode 100644
index 000000000..0ce9dd401
--- /dev/null
+++ b/tests/fixed.nix.in
@@ -0,0 +1,37 @@
+rec {
+
+ f = builder: mode: algo: hash: derivation {
+ name = "fixed";
+ system = "@system@";
+ builder = "@shell@";
+ args = ["-e" "-x" builder];
+ outputHashMode = mode;
+ outputHashAlgo = algo;
+ outputHash = hash;
+ };
+
+ good = [
+ (f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
+ (f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
+ (f ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
+ (f ./fixed.builder2.sh "recursive" "sha1" "vw46m23bizj4n8afrc0fj19wrp7mj3c0")
+ (f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik")
+ ];
+
+ good2 = [
+ # Yes, this looks fscked up: builder2 doesn't have that result.
+ # But Nix sees that an output with the desired hash already
+ # exists, and will refrain from building it.
+ (f ./fixed.builder2.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
+ ];
+
+ bad = [
+ (f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858")
+ ];
+
+ reallyBad = [
+ # Hash too short, and not base-32 either.
+ (f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
+ ];
+
+} \ No newline at end of file
diff --git a/tests/fixed.sh b/tests/fixed.sh
new file mode 100644
index 000000000..fc37e40f4
--- /dev/null
+++ b/tests/fixed.sh
@@ -0,0 +1,18 @@
+source common.sh
+
+drvs=$($nixinstantiate fixed.nix -A good)
+echo $drvs
+$nixstore -r $drvs
+
+drvs=$($nixinstantiate fixed.nix -A good2)
+echo $drvs
+$nixstore -r $drvs
+
+drvs=$($nixinstantiate fixed.nix -A bad)
+echo $drvs
+if $nixstore -r $drvs; then false; fi
+
+if $nixinstantiate fixed.nix -A reallyBad; then false; fi
+
+# While we're at it, check attribute selection a bit more.
+test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1