Merge pull request #10316 from dottharun/derivation-output-test

test: for derivation output selection with `.`
This commit is contained in:
John Ericson 2024-04-03 10:48:04 -04:00 committed by GitHub
commit 36d92dc80a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -56,6 +56,23 @@ cat > $flake1Dir/flake.nix <<EOF
a12 = self.drvCall.outPath;
a13 = "\${self.drvCall.drvPath}\${self.drvCall.outPath}";
a14 = with import ./config.nix; let
top = mkDerivation {
name = "dot-installable";
outputs = [ "foo" "out" ];
meta.outputsToInstall = [ "out" ];
buildCommand = ''
mkdir \$foo \$out
echo "foo" > \$foo/file
echo "out" > \$out/file
'';
};
in top // {
foo = top.foo // {
outputSpecified = true;
};
};
};
}
EOF
@ -94,3 +111,10 @@ nix build --json --out-link $TEST_ROOT/result $flake1Dir#a12
expectStderr 1 nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a13 \
| grepQuiet "has 2 entries in its context. It should only have exactly one entry"
# Test accessing output in installables with `.` (foobarbaz.<output>)
nix build --json --no-link $flake1Dir#a14.foo | jq --exit-status '
(.[0] |
(.drvPath | match(".*dot-installable.drv")) and
(.outputs | keys == ["foo"]))
'