From 6e982797f88a0dd3b4a25fe6c26b009e007babfe Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Sat, 11 Jul 2026 17:09:34 -0600 Subject: [PATCH] Fix cross-platform flakiness in ERC root-resolution test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_root_resolves_to_project_schematic built its project directly in tmp_path, where the autouse _set_test_search_paths fixture also drops a test_project.kicad_pro. With two .kicad_pro files in one directory, root resolution returned whichever os.listdir yielded first — myproject on ext4, test_project on APFS — so it passed on Linux and failed on macOS. Anchor the test's project in its own subdirectory so the walk stops at the intended root. --- tests/test_schematic_analysis.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test_schematic_analysis.py b/tests/test_schematic_analysis.py index 52b8f18..734616b 100644 --- a/tests/test_schematic_analysis.py +++ b/tests/test_schematic_analysis.py @@ -2,6 +2,7 @@ import pytest + @pytest.mark.unit class TestRunSchematicErc: """Tests for the run_schematic_erc tool.""" @@ -182,14 +183,22 @@ class TestErcJsonParsing: from mckicad.tools.schematic_analysis import run_schematic_erc - # Create a project structure with root + sub-sheet - pro_file = tmp_path / "myproject.kicad_pro" + # Anchor the project in its own subdirectory. The autouse + # _set_test_search_paths fixture drops a second "test_project.kicad_pro" + # into tmp_path; keeping our project one level down means the root walk + # finds *this* project's .kicad_pro and stops before it reaches (and is + # confused by) the sibling. Without this, resolution depends on + # os.listdir order, which differs between ext4 and APFS. + proj_dir = tmp_path / "myproject" + proj_dir.mkdir() + + pro_file = proj_dir / "myproject.kicad_pro" pro_file.write_text("{}") - root_sch = tmp_path / "myproject.kicad_sch" + root_sch = proj_dir / "myproject.kicad_sch" root_sch.write_text('(kicad_sch (version 20231120) (uuid "root"))\n') - sub_dir = tmp_path / "sub" + sub_dir = proj_dir / "sub" sub_dir.mkdir() sub_sch = sub_dir / "power.kicad_sch" sub_sch.write_text('(kicad_sch (version 20231120) (uuid "sub"))\n')