aboutsummaryrefslogtreecommitdiff
path: root/tests/nix-collect-garbage-d.sh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-16 11:25:45 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-06-14 19:01:07 -0400
commitd4a2ced9cb99253a277c1507baf001d51871842f (patch)
tree06c13f8aa5e78b09e6458c5d46f43d412e4d06c1 /tests/nix-collect-garbage-d.sh
parentca5752d4faecad8b87ba59892b9ca2a3d8350837 (diff)
Split out `nix-collect-garbage -d` test to new file
Good for test parallelism, and separation of concerns (core GC vs profiles deleting).
Diffstat (limited to 'tests/nix-collect-garbage-d.sh')
-rw-r--r--tests/nix-collect-garbage-d.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/nix-collect-garbage-d.sh b/tests/nix-collect-garbage-d.sh
new file mode 100644
index 000000000..bf30f8938
--- /dev/null
+++ b/tests/nix-collect-garbage-d.sh
@@ -0,0 +1,40 @@
+source common.sh
+
+clearStore
+
+## Test `nix-collect-garbage -d`
+
+# TODO make `nix-env` doesn't work with CA derivations, and make
+# `ca/nix-collect-garbage-d.sh` wrapper.
+
+testCollectGarbageD () {
+ clearProfiles
+ # Run two `nix-env` commands, should create two generations of
+ # the profile
+ nix-env -f ./user-envs.nix -i foo-1.0 "$@"
+ nix-env -f ./user-envs.nix -i foo-2.0pre1 "$@"
+ [[ $(nix-env --list-generations "$@" | wc -l) -eq 2 ]]
+
+ # Clear the profile history. There should be only one generation
+ # left
+ nix-collect-garbage -d
+ [[ $(nix-env --list-generations "$@" | wc -l) -eq 1 ]]
+}
+
+testCollectGarbageD
+
+# Run the same test, but forcing the profiles an arbitrary location.
+rm ~/.nix-profile
+ln -s $TEST_ROOT/blah ~/.nix-profile
+testCollectGarbageD
+
+# Run the same test, but forcing the profiles at their legacy location under
+# /nix/var/nix.
+#
+# Note that we *don't* use the default profile; `nix-collect-garbage` will
+# need to check the legacy conditional unconditionally not just follow
+# `~/.nix-profile` to pass this test.
+#
+# Regression test for #8294
+rm ~/.nix-profile
+testCollectGarbageD --profile "$NIX_STATE_DIR/profiles/per-user/me"