From e97e9e9f0055d02c16a3dc8e7891c06d643aaf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 15 May 2023 11:58:49 +0200 Subject: test the garbage collection with the old profile dir Regression test for https://github.com/NixOS/nix/issues/8294 --- tests/gc.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests/gc.sh') diff --git a/tests/gc.sh b/tests/gc.sh index 98d6cb032..95669e25c 100644 --- a/tests/gc.sh +++ b/tests/gc.sh @@ -52,9 +52,7 @@ rmdir $NIX_STORE_DIR/.links rmdir $NIX_STORE_DIR ## Test `nix-collect-garbage -d` -# `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're -# using them -if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then +testCollectGarbageD () { clearProfiles # Run two `nix-env` commands, should create two generations of # the profile @@ -66,4 +64,17 @@ if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then # left nix-collect-garbage -d [[ $(nix-env --list-generations | wc -l) -eq 1 ]] +} +# `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're +# using them +if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then + testCollectGarbageD + + # Run the same test, but forcing the profiles at their legacy location under + # /nix/var/nix. + # + # Regression test for #8294 + rm ~/.nix-profile + ln -s $NIX_STATE_DIR/profiles/per-user/me ~/.nix-profile + testCollectGarbageD fi -- cgit v1.2.3 From ca5752d4faecad8b87ba59892b9ca2a3d8350837 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 16 May 2023 11:21:50 -0400 Subject: Add another case to the `nix-collect-garbage -d` test --- tests/gc.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'tests/gc.sh') diff --git a/tests/gc.sh b/tests/gc.sh index 95669e25c..9d92ad758 100644 --- a/tests/gc.sh +++ b/tests/gc.sh @@ -56,25 +56,34 @@ 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 ]] + 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 ]] + [[ $(nix-env --list-generations "$@" | wc -l) -eq 1 ]] } + # `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're # using them if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then 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 - ln -s $NIX_STATE_DIR/profiles/per-user/me ~/.nix-profile - testCollectGarbageD + testCollectGarbageD --profile "$NIX_STATE_DIR/profiles/per-user/me" fi -- cgit v1.2.3 From d4a2ced9cb99253a277c1507baf001d51871842f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 16 May 2023 11:25:45 -0400 Subject: Split out `nix-collect-garbage -d` test to new file Good for test parallelism, and separation of concerns (core GC vs profiles deleting). --- tests/gc.sh | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'tests/gc.sh') diff --git a/tests/gc.sh b/tests/gc.sh index 9d92ad758..ad09a8b39 100644 --- a/tests/gc.sh +++ b/tests/gc.sh @@ -50,40 +50,3 @@ if test -e $outPath/foobar; then false; fi # Check that the store is empty. rmdir $NIX_STORE_DIR/.links rmdir $NIX_STORE_DIR - -## Test `nix-collect-garbage -d` -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 ]] -} - -# `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're -# using them -if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then - 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" -fi -- cgit v1.2.3