Skip to content

Commit 4bc191d

Browse files
authored
Merge branch 'master' into add-modular-precision-update
2 parents dec61ba + d1b8028 commit 4bc191d

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

toolchain/mfc/test/test.py

+32-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
nFAIL = 0
2020
nPASS = 0
2121
nSKIP = 0
22+
errors = []
2223

2324
# pylint: disable=too-many-branches, trailing-whitespace
2425
def __filter(cases_) -> typing.List[TestCase]:
2526
cases = cases_[:]
27+
selected_cases = []
28+
skipped_cases = []
2629

2730
# Check "--from" and "--to" exist and are in the right order
2831
bFoundFrom, bFoundTo = (False, False)
@@ -52,6 +55,7 @@ def __filter(cases_) -> typing.List[TestCase]:
5255
for case in cases[:]:
5356
if case.ppn > 1 and not ARG("mpi"):
5457
cases.remove(case)
58+
skipped_cases.append(case)
5559

5660
for case in cases[:]:
5761
if ARG("single"):
@@ -61,14 +65,17 @@ def __filter(cases_) -> typing.List[TestCase]:
6165

6266

6367
if ARG("percent") == 100:
64-
return cases
68+
return cases, skipped_cases
6569

66-
return sample(cases, k=int(len(cases)*ARG("percent")/100.0))
70+
selected_cases = sample(cases, k=int(len(cases)*ARG("percent")/100.0))
71+
skipped_cases = [item for item in cases if item not in selected_cases]
6772

73+
return selected_cases, skipped_cases
6874

6975
def test():
7076
# pylint: disable=global-statement, global-variable-not-assigned
7177
global nFAIL, nPASS, nSKIP
78+
global errors
7279

7380
cases = list_cases()
7481

@@ -83,7 +90,8 @@ def test():
8390

8491
return
8592

86-
cases = [ _.to_case() for _ in __filter(cases) ]
93+
cases, skipped_cases = __filter(cases)
94+
cases = [ _.to_case() for _ in cases ]
8795

8896
if ARG("list"):
8997
table = rich.table.Table(title="MFC Test Cases", box=rich.table.box.SIMPLE)
@@ -133,9 +141,23 @@ def test():
133141
[ sched.Task(ppn=case.ppn, func=handle_case, args=[case], load=case.get_cell_count()) for case in cases ],
134142
ARG("jobs"), ARG("gpus"))
135143

144+
nSKIP = len(skipped_cases)
136145
cons.print()
137146
cons.unindent()
138-
cons.print(f"\nTest Summary: [bold green]{nPASS}[/bold green] passed, [bold red]{nFAIL}[/bold red] failed, [bold yellow]{nSKIP}[/bold yellow] skipped.")
147+
cons.print(f"\nTest Summary: [bold green]{nPASS}[/bold green] passed, [bold red]{nFAIL}[/bold red] failed, [bold yellow]{nSKIP}[/bold yellow] skipped.\n")
148+
149+
# Print a summary of all errors at the end if errors exist
150+
if len(errors) != 0:
151+
cons.print(f"[bold red]Failed Cases[/bold red]\n")
152+
for e in errors:
153+
cons.print(e)
154+
155+
# Print the list of skipped cases
156+
if len(skipped_cases) != 0:
157+
cons.print("[bold yellow]Skipped Cases[/bold yellow]\n")
158+
for c in skipped_cases:
159+
cons.print(f"[bold yellow]{c.trace}[/bold yellow]")
160+
139161
exit(nFAIL)
140162

141163

@@ -223,6 +245,7 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
223245
def handle_case(case: TestCase, devices: typing.Set[int]):
224246
# pylint: disable=global-statement, global-variable-not-assigned
225247
global nFAIL, nPASS, nSKIP
248+
global errors
226249

227250
nAttempts = 0
228251
if ARG('single'):
@@ -237,10 +260,13 @@ def handle_case(case: TestCase, devices: typing.Set[int]):
237260
_handle_case(case, devices)
238261
nPASS += 1
239262
except Exception as exc:
240-
if nAttempts < max_attempts:
263+
if nAttempts < ARG("max_attempts"):
264+
cons.print(f"[bold yellow] Attempt {nAttempts}: Failed test {case.get_uuid()}. Retrying...[/bold yellow]")
265+
errors.append(f"[bold yellow] Attempt {nAttempts}: Failed test {case.get_uuid()}. Retrying...[/bold yellow]")
241266
continue
242267
nFAIL += 1
243268
cons.print(f"[bold red]Failed test {case} after {nAttempts} attempt(s).[/bold red]")
244-
cons.print(f"{exc}")
269+
errors.append(f"[bold red]Failed test {case} after {nAttempts} attempt(s).[/bold red]")
270+
errors.append(f"{exc}")
245271

246272
return

0 commit comments

Comments
 (0)