From af300230cf4a70a5681aadf7a8ed35add1b58962 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 12 Nov 2026 02:34:16 +0000 Subject: tests: check re-locking of generated flakes and git+file: references Deploying the same sources twice doesn't show whether generated flakes get locked again, and the git scenarios' results are the same whether a Git work tree is referred to as git+file: or path:. A feature scenario changes what a source contains between two deploys, and the git scenarios check the reference. --- tests/fixtures.sh | 6 ++++++ tests/scenarios.nix | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/fixtures.sh b/tests/fixtures.sh index 1b39b45..833df77 100755 --- a/tests/fixtures.sh +++ b/tests/fixtures.sh @@ -252,6 +252,12 @@ SH chmod +x /fixtures/pipe2 echo piped > /fixtures/pipe2-data +# alt2: like alt, with other outputs, to change a source to. +mkdir /fixtures/alt2 +cat > /fixtures/alt2/flake.nix <<'NIX' +{ outputs = _: { greeting = "alt2"; who = "alt2"; }; } +NIX + # noflake: a directory without flake.nix. mkdir /fixtures/noflake echo noflake > /fixtures/noflake/README diff --git a/tests/scenarios.nix b/tests/scenarios.nix index eb6bbec..e56cb13 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -358,6 +358,8 @@ assert !(krops.isLocalTarget (targets.remote "/")); } test -e "$T"/x/two || fail "two missing" '' + optionalString flags.inputs '' + grep -q '"git+file:' "$T"/.populate/flakes/x/flake.nix || + fail "the Git work tree isn't referred to as git+file:" gc expect_eq msg "$(nix_eval "$T"/.populate/flakes/x#msg)" git:alt ''; @@ -559,6 +561,26 @@ assert !(krops.isLocalTarget (targets.remote "/")); ''; }; }) + # A generated flake gets locked again when a source it draws from + # changes. + (s "relock" (let + x.file = { path = "/fixtures/filesrc"; inputs.dep.follows = "a"; }; + in { + phases = [ + { + sources = { inherit x; a.file = "/fixtures/alt"; }; + check = '' + expect_eq msg "$(nix_eval_online "$T"/.populate/flakes/x#msg)" top:alt,sub + ''; + } + { + sources = { inherit x; a.file = "/fixtures/alt2"; }; + check = '' + expect_eq msg "$(nix_eval_online "$T"/.populate/flakes/x#msg)" top:alt2,sub + ''; + } + ]; + })) # A generated flake gets removed once its source draws no inputs anymore. (s "removal" { phases = [ -- cgit v1.3.1