mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Run multiple outputs and build-delete test for CA drvs also
This commit is contained in:
parent
af82c847a7
commit
7ea31c6e56
6 changed files with 53 additions and 17 deletions
|
|
@ -233,10 +233,12 @@
|
|||
# Content-addressed test files that use recursive-*looking* sourcing
|
||||
# (cd .. && source <self>), causing shellcheck to loop
|
||||
# They're small wrapper scripts with not a lot going on
|
||||
''^tests/functional/ca/build-delete\.sh$''
|
||||
''^tests/functional/ca/build-dry\.sh$''
|
||||
''^tests/functional/ca/eval-store\.sh$''
|
||||
''^tests/functional/ca/gc\.sh$''
|
||||
''^tests/functional/ca/import-from-derivation\.sh$''
|
||||
''^tests/functional/ca/multiple-outputs\.sh$''
|
||||
''^tests/functional/ca/new-build-cmd\.sh$''
|
||||
''^tests/functional/ca/nix-shell\.sh$''
|
||||
''^tests/functional/ca/post-hook\.sh$''
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ issue_6572_dependent_outputs() {
|
|||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
if [[ -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
# Resolved derivations interferre with the deletion
|
||||
nix-store --delete "${NIX_STORE_DIR}"/*.drv
|
||||
fi
|
||||
nix-store --delete "$(jq -r <"$TEST_ROOT"/a.json .[0].outputs.second)"
|
||||
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
|
||||
cmp "$p" <<EOF
|
||||
|
|
|
|||
7
tests/functional/ca/build-delete.sh
Normal file
7
tests/functional/ca/build-delete.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
cd ..
|
||||
source ./build-delete.sh
|
||||
|
|
@ -9,6 +9,7 @@ suites += {
|
|||
'deps' : [],
|
||||
'tests' : [
|
||||
'build-cache.sh',
|
||||
'build-delete.sh',
|
||||
'build-with-garbage-path.sh',
|
||||
'build.sh',
|
||||
'concurrent-builds.sh',
|
||||
|
|
@ -18,6 +19,7 @@ suites += {
|
|||
'eval-store.sh',
|
||||
'gc.sh',
|
||||
'import-from-derivation.sh',
|
||||
'multiple-outputs.sh',
|
||||
'new-build-cmd.sh',
|
||||
'nix-copy.sh',
|
||||
'nix-run.sh',
|
||||
|
|
|
|||
7
tests/functional/ca/multiple-outputs.sh
Normal file
7
tests/functional/ca/multiple-outputs.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
cd ..
|
||||
source ./multiple-outputs.sh
|
||||
|
|
@ -8,11 +8,15 @@ clearStoreIfPossible
|
|||
|
||||
rm -f $TEST_ROOT/result*
|
||||
|
||||
# Test whether the output names match our expectations
|
||||
outPath=$(nix-instantiate multiple-outputs.nix --eval -A nameCheck.out.outPath)
|
||||
[ "$(echo "$outPath" | sed -E 's_^".*/[^-/]*-([^/]*)"$_\1_')" = "multiple-outputs-a" ]
|
||||
outPath=$(nix-instantiate multiple-outputs.nix --eval -A nameCheck.dev.outPath)
|
||||
[ "$(echo "$outPath" | sed -E 's_^".*/[^-/]*-([^/]*)"$_\1_')" = "multiple-outputs-a-dev" ]
|
||||
# Placeholder strings are opaque, so cannot do this check for floating
|
||||
# content-addressing derivations.
|
||||
if [[ ! -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
# Test whether the output names match our expectations
|
||||
outPath=$(nix-instantiate multiple-outputs.nix --eval -A nameCheck.out.outPath)
|
||||
[ "$(echo "$outPath" | sed -E 's_^".*/[^-/]*-([^/]*)"$_\1_')" = "multiple-outputs-a" ]
|
||||
outPath=$(nix-instantiate multiple-outputs.nix --eval -A nameCheck.dev.outPath)
|
||||
[ "$(echo "$outPath" | sed -E 's_^".*/[^-/]*-([^/]*)"$_\1_')" = "multiple-outputs-a-dev" ]
|
||||
fi
|
||||
|
||||
# Test whether read-only evaluation works when referring to the
|
||||
# ‘drvPath’ attribute.
|
||||
|
|
@ -29,8 +33,12 @@ grepQuiet 'multiple-outputs-b.drv",\["out"\]' $drvPath
|
|||
# While we're at it, test the ‘unsafeDiscardOutputDependency’ primop.
|
||||
outPath=$(nix-build multiple-outputs.nix -A d --no-out-link)
|
||||
drvPath=$(cat $outPath/drv)
|
||||
outPath=$(nix-store -q $drvPath)
|
||||
(! [ -e "$outPath" ])
|
||||
if [[ -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
expectStderr 1 nix-store -q $drvPath | grepQuiet "Cannot use output path of floating content-addressing derivation until we know what it is (e.g. by building it)"
|
||||
else
|
||||
outPath=$(nix-store -q $drvPath)
|
||||
(! [ -e "$outPath" ])
|
||||
fi
|
||||
|
||||
# Do a build of something that depends on a derivation with multiple
|
||||
# outputs.
|
||||
|
|
@ -60,14 +68,16 @@ outPath2=$(nix-build $(nix-instantiate multiple-outputs.nix -A a.second) --no-ou
|
|||
|
||||
[[ $(nix-build $(nix-instantiate multiple-outputs.nix -A a.all) --no-out-link | wc -l) -eq 2 ]]
|
||||
|
||||
# Delete one of the outputs and rebuild it. This will cause a hash
|
||||
# rewrite.
|
||||
env -u NIX_REMOTE nix store delete $TEST_ROOT/result-second --ignore-liveness
|
||||
nix-build multiple-outputs.nix -A a.all -o $TEST_ROOT/result
|
||||
[ "$(cat $TEST_ROOT/result-second/file)" = "second" ]
|
||||
[ "$(cat $TEST_ROOT/result-second/link/file)" = "first" ]
|
||||
hash2=$(nix-store -q --hash $TEST_ROOT/result-second)
|
||||
[ "$hash1" = "$hash2" ]
|
||||
if [[ ! -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
# Delete one of the outputs and rebuild it. This will cause a hash
|
||||
# rewrite.
|
||||
env -u NIX_REMOTE nix store delete $TEST_ROOT/result-second --ignore-liveness
|
||||
nix-build multiple-outputs.nix -A a.all -o $TEST_ROOT/result
|
||||
[ "$(cat $TEST_ROOT/result-second/file)" = "second" ]
|
||||
[ "$(cat $TEST_ROOT/result-second/link/file)" = "first" ]
|
||||
hash2=$(nix-store -q --hash $TEST_ROOT/result-second)
|
||||
[ "$hash1" = "$hash2" ]
|
||||
fi
|
||||
|
||||
# Make sure that nix-build works on derivations with multiple outputs.
|
||||
echo "building a.first..."
|
||||
|
|
@ -88,5 +98,9 @@ nix-store --gc --print-roots
|
|||
rm -rf $NIX_STORE_DIR/.links
|
||||
rmdir $NIX_STORE_DIR
|
||||
|
||||
expect 1 nix build -f multiple-outputs.nix invalid-output-name-1 2>&1 | grep 'contains illegal character'
|
||||
expect 1 nix build -f multiple-outputs.nix invalid-output-name-2 2>&1 | grep 'contains illegal character'
|
||||
# TODO inspect why this doesn't work with floating content-addressing
|
||||
# derivations.
|
||||
if [[ ! -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
expect 1 nix build -f multiple-outputs.nix invalid-output-name-1 2>&1 | grep 'contains illegal character'
|
||||
expect 1 nix build -f multiple-outputs.nix invalid-output-name-2 2>&1 | grep 'contains illegal character'
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue