mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Create test for issue 13247
This test ends up being skipped, since the bug has not yet been fixed. A future commit will fix the bug. Progress on #13247, naturally.
This commit is contained in:
parent
3c610df550
commit
e35abb1102
3 changed files with 118 additions and 0 deletions
46
tests/functional/ca/issue-13247.nix
Normal file
46
tests/functional/ca/issue-13247.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
a = mkDerivation {
|
||||
name = "issue-13247-a";
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
mkdir $out
|
||||
test -z $all
|
||||
echo "output" > $out/file
|
||||
'';
|
||||
};
|
||||
|
||||
# Same output, different drv
|
||||
a-prime = mkDerivation {
|
||||
name = "issue-13247-a";
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
echo 'will make the same stuff as `a`, but different drv hash'
|
||||
|
||||
mkdir $out
|
||||
test -z $all
|
||||
echo "output" > $out/file
|
||||
'';
|
||||
};
|
||||
|
||||
# Multiple outputs in a derivation that depends on other derivations
|
||||
f =
|
||||
dep:
|
||||
mkDerivation {
|
||||
name = "use-a-more-outputs";
|
||||
outputs = [
|
||||
"first"
|
||||
"second"
|
||||
];
|
||||
inherit dep;
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
ln -s $dep/file $first
|
||||
ln -s $first $second
|
||||
'';
|
||||
};
|
||||
|
||||
use-a-more-outputs = f a;
|
||||
|
||||
use-a-prime-more-outputs = f a-prime;
|
||||
|
||||
}
|
||||
71
tests/functional/ca/issue-13247.sh
Executable file
71
tests/functional/ca/issue-13247.sh
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# https://github.com/NixOS/nix/issues/13247
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
|
||||
source common.sh
|
||||
|
||||
clearStoreIfPossible
|
||||
|
||||
set -x
|
||||
|
||||
# Build derivation (both outputs)
|
||||
nix build -f issue-13247.nix --json a a-prime use-a-more-outputs --no-link > "$TEST_ROOT"/a.json
|
||||
|
||||
cache="file://$TEST_ROOT/cache"
|
||||
|
||||
# Copy all outputs and realisations to cache
|
||||
declare -a drvs
|
||||
for d in "$NIX_STORE_DIR"/*-issue-13247-a.drv "$NIX_STORE_DIR"/*-use-a-more-outputs.drv; do
|
||||
drvs+=("$d" "$d"^*)
|
||||
done
|
||||
nix copy --to "$cache" "${drvs[@]}"
|
||||
|
||||
function delete () {
|
||||
# Delete local copy
|
||||
# shellcheck disable=SC2046
|
||||
nix-store --delete \
|
||||
$(jq -r <"$TEST_ROOT"/a.json '.[] | .drvPath, .outputs.[]') \
|
||||
"$NIX_STORE_DIR"/*-issue-13247-a.drv \
|
||||
"$NIX_STORE_DIR"/*-use-a-more-outputs.drv
|
||||
|
||||
[[ ! -e "$(jq -r <"$TEST_ROOT"/a.json '.[0].outputs.out')" ]]
|
||||
[[ ! -e "$(jq -r <"$TEST_ROOT"/a.json '.[1].outputs.out')" ]]
|
||||
[[ ! -e "$(jq -r <"$TEST_ROOT"/a.json '.[2].outputs.first')" ]]
|
||||
[[ ! -e "$(jq -r <"$TEST_ROOT"/a.json '.[2].outputs.second')" ]]
|
||||
}
|
||||
|
||||
delete
|
||||
|
||||
buildViaSubstitute () {
|
||||
nix build -f issue-13247.nix "$1" --no-link --max-jobs 0 --substituters "$cache" --no-require-sigs --offline --substitute
|
||||
}
|
||||
|
||||
# Substitue just the first output
|
||||
buildViaSubstitute use-a-more-outputs^first
|
||||
|
||||
# Should only fetch the output we asked for
|
||||
[[ -d "$(jq -r <"$TEST_ROOT"/a.json '.[0].outputs.out')" ]]
|
||||
[[ -f "$(jq -r <"$TEST_ROOT"/a.json '.[2].outputs.first')" ]]
|
||||
[[ ! -e "$(jq -r <"$TEST_ROOT"/a.json '.[2].outputs.second')" ]]
|
||||
|
||||
delete
|
||||
|
||||
# Failure with 2.28 encountered in CI
|
||||
requireDaemonNewerThan "2.29"
|
||||
|
||||
# Substitue just the first output
|
||||
#
|
||||
# This derivation is the same after normalization, so we should get
|
||||
# early cut-off, and thus a chance to download just the output we want
|
||||
# rather than building more
|
||||
buildViaSubstitute use-a-prime-more-outputs^first
|
||||
|
||||
# Should only fetch the output we asked for
|
||||
[[ -d "$(jq -r <"$TEST_ROOT"/a.json '.[0].outputs.out')" ]]
|
||||
[[ -f "$(jq -r <"$TEST_ROOT"/a.json '.[2].outputs.first')" ]]
|
||||
|
||||
# Output should *not* be here, this is the bug
|
||||
[[ -e "$(jq -r <"$TEST_ROOT"/a.json '.[2].outputs.second')" ]]
|
||||
skipTest "bug is not yet fixed"
|
||||
|
|
@ -19,6 +19,7 @@ suites += {
|
|||
'eval-store.sh',
|
||||
'gc.sh',
|
||||
'import-from-derivation.sh',
|
||||
'issue-13247.sh',
|
||||
'multiple-outputs.sh',
|
||||
'new-build-cmd.sh',
|
||||
'nix-copy.sh',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue