Skip to content

Commit 0a073b8

Browse files
ci: a script the pr set leaves out is reported unaffected, and R5 accepts it for that run
With main's coverage map in place the pull request's Linux shards ran only the scripts the change affects; the coverage check read every other script as uncovered and the host requirement of 1033 as unmet. run_all.sh now reports the left-out scripts as unaffected, the check counts them for that run and host, and a shard the set gives no script is not mtest's failure. Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent bdacf39 commit 0a073b8

6 files changed

Lines changed: 85 additions & 19 deletions

File tree

‎.github/tools/check_e2e_coverage.py‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
under tests/e2e:
1919
2020
ran some report says pass, fail or timeout;
21+
unaffected no report ran it, and a run narrowed to a set (`E2E_SET`, the
22+
`pr` set of a pull request) says the change does not affect it:
23+
the full runs of main are its coverage, and this run's claim is
24+
about the tests the change reaches;
2125
job no report ran it, but a workflow names it outside a comment, as a
2226
whole token: by file name, by name without `.sh`, or by its number
2327
as an `E2E_ONLY` pattern such as `239_*.sh`. A dedicated job runs it
@@ -34,7 +38,8 @@
3438
calls a target row `verified` when CI builds and runs its artefact, and the
3539
`*-openkal` rows claim that for every system. tests/e2e/host-requirements.tsv
3640
lists such a test with the hosts its result must come from; a listed test that
37-
did not pass on one of them, or that does not exist, fails the check.
41+
did not pass on one of them, or that does not exist, fails the check; one a
42+
set left out on that host as unaffected meets it for that run.
3843
3944
With --timings-out DIR it writes `<host>.tsv`, the measured duration of every
4045
test that ran, merged across that host's shards, in the format run_all.sh reads
@@ -133,6 +138,7 @@ def main() -> int:
133138
ran: dict[str, set[str]] = defaultdict(set)
134139
passed: dict[str, set[str]] = defaultdict(set)
135140
skipped: dict[str, set[str]] = defaultdict(set)
141+
unaffected: dict[str, set[str]] = defaultdict(set)
136142
shard_ms: dict[tuple[str, int], int] = defaultdict(int)
137143
timings: dict[str, dict[str, int]] = defaultdict(dict)
138144
reports = 0
@@ -146,6 +152,8 @@ def main() -> int:
146152
timings[host][test] = ms
147153
elif status == "skip":
148154
skipped[test].add(f"{host}: {detail}")
155+
elif status == "unaffected":
156+
unaffected[test].add(host)
149157
if reports == 0:
150158
print(f"no report under {args.reports}: nothing can be said about coverage")
151159
return 1
@@ -157,6 +165,8 @@ def main() -> int:
157165
counts["ran"] += 1
158166
if test in exceptions:
159167
stale.append(f"{test} is excused but ran on {', '.join(sorted(ran[test]))}")
168+
elif test in unaffected:
169+
counts["unaffected"] += 1
160170
elif named_by_a_workflow(test, workflows):
161171
counts["job"] += 1
162172
elif test in exceptions:
@@ -171,13 +181,14 @@ def main() -> int:
171181
if test not in tests:
172182
stale.append(f"{test} is required on hosts but does not exist")
173183
continue
174-
for host in sorted(hosts - passed[test]):
184+
for host in sorted(hosts - passed[test] - unaffected[test]):
175185
why = [d for d in skipped[test] if d.startswith(f"{host}: ")]
176186
unmet.append(f"{test} did not pass on {host}"
177187
f"{' (' + '; '.join(why) + ')' if why else (' (it ran and did not pass)' if host in ran[test] else ' (no report of it there)')}")
178188

179-
print(f"{len(tests)} tests: {counts['ran']} ran on a shard, {counts['job']} run by a "
180-
f"dedicated job, {counts['excused']} excused, {len(uncovered)} uncovered")
189+
print(f"{len(tests)} tests: {counts['ran']} ran on a shard, {counts['unaffected']} unaffected by "
190+
f"the change, {counts['job']} run by a dedicated job, {counts['excused']} excused, "
191+
f"{len(uncovered)} uncovered")
181192
for (host, shard), ms in sorted(shard_ms.items()):
182193
print(f" {host} shard {shard}: {ms / 60000:.1f} min of tests")
183194
for line in uncovered:

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@
110110
naming both; the two programs were a file and a directory of one path.
111111
- The repository's stray empty `.edited` is removed; e2e 859 fails naming the
112112
missing record rather than writing one in the working directory.
113+
- CI: a pull request's e2e shards report the scripts the `pr` set leaves out as
114+
`unaffected`, and the check that every script runs somewhere accepts them
115+
for that run; with main's coverage map in place, it had read them as
116+
uncovered. A shard the set gives no script is not a failure of mtest.
117+
- e2e 298 picks a row whose compiler on this host is its convention's: a macOS
118+
host serves `aarch64-linux-musl` through openkal-platform, whose compiler is
119+
llvm, and there llvm alone overrides nothing.
113120

114121
## [2026.11.8.1] - 2026-11-08
115122

