about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2012-01-26T13·04+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2012-01-26T13·04+0000
commit4c9fdd2cd63f2f3c4e87790c5cacfdf5cd88591f (patch)
treed5b4c5239ff8184014610eb73c7d66247d397b77
parent330df4b4dbb363b69e10fa96d1e22f62088bfc96 (diff)
* Add a test for importing derivations.
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/import-derivation.nix23
-rw-r--r--tests/import-derivation.sh12
3 files changed, 37 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 15c103ec4660..d60226fd2d55 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,7 +9,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.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 nix-channel.sh \
-  multiple-outputs.sh
+  multiple-outputs.sh import-derivation.sh
 
 XFAIL_TESTS =
 
@@ -37,5 +37,6 @@ EXTRA_DIST = $(TESTS) \
   timeout.nix timeout.builder.sh \
   secure-drv-outputs.nix \
   multiple-outputs.nix \
+  import-derivation.nix \
   $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
   common.sh.in
diff --git a/tests/import-derivation.nix b/tests/import-derivation.nix
new file mode 100644
index 000000000000..91adcd288f6e
--- /dev/null
+++ b/tests/import-derivation.nix
@@ -0,0 +1,23 @@
+with import ./config.nix;
+
+let
+
+  bar = mkDerivation {
+    name = "bar";
+    builder = builtins.toFile "builder.sh"
+      ''
+        echo 'builtins.add 123 456' > $out
+      '';
+  };
+
+  value = import bar;
+
+in
+
+mkDerivation {
+  name = "foo";
+  builder = builtins.toFile "builder.sh"
+    ''
+      echo -n FOO${toString value} > $out
+    '';
+}
diff --git a/tests/import-derivation.sh b/tests/import-derivation.sh
new file mode 100644
index 000000000000..93a53a830af8
--- /dev/null
+++ b/tests/import-derivation.sh
@@ -0,0 +1,12 @@
+source common.sh
+
+clearStore
+
+if nix-instantiate --readonly-mode ./import-derivation.nix; then
+    echo "read-only evaluation of an imported derivation unexpectedly failed"
+    exit 1
+fi
+
+outPath=$(nix-build ./import-derivation.nix)
+
+[ "$(cat $outPath)" = FOO579 ]