Skip to content

Commit 49b4fa1

Browse files
ArmavicaricardoV94
authored andcommitted
Fix python script to check test coverage
1 parent 4cac135 commit 49b4fa1

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

scripts/check_all_tests_are_covered.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def find_testfiles():
3030

3131

3232
def from_yaml():
33-
"""Determins how often each test file is run per platform and floatX setting.
33+
"""Determines how often each test file is run per platform and floatX setting.
3434
3535
An exception is raised if tests run multiple times with the same configuration.
3636
"""
3737
# First collect the matrix definitions from testing workflows
3838
matrices = {}
3939
for wf in ["tests.yml"]:
40-
wfname = wf.strip(".yml")
40+
wfname = wf.rstrip(".yml")
4141
wfdef = yaml.safe_load(open(Path(".github", "workflows", wf)))
4242
for jobname, jobdef in wfdef["jobs"].items():
4343
matrix = jobdef.get("strategy", {}).get("matrix", {})
@@ -74,22 +74,21 @@ def from_yaml():
7474
# Windows jobs need \ in line breaks within the test-subset!
7575
# The following checks that these trailing \ are present in
7676
# all items except the last.
77-
nlines = len(lines)
78-
for l, line in enumerate(lines):
79-
if l < nlines - 1 and not line.endswith(" \\"):
77+
if lines and lines[-1].endswith(" \\"):
78+
raise Exception(
79+
f"Last entry '{line}' in Windows test subset should end WITHOUT ' \\'."
80+
)
81+
for line in lines[:-1]:
82+
if not line.endswith(" \\"):
8083
raise Exception(f"Missing ' \\' after '{line}' in Windows test-subset.")
81-
elif l == nlines - 1 and line.endswith(" \\"):
82-
raise Exception(
83-
f"Last entry '{line}' in Windows test subset should end WITHOUT ' \\'."
84-
)
85-
testfiles[l] = line.strip(" \\")
84+
lines = [line.rstrip(" \\") for line in lines]
8685

8786
# Unpack lines with >1 item
8887
testfiles = []
8988
for line in lines:
9089
testfiles += line.split(" ")
9190

92-
ignored = {item.strip("--ignore=") for item in testfiles if item.startswith("--ignore")}
91+
ignored = {item[8:].lstrip(" =") for item in testfiles if item.startswith("--ignore")}
9392
included = {item for item in testfiles if item and not item.startswith("--ignore")}
9493

9594
if ignored and not included:

0 commit comments

Comments
 (0)