From f0f8117d5bd17dcc0d3710328c009d4c90cae7b3 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 22 Feb 2026 23:57:48 +0100 Subject: [PATCH] testing: migrate flakes/flakes.sh (part 13) builds with incomplete lockfiles Change-Id: Ibf386ec98208d5b706236277e2eae9e144d9bdb0 --- tests/functional/flakes/flakes.sh | 29 ++-------------------------- tests/functional2/flakes/test_cli.py | 27 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/tests/functional/flakes/flakes.sh b/tests/functional/flakes/flakes.sh index bbf1481d5..cfde620da 100644 --- a/tests/functional/flakes/flakes.sh +++ b/tests/functional/flakes/flakes.sh @@ -85,33 +85,6 @@ nix path-info $flake1Dir/result nix build -o $TEST_ROOT/result $flake2Dir#bar --commit-lock-file nix build -o $TEST_ROOT/result $flake3Dir#xyzzy git -C $flake3Dir add flake.lock - -# Add dependency to flake3. -rm $flake3Dir/flake.nix - -cat > $flake3Dir/flake.nix < Path: return _make_flake_repo("flake3", flake3_files, git, env, request) +@pytest.fixture +def flake3_locked(git: Git, env: ManagedEnv, nix: Nix, flake3: Path, nonflake: Path) -> Path: # noqa: ARG001 + nix.nix(["flake", "lock", flake3, "--commit-lock-file"]).run().ok() + return flake3 + + @pytest.fixture def flake3_medium(git: Git, env: ManagedEnv, nix: Nix, flake3: Path, nonflake: Path) -> Path: # noqa: ARG001 (flake3 / "flake.nix").write_text(f"""{{ @@ -464,6 +470,27 @@ class TestBuild: logs = nix.nix(["build", url]).run().expect(102).stderr_s assert "NAR hash mismatch" in logs + class TestIncompleteLockfile: + @pytest.fixture(autouse=True) + def update_flake(self, nix: Nix, flake3: Path, git: Git, registry: Path): # noqa: ARG002 + nix.nix(["flake", "lock", flake3]).run().ok() + git(flake3, "add", "flake.lock") + (flake3 / "flake.nix").write_text(f"""{{ + outputs = {{ self, flake1, flake2 }}: rec {{ + packages.{system}.xyzzy = flake2.packages.{system}.bar; + packages.{system}."sth sth" = flake1.packages.{system}.foo; + }}; + }}""") + git(flake3, "add", "flake.nix") + git(flake3, "commit", "-m", "Update flake.nix") + + @pytest.mark.parametrize("attr", ["sth sth", "sth%20sth"]) + def test_build(self, nix: Nix, flake3: Path, git: Git, attr: str): + nix.nix(["build", f"{flake3}#{attr}"]).run().ok() + + # check that the lockfile was changed + assert git(flake3, "diff", "HEAD").stdout_s + @pytest.mark.usefixtures("registry") def test_flakes_gcroots(nix: Nix, flake1: Path, flake2: Path):