From 1ebfa6ba2d5e6be9eb0d83a89dc4fcb2470e773a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 18 Jan 2023 14:21:17 +0100 Subject: [PATCH] Add some tests for illegal output names --- tests/build.sh | 4 ++-- tests/multiple-outputs.nix | 10 ++++++++++ tests/multiple-outputs.sh | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/build.sh b/tests/build.sh index 898c6963a..b6dadb433 100644 --- a/tests/build.sh +++ b/tests/build.sh @@ -89,7 +89,7 @@ nix build "$drv^first,second" --no-link --json | jq --exit-status ' (.outputs | (keys | length == 2) and (.first | match(".*multiple-outputs-a-first")) and - (.second | match(".*multiple-outputs-a-second")))) + (.second | match(".*multiple-outputs-a-second")))) ' nix build "$drv^*" --no-link --json | jq --exit-status ' @@ -98,7 +98,7 @@ nix build "$drv^*" --no-link --json | jq --exit-status ' (.outputs | (keys | length == 2) and (.first | match(".*multiple-outputs-a-first")) and - (.second | match(".*multiple-outputs-a-second")))) + (.second | match(".*multiple-outputs-a-second")))) ' # Make sure that `--impure` works (regression test for https://github.com/NixOS/nix/issues/6488) diff --git a/tests/multiple-outputs.nix b/tests/multiple-outputs.nix index 9a097b5f1..413d392e4 100644 --- a/tests/multiple-outputs.nix +++ b/tests/multiple-outputs.nix @@ -117,4 +117,14 @@ rec { ''; }; + invalid-output-name-1 = mkDerivation { + name = "invalid-output-name-1"; + outputs = [ "out/"]; + }; + + invalid-output-name-2 = mkDerivation { + name = "invalid-output-name-2"; + outputs = [ "x" "foo$"]; + }; + } diff --git a/tests/multiple-outputs.sh b/tests/multiple-outputs.sh index 0d45ad35b..66be6fa64 100644 --- a/tests/multiple-outputs.sh +++ b/tests/multiple-outputs.sh @@ -83,3 +83,6 @@ nix-store --gc --keep-derivations --keep-outputs nix-store --gc --print-roots rm -rf $NIX_STORE_DIR/.links rmdir $NIX_STORE_DIR + +nix build -f multiple-outputs.nix invalid-output-name-1 2>&1 | grep 'contains illegal character' +nix build -f multiple-outputs.nix invalid-output-name-2 2>&1 | grep 'contains illegal character'