@@ -100,17 +100,22 @@ def run_test(notebook_path, root, timeout=7200):
100
100
return 0
101
101
102
102
main_command = [sys .executable , '-m' , 'treon' , notebook_name ]
103
- retcode = subprocess .run (main_command , shell = (platform .system () == "Windows" ), timeout = timeout ).returncode
103
+ try :
104
+ retcode = subprocess .run (main_command , shell = (platform .system () == "Windows" ), timeout = timeout ).returncode
105
+ except subprocess .TimeoutExpired :
106
+ retcode = - 42
104
107
105
108
clean_test_artifacts (existing_files , sorted (Path ('.' ).iterdir ()))
106
109
return retcode
107
110
108
111
109
- def finalize_status (failed_notebooks , test_plan , report_dir , root ):
112
+ def finalize_status (failed_notebooks , timeout_notebooks , test_plan , report_dir , root ):
110
113
return_status = 0
111
114
if failed_notebooks :
112
115
return_status = 1
113
116
print ("FAILED: \n {}" .format ('\n ' .join (failed_notebooks )))
117
+ if timeout_notebooks :
118
+ print ("FAILED BY TIMEOUT: \n {}" .format ('\n ' .join (timeout_notebooks )))
114
119
test_report = []
115
120
for notebook , status in test_plan .items ():
116
121
test_status = status ['status' ] or 'NOT_RUN'
@@ -138,6 +143,7 @@ def __exit__(self, etype, value, traceback):
138
143
139
144
def main ():
140
145
failed_notebooks = []
146
+ timeout_notebooks = []
141
147
args = parse_arguments ()
142
148
reports_dir = Path (args .report_dir )
143
149
reports_dir .mkdir (exist_ok = True , parents = True )
@@ -153,12 +159,18 @@ def main():
153
159
if report ['status' ] == "SKIPPED" :
154
160
continue
155
161
status = run_test (report ['path' ], root , args .timeout )
156
- report ['status' ] = 'SUCCESS' if not status else "FAILED"
157
162
if status :
158
- failed_notebooks .append (str (notebook ))
163
+ report ['status' ] = "TIMEOUT" if status == - 42 else "FAILED"
164
+ else :
165
+ report ["status" ] = 'SUCCESS'
166
+ if status :
167
+ if status == - 42 :
168
+ timeout_notebooks .append (str (notebook ))
169
+ else :
170
+ failed_notebooks .append (str (notebook ))
159
171
if args .early_stop :
160
172
break
161
- exit_status = finalize_status (failed_notebooks , test_plan , reports_dir , root )
173
+ exit_status = finalize_status (failed_notebooks , timeout_notebooks , test_plan , reports_dir , root )
162
174
return exit_status
163
175
164
176
0 commit comments