diff --git a/src/copper_pilot_cli/validate/runner.py b/src/copper_pilot_cli/validate/runner.py index 26e5b02..f546595 100644 --- a/src/copper_pilot_cli/validate/runner.py +++ b/src/copper_pilot_cli/validate/runner.py @@ -423,6 +423,7 @@ def cache_key(self, check: CheckSpec) -> str: "inputs": input_hashes(self.workspace, list(check.inputs)), "repeat": self.options.repeat, "effort": self.options.effort, + "kicad_version": self.design.kicad_version if self.design is not None else None, } return hashlib.sha256(json.dumps(payload, sort_keys=True).encode()).hexdigest() diff --git a/tests/test_validate.py b/tests/test_validate.py index 9042529..70889ec 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -959,6 +959,36 @@ async def test_cache_reuse_and_invalidation(tmp_path) -> None: assert not any(result.cached for result in fourth.results) +@pytest.mark.asyncio +async def test_kicad_version_change_invalidates_cached_erc_and_drc(tmp_path): + make_project(tmp_path) + options = RunOptions(gate=GateMode.FULL) + + # First validation with KiCad 9. + kicad9 = FakeKicad(version="9.0.1") + await runner_for( + tmp_path, + options=options, + kicad=kicad9, + ).run() + + # Second validation with KiCad 10, without changing the design. + kicad10 = FakeKicad(version="10.0.4") + second = await runner_for( + tmp_path, + options=options, + kicad=kicad10, + ).run() + + results = {result.check_id: result for result in second.results} + + assert results["sch.erc"].cached is False + assert results["pcb.drc"].cached is False + + assert "erc" in kicad10.calls + assert "drc" in kicad10.calls + + @pytest.mark.asyncio async def test_error_results_are_never_cached(tmp_path) -> None: make_project(tmp_path)