aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/lang
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/lang')
-rw-r--r--tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.err.exp10
-rw-r--r--tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.nix1
-rw-r--r--tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.err.exp11
-rw-r--r--tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix18
-rw-r--r--tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.err.exp11
-rw-r--r--tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix9
-rw-r--r--tests/functional/lang/eval-okay-context-introspection.exp2
-rw-r--r--tests/functional/lang/eval-okay-context-introspection.nix22
8 files changed, 81 insertions, 3 deletions
diff --git a/tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.err.exp b/tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.err.exp
new file mode 100644
index 000000000..ad91a22aa
--- /dev/null
+++ b/tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.err.exp
@@ -0,0 +1,10 @@
+error:
+ … while calling the 'addDrvOutputDependencies' builtin
+
+ at /pwd/lang/eval-fail-addDrvOutputDependencies-empty-context.nix:1:1:
+
+ 1| builtins.addDrvOutputDependencies ""
+ | ^
+ 2|
+
+ error: context of string '' must have exactly one element, but has 0
diff --git a/tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.nix b/tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.nix
new file mode 100644
index 000000000..dc9ee3ba2
--- /dev/null
+++ b/tests/functional/lang/eval-fail-addDrvOutputDependencies-empty-context.nix
@@ -0,0 +1 @@
+builtins.addDrvOutputDependencies ""
diff --git a/tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.err.exp b/tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.err.exp
new file mode 100644
index 000000000..bb389db4e
--- /dev/null
+++ b/tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.err.exp
@@ -0,0 +1,11 @@
+error:
+ … while calling the 'addDrvOutputDependencies' builtin
+
+ at /pwd/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix:18:4:
+
+ 17|
+ 18| in builtins.addDrvOutputDependencies combo-path
+ | ^
+ 19|
+
+ error: context of string '/nix/store/pg9yqs4yd85yhdm3f4i5dyaqp5jahrsz-fail.drv/nix/store/2dxd5frb715z451vbf7s8birlf3argbk-fail-2.drv' must have exactly one element, but has 2
diff --git a/tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix b/tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix
new file mode 100644
index 000000000..dbde264df
--- /dev/null
+++ b/tests/functional/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix
@@ -0,0 +1,18 @@
+let
+ drv0 = derivation {
+ name = "fail";
+ builder = "/bin/false";
+ system = "x86_64-linux";
+ outputs = [ "out" "foo" ];
+ };
+
+ drv1 = derivation {
+ name = "fail-2";
+ builder = "/bin/false";
+ system = "x86_64-linux";
+ outputs = [ "out" "foo" ];
+ };
+
+ combo-path = "${drv0.drvPath}${drv1.drvPath}";
+
+in builtins.addDrvOutputDependencies combo-path
diff --git a/tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.err.exp b/tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.err.exp
new file mode 100644
index 000000000..070381118
--- /dev/null
+++ b/tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.err.exp
@@ -0,0 +1,11 @@
+error:
+ … while calling the 'addDrvOutputDependencies' builtin
+
+ at /pwd/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix:9:4:
+
+ 8|
+ 9| in builtins.addDrvOutputDependencies drv.outPath
+ | ^
+ 10|
+
+ error: `addDrvOutputDependencies` can only act on derivations, not on a derivation output such as 'out'
diff --git a/tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix b/tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix
new file mode 100644
index 000000000..e379e1d95
--- /dev/null
+++ b/tests/functional/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix
@@ -0,0 +1,9 @@
+let
+ drv = derivation {
+ name = "fail";
+ builder = "/bin/false";
+ system = "x86_64-linux";
+ outputs = [ "out" "foo" ];
+ };
+
+in builtins.addDrvOutputDependencies drv.outPath
diff --git a/tests/functional/lang/eval-okay-context-introspection.exp b/tests/functional/lang/eval-okay-context-introspection.exp
index 03b400cc8..a136b0035 100644
--- a/tests/functional/lang/eval-okay-context-introspection.exp
+++ b/tests/functional/lang/eval-okay-context-introspection.exp
@@ -1 +1 @@
-[ true true true true true true ]
+[ true true true true true true true true true true true true true ]
diff --git a/tests/functional/lang/eval-okay-context-introspection.nix b/tests/functional/lang/eval-okay-context-introspection.nix
index 50a78d946..8886cf32e 100644
--- a/tests/functional/lang/eval-okay-context-introspection.nix
+++ b/tests/functional/lang/eval-okay-context-introspection.nix
@@ -31,11 +31,29 @@ let
(builtins.unsafeDiscardStringContext str)
(builtins.getContext str);
+ # Only holds true if string context contains both a `DrvDeep` and
+ # `Opaque` element.
+ almostEtaRule = str:
+ str == builtins.addDrvOutputDependencies
+ (builtins.unsafeDiscardOutputDependency str);
+
+ addDrvOutputDependencies_idempotent = str:
+ builtins.addDrvOutputDependencies str ==
+ builtins.addDrvOutputDependencies (builtins.addDrvOutputDependencies str);
+
+ rules = str: [
+ (etaRule str)
+ (almostEtaRule str)
+ (addDrvOutputDependencies_idempotent str)
+ ];
+
in [
(legit-context == desired-context)
(reconstructed-path == combo-path)
(etaRule "foo")
- (etaRule drv.drvPath)
(etaRule drv.foo.outPath)
- (etaRule (builtins.unsafeDiscardOutputDependency drv.drvPath))
+] ++ builtins.concatMap rules [
+ drv.drvPath
+ (builtins.addDrvOutputDependencies drv.drvPath)
+ (builtins.unsafeDiscardOutputDependency drv.drvPath)
]