diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-08-22 17:07:14 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-08-23 17:49:15 -0700 |
commit | 686120ee4a34f658b2f19dcac9f9dc44dbc98b93 (patch) | |
tree | 9c688afa704afc91724fdad259de4f3e447b6699 /tests | |
parent | c5949bfe313a92aab0e4cf38ab2407b0ac922ce8 (diff) |
fix: good errors for failures caused by allowSubstitutes
This caused an absolute saga which I would not like anyone else to have
to experience. Let's put in a laser targeted error message that
diagnoses this exact problem.
Fixes: https://git.lix.systems/lix-project/lix/issues/484
Change-Id: I2a79f04aeb4a1b67c10115e5e39501d958836298
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/meson.build | 1 | ||||
-rw-r--r-- | tests/functional/regression-484.sh | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/functional/meson.build b/tests/functional/meson.build index fb8d77a57..bb706ce9e 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -189,6 +189,7 @@ functional_tests_scripts = [ 'test-libstoreconsumer.sh', 'extra-sandbox-profile.sh', 'substitute-truncated-nar.sh', + 'regression-484.sh', ] # Plugin tests require shared libraries support. diff --git a/tests/functional/regression-484.sh b/tests/functional/regression-484.sh new file mode 100644 index 000000000..1aa039ac2 --- /dev/null +++ b/tests/functional/regression-484.sh @@ -0,0 +1,41 @@ +source common.sh + +# Ensures that nix build will deliver a usable error message when it encounters +# a build failure potentially caused by allowSubstitutes. + +clearStore + +cd $TEST_HOME + +putDrv() { + cat > "$1" <<EOF +builtins.derivation { + name = "meow"; + builder = "/bin/sh"; + args = []; + system = "unicornsandrainbows-linux"; + allowSubstitutes = ${2}; + preferLocalBuild = true; +} +EOF +} + +putDrv drv-disallow-substitutes.nix false +putDrv drv-allow-substitutes.nix true + +expect 1 nix build --substitute --substituters '' --offline -f drv-disallow-substitutes.nix 2> output.txt + +# error: a 'unicornsandrainbows-linux' with features {} is required to build '$TMPDIR/regression-484/store/...-meow.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, uid-range} +# +# Hint: the failing derivation has allowSubstitutes set to false, forcing it to be built rather than substituted. +# Passing --always-allow-substitutes to force substitution may resolve this failure if the path is available in a substituter. +cat output.txt +grepQuiet unicornsandrainbows-linux output.txt +grepQuiet always-allow-substitutes output.txt +grepQuiet allowSubstitutes output.txt + +expect 1 nix build --substitute --substituters '' --offline -f drv-allow-substitutes.nix 2> output.txt + +cat output.txt +grepQuiet unicornsandrainbows-linux output.txt +grepQuiet -v allowSubstitutes output.txt |