* Add a test for importing derivations.

This commit is contained in:
Eelco Dolstra 2012-01-26 13:04:50 +00:00
parent 330df4b4db
commit 4c9fdd2cd6
3 changed files with 37 additions and 1 deletions

View file

@ -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

View file

@ -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
'';
}

View file

@ -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 ]