Skip to content

Commit d1b8028

Browse files
Print all test case error messages together at the end (#745)
Co-authored-by: Spencer Bryngelson <[email protected]>
1 parent a3d39df commit d1b8028

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

toolchain/mfc/test/test.py

+30-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
nFAIL = 0
2020
nPASS = 0
2121
nSKIP = 0
22+
errors = []
2223

2324
def __filter(cases_) -> typing.List[TestCase]:
2425
cases = cases_[:]
26+
selected_cases = []
27+
skipped_cases = []
2528

2629
# Check "--from" and "--to" exist and are in the right order
2730
bFoundFrom, bFoundTo = (False, False)
@@ -51,16 +54,20 @@ def __filter(cases_) -> typing.List[TestCase]:
5154
for case in cases[:]:
5255
if case.ppn > 1 and not ARG("mpi"):
5356
cases.remove(case)
57+
skipped_cases.append(case)
5458

5559
if ARG("percent") == 100:
56-
return cases
60+
return cases, skipped_cases
5761

58-
return sample(cases, k=int(len(cases)*ARG("percent")/100.0))
62+
selected_cases = sample(cases, k=int(len(cases)*ARG("percent")/100.0))
63+
skipped_cases = [item for item in cases if item not in selected_cases]
5964

65+
return selected_cases, skipped_cases
6066

6167
def test():
6268
# pylint: disable=global-statement, global-variable-not-assigned
6369
global nFAIL, nPASS, nSKIP
70+
global errors
6471

6572
cases = list_cases()
6673

@@ -75,7 +82,8 @@ def test():
7582

7683
return
7784

78-
cases = [ _.to_case() for _ in __filter(cases) ]
85+
cases, skipped_cases = __filter(cases)
86+
cases = [ _.to_case() for _ in cases ]
7987

8088
if ARG("list"):
8189
table = rich.table.Table(title="MFC Test Cases", box=rich.table.box.SIMPLE)
@@ -125,9 +133,23 @@ def test():
125133
[ sched.Task(ppn=case.ppn, func=handle_case, args=[case], load=case.get_cell_count()) for case in cases ],
126134
ARG("jobs"), ARG("gpus"))
127135

136+
nSKIP = len(skipped_cases)
128137
cons.print()
129138
cons.unindent()
130-
cons.print(f"\nTest Summary: [bold green]{nPASS}[/bold green] passed, [bold red]{nFAIL}[/bold red] failed, [bold yellow]{nSKIP}[/bold yellow] skipped.")
139+
cons.print(f"\nTest Summary: [bold green]{nPASS}[/bold green] passed, [bold red]{nFAIL}[/bold red] failed, [bold yellow]{nSKIP}[/bold yellow] skipped.\n")
140+
141+
# Print a summary of all errors at the end if errors exist
142+
if len(errors) != 0:
143+
cons.print(f"[bold red]Failed Cases[/bold red]\n")
144+
for e in errors:
145+
cons.print(e)
146+
147+
# Print the list of skipped cases
148+
if len(skipped_cases) != 0:
149+
cons.print("[bold yellow]Skipped Cases[/bold yellow]\n")
150+
for c in skipped_cases:
151+
cons.print(f"[bold yellow]{c.trace}[/bold yellow]")
152+
131153
exit(nFAIL)
132154

133155

@@ -216,6 +238,7 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
216238
def handle_case(case: TestCase, devices: typing.Set[int]):
217239
# pylint: disable=global-statement, global-variable-not-assigned
218240
global nFAIL, nPASS, nSKIP
241+
global errors
219242

220243
nAttempts = 0
221244

@@ -228,9 +251,11 @@ def handle_case(case: TestCase, devices: typing.Set[int]):
228251
except Exception as exc:
229252
if nAttempts < ARG("max_attempts"):
230253
cons.print(f"[bold yellow] Attempt {nAttempts}: Failed test {case.get_uuid()}. Retrying...[/bold yellow]")
254+
errors.append(f"[bold yellow] Attempt {nAttempts}: Failed test {case.get_uuid()}. Retrying...[/bold yellow]")
231255
continue
232256
nFAIL += 1
233257
cons.print(f"[bold red]Failed test {case} after {nAttempts} attempt(s).[/bold red]")
234-
cons.print(f"{exc}")
258+
errors.append(f"[bold red]Failed test {case} after {nAttempts} attempt(s).[/bold red]")
259+
errors.append(f"{exc}")
235260

236261
return

0 commit comments

Comments
 (0)