50
50
else :
51
51
TAGS_DIR = "null"
52
52
53
- TIMEOUT = 90 * 60
53
+ RUN_TIMEOUT = 90 * 60
54
+ RETAG_TIMEOUT = 20 * 60
54
55
RUNNER = os .path .join (os .path .dirname (__file__ ), "run_cpython_test.py" )
55
56
LINE = "=" * 80
56
57
@@ -107,14 +108,16 @@ def test_tagged():
107
108
if os .environ .get ("ENABLE_THREADED_GRAALPYTEST" ) == "true" :
108
109
run_serialize_out (cmd )
109
110
else :
110
- rcode = run_with_timeout (cmd ).returncode
111
+ rcode = run_with_timeout (cmd , timeout = RUN_TIMEOUT ).returncode
111
112
if rcode :
112
113
raise subprocess .CalledProcessError (rcode , cmd )
113
114
print (working_test [0 ], "was finished." )
114
115
115
116
def run_serialize_out (cmd ):
116
- result = run_with_timeout (cmd , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
117
+ result = run_with_timeout (cmd , timeout = RUN_TIMEOUT , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
117
118
append_out = "-v" in sys .argv
119
+ if result .returncode == 124 :
120
+ raise subprocess .TimeoutExpired (cmd = cmd , timeout = RUN_TIMEOUT )
118
121
if result .returncode :
119
122
message = f"{ working_test [0 ]} failed with exit code { result .returncode } .\n "
120
123
append_out = True
@@ -196,14 +199,14 @@ def parse_unittest_output(output):
196
199
return
197
200
198
201
199
- def run_with_timeout (cmd , * args , ** kwargs ):
202
+ def run_with_timeout (cmd , * , timeout , ** kwargs ):
200
203
p = subprocess .getstatusoutput ("which timeout" if sys .platform != 'darwin' else "which gtimeout" )
201
204
if p [0 ] != 0 :
202
205
print ("Cannot find the 'timeout' GNU tool. Do you have coreutils installed?" )
203
206
else :
204
- timeout = p [1 ].strip ()
205
- cmd = [timeout , "-s " , "9 " , str (TIMEOUT )] + cmd
206
- return subprocess .run (cmd , * args , * *kwargs )
207
+ timeout_cmd = p [1 ].strip ()
208
+ cmd = [timeout_cmd , "-k " , "10 " , str (timeout )] + cmd
209
+ return subprocess .run (cmd , ** kwargs )
207
210
208
211
209
212
def main ():
@@ -213,21 +216,23 @@ def main():
213
216
glob_pattern = os .path .join (os .path .dirname (test .__file__ ), "test_*.py" )
214
217
retag = False
215
218
maxrepeats = 4
219
+ timeout = None
216
220
for arg in sys .argv [1 :]:
217
221
if arg == "--retag" :
218
222
retag = True
219
223
elif arg .startswith ("--maxrepeats=" ):
220
224
maxrepeats = int (arg .partition ("=" )[2 ])
221
225
elif arg .startswith ("--timeout=" ):
222
- global TIMEOUT
223
- TIMEOUT = arg .partition ("=" )[2 ]
226
+ timeout = int (arg .partition ("=" )[2 ])
224
227
elif arg == "--help" :
225
228
print (sys .argv [0 ] + " [--retag] [--maxrepeats=n] [glob]" )
226
229
else :
227
230
if not (arg .endswith (".py" ) or arg .endswith ("*" )):
228
231
arg += ".py"
229
232
glob_pattern = os .path .join (os .path .dirname (test .__file__ ), arg )
230
233
234
+ if not timeout :
235
+ timeout = RETAG_TIMEOUT if retag else RUN_TIMEOUT
231
236
testfiles = glob .glob (glob_pattern )
232
237
testfiles += glob .glob (glob_pattern .replace (".py" , "/__init__.py" ))
233
238
@@ -268,15 +273,15 @@ def main():
268
273
cmd .append (testfile )
269
274
270
275
print (shlex .join (cmd ))
271
- p = run_with_timeout (cmd , errors = 'backslashreplace' , ** kwargs )
276
+ p = run_with_timeout (cmd , timeout = timeout , errors = 'backslashreplace' , ** kwargs )
272
277
print ("*stdout*" )
273
278
print (p .stdout )
274
279
print ("*stderr*" )
275
280
print (p .stderr )
276
281
277
- if p .returncode == - 9 :
282
+ if p .returncode == 124 :
278
283
print (
279
- f"\n Timeout (return code -9) \n you can try to increase the current timeout { TIMEOUT } s by using --timeout=NNN" )
284
+ f"\n Timed out \n You can try to increase the current timeout { timeout } s by using --timeout=NNN" )
280
285
281
286
passing_tests = set ()
282
287
failing_tests = set ()
0 commit comments