19
19
nFAIL = 0
20
20
nPASS = 0
21
21
nSKIP = 0
22
+ errors = []
22
23
23
24
# pylint: disable=too-many-branches, trailing-whitespace
24
25
def __filter (cases_ ) -> typing .List [TestCase ]:
25
26
cases = cases_ [:]
27
+ selected_cases = []
28
+ skipped_cases = []
26
29
27
30
# Check "--from" and "--to" exist and are in the right order
28
31
bFoundFrom , bFoundTo = (False , False )
@@ -52,6 +55,7 @@ def __filter(cases_) -> typing.List[TestCase]:
52
55
for case in cases [:]:
53
56
if case .ppn > 1 and not ARG ("mpi" ):
54
57
cases .remove (case )
58
+ skipped_cases .append (case )
55
59
56
60
for case in cases [:]:
57
61
if ARG ("single" ):
@@ -61,14 +65,17 @@ def __filter(cases_) -> typing.List[TestCase]:
61
65
62
66
63
67
if ARG ("percent" ) == 100 :
64
- return cases
68
+ return cases , skipped_cases
65
69
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 ]
67
72
73
+ return selected_cases , skipped_cases
68
74
69
75
def test ():
70
76
# pylint: disable=global-statement, global-variable-not-assigned
71
77
global nFAIL , nPASS , nSKIP
78
+ global errors
72
79
73
80
cases = list_cases ()
74
81
@@ -83,7 +90,8 @@ def test():
83
90
84
91
return
85
92
86
- cases = [ _ .to_case () for _ in __filter (cases ) ]
93
+ cases , skipped_cases = __filter (cases )
94
+ cases = [ _ .to_case () for _ in cases ]
87
95
88
96
if ARG ("list" ):
89
97
table = rich .table .Table (title = "MFC Test Cases" , box = rich .table .box .SIMPLE )
@@ -133,9 +141,23 @@ def test():
133
141
[ sched .Task (ppn = case .ppn , func = handle_case , args = [case ], load = case .get_cell_count ()) for case in cases ],
134
142
ARG ("jobs" ), ARG ("gpus" ))
135
143
144
+ nSKIP = len (skipped_cases )
136
145
cons .print ()
137
146
cons .unindent ()
138
- cons .print (f"\n Test Summary: [bold green]{ nPASS } [/bold green] passed, [bold red]{ nFAIL } [/bold red] failed, [bold yellow]{ nSKIP } [/bold yellow] skipped." )
147
+ cons .print (f"\n Test 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
+
139
161
exit (nFAIL )
140
162
141
163
@@ -223,6 +245,7 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
223
245
def handle_case (case : TestCase , devices : typing .Set [int ]):
224
246
# pylint: disable=global-statement, global-variable-not-assigned
225
247
global nFAIL , nPASS , nSKIP
248
+ global errors
226
249
227
250
nAttempts = 0
228
251
if ARG ('single' ):
@@ -237,10 +260,13 @@ def handle_case(case: TestCase, devices: typing.Set[int]):
237
260
_handle_case (case , devices )
238
261
nPASS += 1
239
262
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]" )
241
266
continue
242
267
nFAIL += 1
243
268
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 } " )
245
271
246
272
return
0 commit comments