aboutsummaryrefslogtreecommitdiff
path: root/tests/build.sh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-12-12 17:34:57 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-12-12 17:34:57 -0500
commitc886b1856184fc180603435197a10ea20df8bcfb (patch)
treef786f9e7bb505fabdf2af2a107e977c9350672b2 /tests/build.sh
parentd8c1c24c78ebeb1f695e29a489be567118eb073e (diff)
Merge new tests into `build.sh`
Diffstat (limited to 'tests/build.sh')
-rw-r--r--tests/build.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/build.sh b/tests/build.sh
index 3a3d773b1..036fb037e 100644
--- a/tests/build.sh
+++ b/tests/build.sh
@@ -58,6 +58,48 @@ nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
(.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)
nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status '
(.[0] |