@@ -54,6 +54,13 @@ def dump(self, out: str):
54
54
else :
55
55
result_xml .write (sys .stdout .buffer )
56
56
57
+ def is_failure (self ):
58
+ if (self .errors > 0 or self .failures > 0 ):
59
+ return True
60
+ else :
61
+ return False
62
+
63
+
57
64
# data needed for human readable output
58
65
class TestData :
59
66
total_assertions = 0
@@ -138,6 +145,11 @@ def dump(self, _):
138
145
print (f'\u001b [32;1mAll tests passed\u001b [39;0m ({ self .passed_assertions } assertions in { self .passed_test_cases } test cases)\n ' )
139
146
print (f'Execution time: { self .execution_time } s\n ' )
140
147
148
+ def is_failure (self ):
149
+ if (self .failed_assertions > 0 or self .failed_test_cases > 0 ):
150
+ return True
151
+ else :
152
+ return False
141
153
142
154
143
155
def run_tests (args , test_names : list [str ], binary_path : str , is_interactive : bool ):
@@ -217,8 +229,7 @@ def run_tests(args, test_names: list[str], binary_path: str, is_interactive: boo
217
229
execution_time = time_end - time_start
218
230
data .execution_time = execution_time
219
231
220
- out = args .out
221
- data .dump (out )
232
+ return data
222
233
223
234
224
235
if __name__ == '__main__' :
@@ -251,5 +262,11 @@ def run_tests(args, test_names: list[str], binary_path: str, is_interactive: boo
251
262
output = subprocess .run (list_tests_command , shell = True , stdout = subprocess .PIPE )
252
263
test_names = output .stdout .decode ().strip ().split ('\n ' )
253
264
254
- run_tests (args , test_names , args .binary_path , is_interactive )
265
+ data = run_tests (args , test_names , args .binary_path , is_interactive )
266
+
267
+ data .dump (args .out )
268
+ if data .is_failure ():
269
+ exit (1 )
270
+ else :
271
+ exit (0 )
255
272
0 commit comments