aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-01-10 16:55:28 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-01-10 16:55:28 +0100
commitf39d94a55be7db1759e3fcd8aea24bfb0da7b8c2 (patch)
treefd6380a2b51e35dda3d8f1a5f18537c3935aa127 /tests
parent19fd6e585d8f4cad3e358361b6f983b0d7d3b8a9 (diff)
parent120ca245d13708743a59e83da12ec90902636236 (diff)
Merge branch 'readfile' of https://github.com/abbradar/nix
Diffstat (limited to 'tests')
-rw-r--r--tests/local.mk3
-rw-r--r--tests/readfile-context.builder.sh1
-rw-r--r--tests/readfile-context.nix19
-rw-r--r--tests/readfile-context.sh16
4 files changed, 38 insertions, 1 deletions
diff --git a/tests/local.mk b/tests/local.mk
index c22e779a6..d2a46f22b 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -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)
diff --git a/tests/readfile-context.builder.sh b/tests/readfile-context.builder.sh
new file mode 100644
index 000000000..7084a08cb
--- /dev/null
+++ b/tests/readfile-context.builder.sh
@@ -0,0 +1 @@
+echo "$input" > $out
diff --git a/tests/readfile-context.nix b/tests/readfile-context.nix
new file mode 100644
index 000000000..600036a94
--- /dev/null
+++ b/tests/readfile-context.nix
@@ -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
diff --git a/tests/readfile-context.sh b/tests/readfile-context.sh
new file mode 100644
index 000000000..31e70ddb1
--- /dev/null
+++ b/tests/readfile-context.sh
@@ -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!" ]