Add test for readFile keeping context

This commit is contained in:
Nikolay Amiantov 2017-11-11 01:51:34 +03:00
parent c66865dff1
commit 120ca245d1
4 changed files with 38 additions and 1 deletions

View File

@ -59,7 +59,8 @@ nix_tests = \
ca/recursive.sh \
ca/concurrent-builds.sh \
ca/nix-copy.sh \
eval-store.sh
eval-store.sh \
readfile-context.sh
# parallel.sh
ifeq ($(HAVE_LIBCPUID), 1)

View File

@ -0,0 +1 @@
echo "$input" > $out

View File

@ -0,0 +1,19 @@
with import ./config.nix;
let
input = import ./simple.nix;
dependent = mkDerivation {
name = "dependent";
builder = ./readfile-context.builder.sh;
input = "${input}/hello";
};
readDependent = mkDerivation {
name = "read-dependent";
builder = ./readfile-context.builder.sh;
input = builtins.readFile dependent;
};
in readDependent

16
tests/readfile-context.sh Normal file
View File

@ -0,0 +1,16 @@
source common.sh
clearStore
outPath=$(nix-build --no-out-link readfile-context.nix)
# Set a GC root.
ln -s $outPath "$NIX_STATE_DIR"/gcroots/foo
# Check that file exists.
[ "$(cat $(cat $outPath))" = "Hello World!" ]
nix-collect-garbage
# Check that file still exists.
[ "$(cat $(cat $outPath))" = "Hello World!" ]