From 8d389fcccfe588ce9c50bf718bbe7c5e161c0344 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 28 Feb 2026 13:19:13 +0100 Subject: [PATCH] testing: migrate selfref-gc.sh Change-Id: Ibead4030448fb9251be78b3c876c7f054154c83c --- tests/functional/meson.build | 1 - tests/functional/selfref-gc.sh | 28 ---------------------- tests/functional2/store/test_gc.py | 37 ++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 29 deletions(-) delete mode 100644 tests/functional/selfref-gc.sh create mode 100644 tests/functional2/store/test_gc.py diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 816ee6cdc..dcff153e7 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -95,7 +95,6 @@ functional_tests_scripts = [ 'eval-store.sh', 'derivation-json.sh', 'import-derivation.sh', - 'selfref-gc.sh', 'db-migration.sh', 'bash-profile.sh', 'store-ping.sh', diff --git a/tests/functional/selfref-gc.sh b/tests/functional/selfref-gc.sh deleted file mode 100644 index cf1c4d18e..000000000 --- a/tests/functional/selfref-gc.sh +++ /dev/null @@ -1,28 +0,0 @@ -source common.sh - -clearStore - -nix-build --no-out-link -E ' - with import ./config.nix; - - let d1 = mkDerivation { - name = "selfref-gc"; - outputs = [ "out" ]; - buildCommand = " - echo SELF_REF: $out > $out - "; - }; in - - # the only change from d1 is d1 as an (unused) build input - # to get identical store path in CA. - mkDerivation { - name = "selfref-gc"; - outputs = [ "out" ]; - buildCommand = " - echo UNUSED: ${d1} - echo SELF_REF: $out > $out - "; - } -' - -nix-collect-garbage diff --git a/tests/functional2/store/test_gc.py b/tests/functional2/store/test_gc.py new file mode 100644 index 000000000..fbe4f971d --- /dev/null +++ b/tests/functional2/store/test_gc.py @@ -0,0 +1,37 @@ +from pathlib import Path +from testlib.fixtures.file_helper import with_files +from testlib.fixtures.nix import Nix +from testlib.utils import get_global_asset + + +@with_files({"config.nix": get_global_asset("config.nix")}) +def test_selfref_gc(nix: Nix): + expr = """ + with import ./config.nix; + + let d1 = mkDerivation { + name = "selfref-gc"; + outputs = [ "out" ]; + buildCommand = " + echo SELF_REF: $out > $out + "; + }; in + + # the only change from d1 is d1 as an (unused) build input + # to get identical store path in CA. + mkDerivation { + name = "selfref-gc"; + outputs = [ "out" ]; + buildCommand = " + echo UNUSED: ${d1} + echo SELF_REF: $out > $out + "; + } + """ + + out = Path(nix.nix_build(["--no-out-link", "-E", expr]).run().ok().stdout_plain) + assert out.exists() + + nix.nix([], nix_exe="nix-collect-garbage").run().ok() + + assert list(nix.env.dirs.real_store_dir.glob("*selfref*")) == []