about summary refs log tree commit diff
path: root/tests/gc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gc.sh')
-rw-r--r--tests/gc.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/gc.sh b/tests/gc.sh
new file mode 100644
index 000000000000..9aeda43e7101
--- /dev/null
+++ b/tests/gc.sh
@@ -0,0 +1,14 @@
+storeExpr=$($TOP/src/nix-instantiate/nix-instantiate dependencies.nix)
+outPath=$($TOP/src/nix-store/nix-store -rvv "$storeExpr")
+
+# Set a GC root.
+ln -s $outPath "$NIX_LOCALSTATE_DIR"/nix/gcroots/foo
+
+$NIX_BIN_DIR/nix-collect-garbage
+
+# Check that the root and its dependencies haven't been deleted.
+cat $outPath/foobar
+cat $outPath/input-2/bar
+
+# Check that the derivation has been GC'd.
+if cat $storeExpr > /dev/null; then false; fi