Merge new tests into build.sh

This commit is contained in:
John Ericson 2022-12-12 17:34:57 -05:00
parent d8c1c24c78
commit c886b18561
3 changed files with 42 additions and 44 deletions

View file

@ -1,43 +0,0 @@
source common.sh
set -o pipefail
drv=$(nix eval -f multiple-outputs.nix --raw a.drvPath)
if nix build "$drv^not-an-output" --no-link --json; then
fail "'not-an-output' should fail to build"
fi
if nix build "$drv^" --no-link --json; then
fail "'empty outputs list' should fail to build"
fi
if nix build "$drv^*nope" --no-link --json; then
fail "'* must be entire string' should fail to build"
fi
nix build "$drv^first" --no-link --json | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-a.drv")) and
(.outputs |
(keys | length == 1) and
(.first | match(".*multiple-outputs-a-first")) and
(has("second") | not)))
'
nix build "$drv^first,second" --no-link --json | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-a.drv")) and
(.outputs |
(keys | length == 2) and
(.first | match(".*multiple-outputs-a-first")) and
(.second | match(".*multiple-outputs-a-second"))))
'
nix build "$drv^*" --no-link --json | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-a.drv")) and
(.outputs |
(keys | length == 2) and
(.first | match(".*multiple-outputs-a-first")) and
(.second | match(".*multiple-outputs-a-second"))))
'

View file

@ -58,6 +58,48 @@ nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
(.outputs | keys == ["a", "b", "c"])) (.outputs | keys == ["a", "b", "c"]))
' '
# Test building from raw store path to drv not expression.
drv=$(nix eval -f multiple-outputs.nix --raw a.drvPath)
if nix build "$drv^not-an-output" --no-link --json; then
fail "'not-an-output' should fail to build"
fi
if nix build "$drv^" --no-link --json; then
fail "'empty outputs list' should fail to build"
fi
if nix build "$drv^*nope" --no-link --json; then
fail "'* must be entire string' should fail to build"
fi
nix build "$drv^first" --no-link --json | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-a.drv")) and
(.outputs |
(keys | length == 1) and
(.first | match(".*multiple-outputs-a-first")) and
(has("second") | not)))
'
nix build "$drv^first,second" --no-link --json | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-a.drv")) and
(.outputs |
(keys | length == 2) and
(.first | match(".*multiple-outputs-a-first")) and
(.second | match(".*multiple-outputs-a-second"))))
'
nix build "$drv^*" --no-link --json | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-a.drv")) and
(.outputs |
(keys | length == 2) and
(.first | match(".*multiple-outputs-a-first")) and
(.second | match(".*multiple-outputs-a-second"))))
'
# Make sure that `--impure` works (regression test for https://github.com/NixOS/nix/issues/6488) # Make sure that `--impure` works (regression test for https://github.com/NixOS/nix/issues/6488)
nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status ' nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status '
(.[0] | (.[0] |

View file

@ -98,7 +98,6 @@ nix_tests = \
ssh-relay.sh \ ssh-relay.sh \
plugins.sh \ plugins.sh \
build.sh \ build.sh \
build-explicit-output.sh \
ca/nix-run.sh \ ca/nix-run.sh \
selfref-gc.sh ca/selfref-gc.sh \ selfref-gc.sh ca/selfref-gc.sh \
db-migration.sh \ db-migration.sh \