Skip to content

Commit 965b192

Browse files
committed
runtest: show test results in timed out case.
A timed out test means that the tests can't proceed (REPL likely hung). However, we still want to get a test summary for that case. When a timeout happens, instead of throw an exception and immediately existing, the test file continues to be read but no more tests are executed (similar to if a regular test failure happens without --continue-on-fail).
1 parent 9eb7bea commit 965b192

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

runtest.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def elide(s, max = 79):
284284
fail_cnt = 0
285285
soft_fail_cnt = 0
286286
failures = []
287+
fail_type = ""
287288

288289
class TestTimeout(Exception):
289290
pass
@@ -306,6 +307,8 @@ class TestTimeout(Exception):
306307
if t.form == None: continue
307308

308309
total_test_cnt += 1
310+
if fail_type == "TIMED OUT":
311+
continue # repl is stuck
309312
if not args.continue_after_fail:
310313
if fail_cnt > 0:
311314
continue
@@ -326,38 +329,39 @@ class TestTimeout(Exception):
326329
res = r.read_to_prompt(['\r\n[^\\s()<>]+> ', '\n[^\\s()<>]+> '],
327330
timeout=args.test_timeout)
328331
#print "%s,%s,%s" % (idx, repr(p.before), repr(p.after))
329-
if (res == None):
330-
if verbose == 0: log(test_msg, end='')
331-
log(" -> TIMEOUT")
332-
raise TestTimeout("TIMEOUT (line %d)" % t.line_num)
333-
elif (t.ret == "" and t.out == ""):
332+
if (t.ret == "" and t.out == ""):
334333
vlog(" -> SUCCESS (result ignored)")
335334
pass_cnt += 1
336-
elif (re.search(expects[0], res, re.S) or
335+
elif res and (re.search(expects[0], res, re.S) or
337336
re.search(expects[1], res, re.S)):
338337
vlog(" -> SUCCESS")
339338
pass_cnt += 1
340339
else:
341-
if t.soft and not args.hard:
340+
if (res == None):
341+
if verbose == 0: log(test_msg, end='')
342+
log(" -> TIMED OUT")
343+
fail_cnt += 1
344+
fail_type = "TIMED OUT"
345+
elif t.soft and not args.hard:
342346
vlog(" -> SOFT FAIL:")
343347
soft_fail_cnt += 1
344-
fail_type = "SOFT "
348+
fail_type = "SOFT FAILED"
345349
else:
346350
vlog(" -> FAIL:")
347351
fail_cnt += 1
348-
fail_type = ""
352+
fail_type = "FAILED"
349353
expected = " Expected : %s" % repr(expects[0])
350-
got = " Got : %s" % repr(res)
354+
got = " Got : %s" % repr(res or "")
351355
vvlog(expected)
352356
vlog(got if verbose >= 2 else elide(got))
353-
failed_test = "%sFAILED %s:\n%s\n%s" % (
357+
failed_test = "%s %s:\n%s\n%s" % (
354358
fail_type, test_msg, expected, got)
355359
failures.append(failed_test)
356360
except:
357361
_, exc, _ = sys.exc_info()
358362
log("\nException: %s" % repr(exc))
359363
log("Output before exception:\n%s" % r.buf)
360-
sys.exit(1)
364+
break
361365

362366
if len(failures) > 0:
363367
log("\nFAILURES:")

0 commit comments

Comments
 (0)