Skip to content

Commit

Permalink
Test --keep-going
Browse files Browse the repository at this point in the history
Make sure that when `nix-build` runs with `--keep-going` we don't stop
the build too early
  • Loading branch information
Théophane Hufschmitt authored and iFreilicht committed Aug 4, 2023
1 parent bb8fff3 commit be145b2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/keep-going.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
with import ./config.nix;

rec {

# Hack to get the scheduler to do what we want: The `good` derivation can
# only be built after `delay_good` (which takes a long time to build) while
# the others don't have any dependency.
# This means that if we build this with parallelism (`-j2`), then we can be
# reasonably sure that the failing derivations will be scheduled _before_ the
# `good` one (and so we can check that `--keep-going` works fine)
delay_good = mkDerivation {
name = "delay-good";
buildCommand = "sleep 3; touch $out";
};

good = mkDerivation {
name = "good";
buildCommand = "mkdir $out; echo foo > $out/bar";
delay = delay_good;
};

failing = mkDerivation {
name = "failing";
buildCommand = false;
};

requiresFooSystemFeature = mkDerivation {
name = "requires-foo-system-feature";
buildCommand = "mkdir $out; echo foo > $out/bar";
requiredSystemFeatures = [ "foo" ];
};

}

14 changes: 14 additions & 0 deletions tests/keep-going.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source common.sh

clearStore

# XXX: These invocations of nix-build should always return 100 according to the manpage, but often return 1
(! nix-build ./keep-going.nix -j2)
(! nix-build ./keep-going.nix -A good -j0) || \
fail "Hello shouldn't have been built because of earlier errors"

clearStore

(! nix-build ./keep-going.nix --keep-going -j2)
nix-build ./keep-going.nix -A good -j0 || \
fail "Hello should have been built despite the errors because of '--keep-going'"
1 change: 1 addition & 0 deletions tests/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ nix_tests = \
ssh-relay.sh \
plugins.sh \
build.sh \
keep-going.sh \
build-delete.sh \
output-normalization.sh \
selfref-gc.sh \
Expand Down

0 comments on commit be145b2

Please sign in to comment.