From 4c9fdd2cd63f2f3c4e87790c5cacfdf5cd88591f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 26 Jan 2012 13:04:50 +0000 Subject: [PATCH] * Add a test for importing derivations. --- tests/Makefile.am | 3 ++- tests/import-derivation.nix | 23 +++++++++++++++++++++++ tests/import-derivation.sh | 12 ++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/import-derivation.nix create mode 100644 tests/import-derivation.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 15c103ec4..d60226fd2 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 000000000..91adcd288 --- /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 000000000..93a53a830 --- /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 ]