testing: migrate flakes/flakes.sh (part 13)
builds with incomplete lockfiles Change-Id: Ibf386ec98208d5b706236277e2eae9e144d9bdb0
This commit is contained in:
@@ -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 <<EOF
|
||||
{
|
||||
description = "Fnord";
|
||||
|
||||
outputs = { self, flake1, flake2 }: rec {
|
||||
packages.$system.xyzzy = flake2.packages.$system.bar;
|
||||
packages.$system."sth sth" = flake1.packages.$system.foo;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
git -C $flake3Dir add flake.nix
|
||||
git -C $flake3Dir commit -m 'Update flake.nix'
|
||||
|
||||
# Check whether `nix build` works with an incomplete lockfile
|
||||
nix build -o $TEST_ROOT/result $flake3Dir#"sth sth"
|
||||
nix build -o $TEST_ROOT/result $flake3Dir#"sth%20sth"
|
||||
|
||||
# Check whether it saved the lockfile
|
||||
[[ -n $(git -C $flake3Dir diff master) ]]
|
||||
|
||||
git -C $flake3Dir add flake.lock
|
||||
|
||||
git -C $flake3Dir commit -m 'Add lockfile'
|
||||
|
||||
# Add nonFlakeInputs to flake3.
|
||||
@@ -173,6 +146,8 @@ nix build -o $TEST_ROOT/result $flake3Dir#sth --commit-lock-file
|
||||
|
||||
Flake lock file updates:
|
||||
|
||||
• Added input 'flake1':
|
||||
'git+file://"*"/flakes/flakes/flake1?ref=refs/heads/master&rev="*"' "*"
|
||||
• Added input 'nonFlake':
|
||||
'git+file://"*"/flakes/flakes/nonFlake?ref=refs/heads/master&rev="*"' "*"
|
||||
• Added input 'nonFlakeFile':
|
||||
|
||||
@@ -92,6 +92,12 @@ def flake3(git: Git, env: ManagedEnv, request: pytest.FixtureRequest) -> 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):
|
||||
|
||||
Reference in New Issue
Block a user