aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/build-hook-ca-floating.nix55
-rw-r--r--tests/build-hook.nix11
-rw-r--r--tests/build-remote.sh9
-rw-r--r--tests/build.sh15
-rw-r--r--tests/lang/eval-okay-context-introspection.exp2
-rw-r--r--tests/lang/eval-okay-context-introspection.nix23
-rw-r--r--tests/lang/eval-okay-readDir.exp2
-rw-r--r--tests/lang/eval-okay-readFileType.exp1
-rw-r--r--tests/lang/eval-okay-readFileType.nix6
l---------tests/lang/readDir/ldir1
l---------tests/lang/readDir/linked1
-rw-r--r--tests/multiple-outputs.nix16
-rw-r--r--tests/multiple-outputs.sh3
13 files changed, 71 insertions, 74 deletions
diff --git a/tests/build-hook-ca-floating.nix b/tests/build-hook-ca-floating.nix
index 67295985f..dfdbb82da 100644
--- a/tests/build-hook-ca-floating.nix
+++ b/tests/build-hook-ca-floating.nix
@@ -1,53 +1,6 @@
{ busybox }:
-with import ./config.nix;
-
-let
-
- mkDerivation = args:
- derivation ({
- inherit system;
- builder = busybox;
- args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
- outputHashMode = "recursive";
- outputHashAlgo = "sha256";
- __contentAddressed = true;
- } // removeAttrs args ["builder" "meta"])
- // { meta = args.meta or {}; };
-
- input1 = mkDerivation {
- shell = busybox;
- name = "build-remote-input-1";
- buildCommand = "echo FOO > $out";
- requiredSystemFeatures = ["foo"];
- };
-
- input2 = mkDerivation {
- shell = busybox;
- name = "build-remote-input-2";
- buildCommand = "echo BAR > $out";
- requiredSystemFeatures = ["bar"];
- };
-
- input3 = mkDerivation {
- shell = busybox;
- name = "build-remote-input-3";
- buildCommand = ''
- read x < ${input2}
- echo $x BAZ > $out
- '';
- requiredSystemFeatures = ["baz"];
- };
-
-in
-
- mkDerivation {
- shell = busybox;
- name = "build-remote";
- buildCommand =
- ''
- read x < ${input1}
- read y < ${input3}
- echo "$x $y" > $out
- '';
- }
+import ./build-hook.nix {
+ inherit busybox;
+ contentAddressed = true;
+}
diff --git a/tests/build-hook.nix b/tests/build-hook.nix
index 643334caa..7effd7903 100644
--- a/tests/build-hook.nix
+++ b/tests/build-hook.nix
@@ -1,15 +1,22 @@
-{ busybox }:
+{ busybox, contentAddressed ? false }:
with import ./config.nix;
let
+ caArgs = if contentAddressed then {
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+ __contentAddressed = true;
+ } else {};
+
mkDerivation = args:
derivation ({
inherit system;
builder = busybox;
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
- } // removeAttrs args ["builder" "meta" "passthru"])
+ } // removeAttrs args ["builder" "meta" "passthru"]
+ // caArgs)
// { meta = args.meta or {}; passthru = args.passthru or {}; };
input1 = mkDerivation {
diff --git a/tests/build-remote.sh b/tests/build-remote.sh
index e73c37ea4..25a482003 100644
--- a/tests/build-remote.sh
+++ b/tests/build-remote.sh
@@ -63,12 +63,9 @@ nix path-info --store $TEST_ROOT/machine3 --all \
| grep builder-build-remote-input-3.sh
-# Temporarily disabled because of https://github.com/NixOS/nix/issues/6209
-if [[ -z "$CONTENT_ADDRESSED" ]]; then
- for i in input1 input3; do
- nix log --store $TEST_ROOT/machine0 --file "$file" --arg busybox $busybox passthru."$i" | grep hi-$i
- done
-fi
+for i in input1 input3; do
+nix log --store $TEST_ROOT/machine0 --file "$file" --arg busybox $busybox passthru."$i" | grep hi-$i
+done
# Behavior of keep-failed
out="$(nix-build 2>&1 failing.nix \
diff --git a/tests/build.sh b/tests/build.sh
index 036fb037e..a00fb5232 100644
--- a/tests/build.sh
+++ b/tests/build.sh
@@ -42,20 +42,21 @@ nix build -f multiple-outputs.nix --json 'a^*' --no-link | jq --exit-status '
nix build -f multiple-outputs.nix --json e --no-link | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-e.drv")) and
- (.outputs | keys == ["a", "b"]))
+ (.outputs | keys == ["a_a", "b"]))
'
# But not when it's overriden.
-nix build -f multiple-outputs.nix --json e^a --no-link | jq --exit-status '
+nix build -f multiple-outputs.nix --json e^a_a --no-link
+nix build -f multiple-outputs.nix --json e^a_a --no-link | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-e.drv")) and
- (.outputs | keys == ["a"]))
+ (.outputs | keys == ["a_a"]))
'
nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-e.drv")) and
- (.outputs | keys == ["a", "b", "c"]))
+ (.outputs | keys == ["a_a", "b", "c"]))
'
# Test building from raw store path to drv not expression.
@@ -88,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 '
@@ -97,14 +98,14 @@ 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)
nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status '
(.[0] |
(.drvPath | match(".*multiple-outputs-e.drv")) and
- (.outputs | keys == ["a", "b"]))
+ (.outputs | keys == ["a_a", "b"]))
'
testNormalization () {
diff --git a/tests/lang/eval-okay-context-introspection.exp b/tests/lang/eval-okay-context-introspection.exp
index 27ba77dda..03b400cc8 100644
--- a/tests/lang/eval-okay-context-introspection.exp
+++ b/tests/lang/eval-okay-context-introspection.exp
@@ -1 +1 @@
-true
+[ true true true true true true ]
diff --git a/tests/lang/eval-okay-context-introspection.nix b/tests/lang/eval-okay-context-introspection.nix
index 43178bd2e..50a78d946 100644
--- a/tests/lang/eval-okay-context-introspection.nix
+++ b/tests/lang/eval-okay-context-introspection.nix
@@ -18,7 +18,24 @@ let
};
};
- legit-context = builtins.getContext "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
+ combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
+ legit-context = builtins.getContext combo-path;
- constructed-context = builtins.getContext (builtins.appendContext "" desired-context);
-in legit-context == constructed-context
+ reconstructed-path = builtins.appendContext
+ (builtins.unsafeDiscardStringContext combo-path)
+ desired-context;
+
+ # Eta rule for strings with context.
+ etaRule = str:
+ str == builtins.appendContext
+ (builtins.unsafeDiscardStringContext str)
+ (builtins.getContext str);
+
+in [
+ (legit-context == desired-context)
+ (reconstructed-path == combo-path)
+ (etaRule "foo")
+ (etaRule drv.drvPath)
+ (etaRule drv.foo.outPath)
+ (etaRule (builtins.unsafeDiscardOutputDependency drv.drvPath))
+]
diff --git a/tests/lang/eval-okay-readDir.exp b/tests/lang/eval-okay-readDir.exp
index bf8d2c14e..6413f6d4f 100644
--- a/tests/lang/eval-okay-readDir.exp
+++ b/tests/lang/eval-okay-readDir.exp
@@ -1 +1 @@
-{ bar = "regular"; foo = "directory"; }
+{ bar = "regular"; foo = "directory"; ldir = "symlink"; linked = "symlink"; }
diff --git a/tests/lang/eval-okay-readFileType.exp b/tests/lang/eval-okay-readFileType.exp
new file mode 100644
index 000000000..6413f6d4f
--- /dev/null
+++ b/tests/lang/eval-okay-readFileType.exp
@@ -0,0 +1 @@
+{ bar = "regular"; foo = "directory"; ldir = "symlink"; linked = "symlink"; }
diff --git a/tests/lang/eval-okay-readFileType.nix b/tests/lang/eval-okay-readFileType.nix
new file mode 100644
index 000000000..174fb6c3a
--- /dev/null
+++ b/tests/lang/eval-okay-readFileType.nix
@@ -0,0 +1,6 @@
+{
+ bar = builtins.readFileType ./readDir/bar;
+ foo = builtins.readFileType ./readDir/foo;
+ linked = builtins.readFileType ./readDir/linked;
+ ldir = builtins.readFileType ./readDir/ldir;
+}
diff --git a/tests/lang/readDir/ldir b/tests/lang/readDir/ldir
new file mode 120000
index 000000000..191028156
--- /dev/null
+++ b/tests/lang/readDir/ldir
@@ -0,0 +1 @@
+foo \ No newline at end of file
diff --git a/tests/lang/readDir/linked b/tests/lang/readDir/linked
new file mode 120000
index 000000000..c503f86a0
--- /dev/null
+++ b/tests/lang/readDir/linked
@@ -0,0 +1 @@
+foo/git-hates-directories \ No newline at end of file
diff --git a/tests/multiple-outputs.nix b/tests/multiple-outputs.nix
index 1429bc648..413d392e4 100644
--- a/tests/multiple-outputs.nix
+++ b/tests/multiple-outputs.nix
@@ -91,9 +91,9 @@ rec {
e = mkDerivation {
name = "multiple-outputs-e";
- outputs = [ "a" "b" "c" ];
- meta.outputsToInstall = [ "a" "b" ];
- buildCommand = "mkdir $a $b $c";
+ outputs = [ "a_a" "b" "c" ];
+ meta.outputsToInstall = [ "a_a" "b" ];
+ buildCommand = "mkdir $a_a $b $c";
};
independent = mkDerivation {
@@ -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'