‎docs/90-build-from-source.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ runs beside it; a script that changes the shared home's configuration says so).
126126
divides by the measured history of the store (`tests/e2e/.mtest`, which CI takes
127127
from main's last run), `E2E_JOBS` runs that many scripts at once, and
128128
`E2E_SET=pr` runs the scripts a change affects by the nightly coverage map
129-
(`.github/workflows/e2e-coverage.yml`). `mtest explain` in `tests/e2e` says where
129+
(`.github/workflows/e2e-coverage.yml`); a script the set leaves out is reported
130+
`unaffected`, which the check that every script runs somewhere (rule R5) accepts
131+
for that run, main's full runs being its coverage. `mtest explain` in `tests/e2e` says where
130132
a script failed and how to run it again.
131133

132134
## Writing a check that measures something

‎docs/zh/90-build-from-source.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ MCPP=<fresh-mcpp-binary> bash tests/e2e/02_new_build_run.sh
122122
行是它运行时占有的资源(`machine`:没有别的脚本与它并行;改动共享 home 配置的脚本这样声明)。
123123
`run_all.sh` 在 `E2E_MTEST=<mtest>` 下经由它运行整套:`E2E_SHARD` 按存储(`tests/e2e/.mtest`,
124124
CI 取自 main 的上一次运行)中测得的历史划分,`E2E_JOBS` 同时运行多少个脚本,`E2E_SET=pr`
125-
按夜间的覆盖映射(`.github/workflows/e2e-coverage.yml`)运行变更影响的脚本。在 `tests/e2e`
125+
按夜间的覆盖映射(`.github/workflows/e2e-coverage.yml`)运行变更影响的脚本;集合留下的脚本报告为
126+
`unaffected`,「每个脚本都在某处运行」的检查(规则 R5)对该次运行接受它,其覆盖由 main 的完整运行承担。在 `tests/e2e`
126127
中执行 `mtest explain` 可得知脚本在哪里失败以及如何再次运行。
127128

128129
## 写一条真的在测东西的判据

‎tests/e2e/run_all.sh‎

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,25 +499,34 @@ fi
499499
# the smoke and regression sets; a test the map does not know is affected).
500500
# E2E_ONLY and E2E_EXCLUDE select as below. Each result is reported as the
501501
# serial run reports it.
502+
# The selection common to a run and its listings, in MTEST_SELECTION: this
503+
# machine's capabilities, E2E_ONLY and E2E_EXCLUDE.
504+
MTEST_SELECTION=()
505+
for cap in "${KNOWN_CAPS[@]}"; do
506+
[[ " ${CAPS[*]} " == *" $cap "* ]] || MTEST_SELECTION+=(--exclude-tag "requires:$cap")
507+
done
508+
[[ -n "${E2E_ONLY:-}" ]] && MTEST_SELECTION+=(--program "$E2E_ONLY")
509+
[[ -n "${E2E_EXCLUDE:-}" ]] && MTEST_SELECTION+=(--exclude-program "$E2E_EXCLUDE")
502510
run_by_mtest() {
503-
local args=(run --jobs "${E2E_JOBS:-1}" --timeout "${E2E_TEST_TIMEOUT}s" --report-json "$1")
504-
local cap
505-
for cap in "${KNOWN_CAPS[@]}"; do
506-
[[ " ${CAPS[*]} " == *" $cap "* ]] || args+=(--exclude-tag "requires:$cap")
507-
done
511+
local args=(run --jobs "${E2E_JOBS:-1}" --timeout "${E2E_TEST_TIMEOUT}s" --report-json "$1"
512+
${MTEST_SELECTION[@]+"${MTEST_SELECTION[@]}"})
508513
(( SHARD_TOTAL > 1 )) && args+=(--shard "$SHARD_IDX/$SHARD_TOTAL")
509514
[[ -n "${E2E_SET:-}" ]] && args+=(--set "$E2E_SET")
510515
# E2E_COVERAGE: the run measures the coverage map ([coverage] of mtest.toml).
511516
[[ -n "${E2E_COVERAGE:-}" ]] && args+=(--coverage)
512-
[[ -n "${E2E_ONLY:-}" ]] && args+=(--program "$E2E_ONLY")
513-
[[ -n "${E2E_EXCLUDE:-}" ]] && args+=(--exclude-program "$E2E_EXCLUDE")
514517
(cd "$HERE" && MCPP="$MCPP" "$E2E_MTEST" "${args[@]}")
515518
}
519+
# The programs of a listing, one per line; the arguments narrow it.
520+
mtest_programs() {
521+
(cd "$HERE" && MCPP="$MCPP" "$E2E_MTEST" list --json ${MTEST_SELECTION[@]+"${MTEST_SELECTION[@]}"} "$@") \
522+
| "$py" -c 'import json, sys
523+
for u in json.load(sys.stdin).get("units", []): print(u["program"])' | tr -d '\r'
524+
}
516525
if [[ -n "${E2E_MTEST:-}" ]]; then
526+
py=python3; command -v python3 >/dev/null 2>&1 || py=python
517527
record="$(mktemp)"
518528
run_by_mtest "$record" || true
519529
# One `<status> <ms> <name>` line per case of the run's record.
520-
py=python3; command -v python3 >/dev/null 2>&1 || py=python
521530
results="$("$py" - "$record" <<'PY'
522531
import json, sys
523532
try:
@@ -541,9 +550,28 @@ PY
541550
*) ((FAIL++)); FAILED_TESTS+=("$name"); report fail "$name" "$ms" "failed" ;;
542551
esac
543552
done <<<"$results"
553+
# A SET LEAVES OUT WHAT THE CHANGE DOES NOT AFFECT, AND THE REPORT SAYS SO.
554+
# The coverage check (rule R5) reads a test no report ran as uncovered; one
555+
# the set left out is `unaffected`: the full runs of main cover it. Every
556+
# shard lists the same programs, the shard being the set's own division.
557+
if [[ -n "${E2E_SET:-}" && -n "${E2E_REPORT:-}" ]]; then
558+
inSet=" $(mtest_programs --set "$E2E_SET" | tr '\n' ' ') "
559+
while read -r name; do
560+
[[ -n "$name" && "$inSet" != *" $name "* ]] || continue
561+
report unaffected "$name" 0 "not in the set '$E2E_SET'"
562+
done < <(mtest_programs)
563+
fi
564+
# A run the set gave nothing ran nothing; any other empty run is mtest's
565+
# failure.
544566
if [[ $((PASS + FAIL)) -eq 0 ]]; then
545-
echo "FATAL: mtest reported no case (E2E_MTEST=$E2E_MTEST)"
546-
exit 1
567+
part=(); (( SHARD_TOTAL > 1 )) && part=(--shard "$SHARD_IDX/$SHARD_TOTAL")
568+
if [[ -n "${E2E_SET:-}" ]] \
569+
&& [[ -z "$(mtest_programs --set "$E2E_SET" ${part[@]+"${part[@]}"})" ]]; then
570+
echo "The set '$E2E_SET' gives this run no test."
571+
else
572+
echo "FATAL: mtest reported no case (E2E_MTEST=$E2E_MTEST)"
573+
exit 1
574+
fi
547575
fi
548576
fi
549577

