aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-03-25 21:05:42 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-03-25 21:05:42 +0000
commit92f525ecf4ea8a9bd356acd1d3845074b1e5b918 (patch)
tree6d022fbd92897ad965a04571b339bad362cb9158 /tests
parent7024a1ef076cedf4596c9f4b107e85d315242cea (diff)
* Negative caching, i.e. caching of build failures. Disabled by
default. This is mostly useful for Hydra.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/negative-caching.nix21
-rw-r--r--tests/negative-caching.sh22
3 files changed, 45 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a16051f73..beb7852db 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 000000000..10df67a74
--- /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 000000000..e618e9443
--- /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"