Skip to content

Commit 61ed14d

Browse files
committed
feat(test): ALWAYS_RUN_ALL classification for coverage selection
1 parent 94d5e48 commit 61ed14d

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

toolchain/mfc/test/coverage.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ def save_map(path: Path, entries: dict, *, n_tests: int, git_sha: str, gfortran_
3838
json.dump(payload, f, indent=2, sort_keys=True)
3939

4040

41+
ALWAYS_RUN_ALL_EXACT = frozenset(["CMakeLists.txt"])
42+
ALWAYS_RUN_ALL_PREFIXES = (
43+
"src/common/include/", # GPU/Fypp macro & include files (CPU map can't line-attribute)
44+
"toolchain/cmake/", # build system
45+
"toolchain/mfc/params/", # parameter codegen -> emits Fortran broadly
46+
"toolchain/bootstrap/", # build/run scripts
47+
)
48+
49+
50+
def is_always_run_all(changed_files: set) -> bool:
51+
"""True if any changed file forces the full suite (un-attributable by the CPU map)."""
52+
if changed_files & ALWAYS_RUN_ALL_EXACT:
53+
return True
54+
return any(f.startswith(ALWAYS_RUN_ALL_PREFIXES) for f in changed_files)
55+
56+
4157
def load_map(path: Path) -> Tuple[Optional[dict], Optional[dict]]:
4258
"""Return (entries_without_meta, meta), or (None, None) if missing/corrupt."""
4359
if not Path(path).exists():

toolchain/mfc/test/test_coverage_unit.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import tempfile
22
from pathlib import Path
33

4-
from mfc.test.coverage import load_map, param_hash, save_map
4+
from mfc.test.coverage import is_always_run_all, load_map, param_hash, save_map
55

66

77
def test_param_hash_is_order_independent():
@@ -46,3 +46,24 @@ def test_load_corrupt_returns_none():
4646
p = Path(d) / "m.json.gz"
4747
p.write_bytes(b"not gzip")
4848
assert load_map(p) == (None, None)
49+
50+
51+
def test_macro_file_forces_all():
52+
assert is_always_run_all({"src/common/include/parallel_macros.fpp"})
53+
54+
55+
def test_cmake_forces_all():
56+
assert is_always_run_all({"CMakeLists.txt"})
57+
assert is_always_run_all({"toolchain/cmake/foo.cmake"})
58+
59+
60+
def test_param_codegen_forces_all():
61+
assert is_always_run_all({"toolchain/mfc/params/definitions.py"})
62+
63+
64+
def test_ordinary_common_module_does_not_force_all():
65+
assert not is_always_run_all({"src/common/m_helper.fpp"})
66+
67+
68+
def test_ordinary_sim_module_does_not_force_all():
69+
assert not is_always_run_all({"src/simulation/m_rhs.fpp"})

0 commit comments

Comments
 (0)