about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/multiple-outputs.a.builder.sh6
-rw-r--r--tests/multiple-outputs.b.builder.sh7
-rw-r--r--tests/multiple-outputs.nix23
-rw-r--r--tests/multiple-outputs.sh15
5 files changed, 54 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 676a9c387b18..0418f73e6cf5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,7 +8,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
   referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
   gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
   remote-store.sh export.sh export-graph.sh negative-caching.sh \
-  binary-patching.sh timeout.sh secure-drv-outputs.sh
+  binary-patching.sh timeout.sh secure-drv-outputs.sh multiple-outputs.sh
 
 XFAIL_TESTS =
 
@@ -35,6 +35,8 @@ EXTRA_DIST = $(TESTS) \
   binary-patching.nix \
   timeout.nix timeout.builder.sh \
   secure-drv-outputs.nix \
+  multiple-outputs.nix \
+  multiple-outputs.a.builder.sh multiple-outputs.b.builder.sh \
   $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
   common.sh.in
 
diff --git a/tests/multiple-outputs.a.builder.sh b/tests/multiple-outputs.a.builder.sh
new file mode 100644
index 000000000000..657b7ea0adc5
--- /dev/null
+++ b/tests/multiple-outputs.a.builder.sh
@@ -0,0 +1,6 @@
+mkdir $first
+mkdir $second
+test -z $all
+
+echo "second" > $first/file
+echo "first" > $second/file
diff --git a/tests/multiple-outputs.b.builder.sh b/tests/multiple-outputs.b.builder.sh
new file mode 100644
index 000000000000..bc63fc0681b0
--- /dev/null
+++ b/tests/multiple-outputs.b.builder.sh
@@ -0,0 +1,7 @@
+mkdir $out
+test "$firstOutput $secondOutput" = "$allOutputs"
+test "$defaultOutput" = "$firstOutput"
+test "$(cat $first/file)" = "second"
+test "$(cat $second/file)" = "first"
+
+echo "success" > $out/file
diff --git a/tests/multiple-outputs.nix b/tests/multiple-outputs.nix
new file mode 100644
index 000000000000..e8fbf91bfa89
--- /dev/null
+++ b/tests/multiple-outputs.nix
@@ -0,0 +1,23 @@
+with import ./config.nix;
+
+let
+
+  a = mkDerivation {
+    name = "multiple-outputs-a";
+    outputs = [ "first" "second" ];
+    builder = ./multiple-outputs.a.builder.sh;
+    helloString = "Hello, world!";
+  };
+
+in
+
+assert a.second.helloString == "Hello, world!";
+
+mkDerivation {
+  defaultOutput = a;
+  firstOutput = a.first.first;
+  secondOutput = a.second.first.first.second.second.first.second;
+  allOutputs = a.all;
+  name = "multiple-outputs-b";
+  builder = ./multiple-outputs.b.builder.sh;
+}
diff --git a/tests/multiple-outputs.sh b/tests/multiple-outputs.sh
new file mode 100644
index 000000000000..f4cd01234c5b
--- /dev/null
+++ b/tests/multiple-outputs.sh
@@ -0,0 +1,15 @@
+source common.sh
+
+echo "Testing multiple outputs..."
+
+drvPath=$($nixinstantiate multiple-outputs.nix)
+
+echo "derivation is $drvPath"
+
+outPath=$($nixstore -rvv "$drvPath")
+
+echo "output path is $outPath"
+
+text=$(cat "$outPath"/file)
+if test "$text" != "success"; then exit 1; fi
+