mirror of
https://github.com/NixOS/nix
synced 2025-07-09 07:53:55 +02:00
* Negative caching, i.e. caching of build failures. Disabled by
default. This is mostly useful for Hydra.
This commit is contained in:
parent
7024a1ef07
commit
92f525ecf4
7 changed files with 140 additions and 7 deletions
|
@ -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
|
||||
|
|
21
tests/negative-caching.nix
Normal file
21
tests/negative-caching.nix
Normal file
|
@ -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];
|
||||
};
|
||||
|
||||
}
|
22
tests/negative-caching.sh
Normal file
22
tests/negative-caching.sh
Normal file
|
@ -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"
|
Loading…
Add table
Add a link
Reference in a new issue