‎tests/scripts/test_check_e2e_coverage.py‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22
"""Fixture tests for .github/tools/check_e2e_coverage.py (rule R5).
33
4-
A test that ran, a test a workflow names, and a test the exceptions excuse are
5-
covered; a test that is none of these fails the check, and so does an exception
4+
A test that ran, a test a set left out as unaffected, a test a workflow names,
5+
and a test the exceptions excuse are covered; a test that is none of these fails the check, and so does an exception
66
for a test that ran or that does not exist.
77
"""
88

@@ -46,7 +46,7 @@ def run_check(self, *extra: str) -> subprocess.CompletedProcess:
4646
def test_ran_named_and_excused_tests_are_covered(self) -> None:
4747
r = self.run_check()
4848
self.assertEqual(r.returncode, 0, r.stdout)
49-
self.assertIn("1 ran on a shard, 2 run by a dedicated job, 1 excused, 0 uncovered", r.stdout)
49+
self.assertIn("1 ran on a shard, 0 unaffected by the change, 2 run by a dedicated job, 1 excused, 0 uncovered", r.stdout)
5050

5151
def test_a_name_in_a_comment_or_inside_a_longer_name_does_not_count(self) -> None:
5252
e2e = self.root / "tests" / "e2e"
@@ -71,6 +71,23 @@ def test_a_test_that_runs_nowhere_fails(self) -> None:
7171
self.assertEqual(r.returncode, 1)
7272
self.assertIn("UNCOVERED: 50_nowhere.sh: linux: missing capability: llvm", r.stdout)
7373

74+
def test_a_test_a_set_left_out_is_unaffected_and_meets_its_host(self) -> None:
75+
e2e = self.root / "tests" / "e2e"
76+
(e2e / "50_untouched.sh").write_text("# x\n# requires: unix-shell\n")
77+
(e2e / "host-requirements.tsv").write_text("50_untouched.sh\tlinux\tverified rows\n")
78+
(self.reports / "e2e-report-linux-2.tsv").write_text(
79+
"unaffected\t50_untouched.sh\t0\tnot in the set 'pr'\n")
80+
r = self.run_check()
81+
self.assertEqual(r.returncode, 0, r.stdout)
82+
self.assertIn("1 unaffected by the change", r.stdout)
83+
# Another host's unaffected report does not meet a requirement of linux.
84+
(self.reports / "e2e-report-linux-2.tsv").unlink()
85+
(self.reports / "e2e-report-macos-1.tsv").write_text(
86+
"unaffected\t50_untouched.sh\t0\tnot in the set 'pr'\n")
87+
r = self.run_check()
88+
self.assertEqual(r.returncode, 1)
89+
self.assertIn("REQUIRED ON HOST: 50_untouched.sh did not pass on linux", r.stdout)
90+
7491
def test_an_exception_for_a_test_that_ran_fails(self) -> None:
7592
(self.reports / "e2e-report-macos-1.tsv").write_text("pass\t30_excused.sh\t10\t\n")
7693
r = self.run_check()

0 commit comments

Comments
 (0)