Skip to content

Commit f7a692f

Browse files
committed
fix(test): empty --changed-files is uncertainty (run all), not skip-all
1 parent 36b3c71 commit f7a692f

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

toolchain/mfc/test/coverage.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ def get_changed_files(root_dir, compare_branch="master", explicit: Optional[str]
144144
Otherwise use git merge-base, self-healing a shallow clone with a deepen+retry.
145145
"""
146146
if explicit is not None:
147-
return {f for f in explicit.replace(",", " ").split() if f.strip()}
147+
files = {f for f in explicit.replace(",", " ").split() if f.strip()}
148+
if files:
149+
return files
150+
# explicit was given but empty/whitespace -> ambiguous (a paths-filter/env failure vs
151+
# genuinely nothing). Per the soundness invariant, uncertainty must run, not skip:
152+
# fall through to git detection, ultimately None -> rung 1 (run all). Never return
153+
# an empty set here, which would be read as "nothing changed -> skip all".
148154
try:
149155
base = _merge_base(root_dir, compare_branch)
150156
if base is None:

toolchain/mfc/test/test_coverage_unit.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,15 @@ def test_sim_include_fpp_forces_all():
267267
# gcov can't reliably attribute #:include'd files; any src include change runs all.
268268
assert is_always_run_all({"src/simulation/include/inline_riemann.fpp"})
269269
assert is_always_run_all({"src/pre_process/include/2dHardcodedIC.fpp"})
270+
271+
272+
def test_empty_explicit_is_uncertainty_not_skipall():
273+
# An empty/whitespace --changed-files must NOT become an empty set (skip-all under
274+
# enforce). It falls through to git detection -> None when that fails -> run all.
275+
def fail_git(cmd, **kw):
276+
rc = 1 if (len(cmd) > 1 and cmd[1] == "merge-base") else 0
277+
return _types.SimpleNamespace(returncode=rc, stdout="", stderr="x")
278+
279+
with patch("subprocess.run", fail_git):
280+
assert get_changed_files("/r", "master", explicit="") is None
281+
assert get_changed_files("/r", "master", explicit=" , ") is None

0 commit comments

Comments
 (0)