diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/negative-caching.nix | 21 | ||||
-rw-r--r-- | tests/negative-caching.sh | 22 |
3 files changed, 45 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index a16051f73510..beb7852db31c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,7 +7,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.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 fixed.sh \ gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \ - remote-store.sh export.sh export-graph.sh + remote-store.sh export.sh export-graph.sh negative-caching.sh XFAIL_TESTS = @@ -30,5 +30,6 @@ EXTRA_DIST = $(TESTS) \ check-refs.nix \ filter-source.nix \ export-graph.nix \ + negative-caching.nix \ $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) \ common.sh.in diff --git a/tests/negative-caching.nix b/tests/negative-caching.nix new file mode 100644 index 000000000000..10df67a748fc --- /dev/null +++ b/tests/negative-caching.nix @@ -0,0 +1,21 @@ +with import ./config.nix; + +rec { + + fail = mkDerivation { + name = "fail"; + builder = builtins.toFile "builder.sh" "echo FAIL; exit 1"; + }; + + succeed = mkDerivation { + name = "succeed"; + builder = builtins.toFile "builder.sh" "echo SUCCEED; mkdir $out"; + }; + + depOnFail = mkDerivation { + name = "dep-on-fail"; + builder = builtins.toFile "builder.sh" "echo URGH; mkdir $out"; + inputs = [fail succeed]; + }; + +} diff --git a/tests/negative-caching.sh b/tests/negative-caching.sh new file mode 100644 index 000000000000..e618e9443ef2 --- /dev/null +++ b/tests/negative-caching.sh @@ -0,0 +1,22 @@ +source common.sh + +clearStore + +set +e + +opts="--option build-cache-failure true --print-build-trace" + +# This build should fail, and the failure should be cached. +log=$($nixbuild $opts negative-caching.nix -A fail 2>&1) && fail "should fail" +echo "$log" | grep -q "@ build-failed" || fail "no build-failed trace" + +# Do it again. The build shouldn't be tried again. +log=$($nixbuild $opts negative-caching.nix -A fail 2>&1) && fail "should fail" +echo "$log" | grep -q "FAIL" && fail "failed build not cached" +echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached" + +# Check that --keep-going works properly with cached failures. +log=$($nixbuild $opts --keep-going negative-caching.nix -A depOnFail 2>&1) && fail "should fail" +echo "$log" | grep -q "FAIL" && fail "failed build not cached (2)" +echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached (2)" +echo "$log" | grep -q "@ build-succeeded .*-succeed" || fail "didn't keep going" |