Skip to content

Commit 7da2ba7

Browse files
michaelosthegebrandonwillard
authored andcommitted
Allow ignoring tests files, but print a warning about it
1 parent bfa70ba commit 7da2ba7

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

scripts/check_all_tests_are_covered.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
This is intended to be used as a pre-commit hook, see `.pre-commit-config.yaml`.
77
You can run it manually with `pre-commit run check-no-tests-are-ignored --all`.
88
"""
9-
9+
import logging
1010
import re
1111

1212
from pathlib import Path
1313

14+
_log = logging.getLogger(__file__)
15+
16+
1417
if __name__ == "__main__":
1518
testing_workflows = ["jaxtests.yml", "pytest.yml"]
1619
ignored = set()
@@ -20,9 +23,21 @@
2023
txt = pytest_ci_job.read_text()
2124
ignored = set(re.findall(r"(?<=--ignore=)(pymc3/tests.*\.py)", txt))
2225
non_ignored = non_ignored.union(set(re.findall(r"(?<!--ignore=)(pymc3/tests.*\.py)", txt)))
23-
assert (
24-
ignored <= non_ignored
25-
), f"The following tests are ignored by the first job but not run by the others: {ignored.difference(non_ignored)}"
26-
assert (
27-
ignored >= non_ignored
28-
), f"The following tests are run by multiple jobs: {non_ignored.difference(ignored)}"
26+
# Summarize
27+
ignored_by_all = ignored.difference(non_ignored)
28+
run_multiple_times = non_ignored.difference(ignored)
29+
30+
if ignored_by_all:
31+
_log.warning(
32+
f"The following {len(ignored_by_all)} tests are completely ignored: {ignored_by_all}"
33+
)
34+
if run_multiple_times:
35+
_log.warning(
36+
f"The following {len(run_multiple_times)} tests are run multiple times: {run_multiple_times}"
37+
)
38+
if not (ignored_by_all or run_multiple_times):
39+
print(f"✔ All tests will run exactly once.")
40+
41+
# Temporarily disabled as we're bringing features back for v4:
42+
# assert not ignored_by_all
43+
assert not run_multiple_times

0 commit comments

Comments
 (0)