Issue #25220: Use print(flush=True) in libregrtest
This commit is contained in:
parent
76f756d934
commit
f33536c430
|
@ -157,8 +157,8 @@ class Regrtest:
|
||||||
return
|
return
|
||||||
fmt = "[{1:{0}}{2}/{3}] {4}" if self.bad else "[{1:{0}}{2}] {4}"
|
fmt = "[{1:{0}}{2}/{3}] {4}" if self.bad else "[{1:{0}}{2}] {4}"
|
||||||
print(fmt.format(self.test_count_width, test_index,
|
print(fmt.format(self.test_count_width, test_index,
|
||||||
self.test_count, len(self.bad), test))
|
self.test_count, len(self.bad), test),
|
||||||
sys.stdout.flush()
|
flush=True)
|
||||||
|
|
||||||
def setup_regrtest(self):
|
def setup_regrtest(self):
|
||||||
if self.ns.huntrleaks:
|
if self.ns.huntrleaks:
|
||||||
|
@ -333,8 +333,7 @@ class Regrtest:
|
||||||
if self.ns.verbose2 and self.bad:
|
if self.ns.verbose2 and self.bad:
|
||||||
print("Re-running failed tests in verbose mode")
|
print("Re-running failed tests in verbose mode")
|
||||||
for test in self.bad[:]:
|
for test in self.bad[:]:
|
||||||
print("Re-running test %r in verbose mode" % test)
|
print("Re-running test %r in verbose mode" % test, flush=True)
|
||||||
sys.stdout.flush()
|
|
||||||
try:
|
try:
|
||||||
self.ns.verbose = True
|
self.ns.verbose = True
|
||||||
ok = runtest(test, True, self.ns.quiet, self.ns.huntrleaks,
|
ok = runtest(test, True, self.ns.quiet, self.ns.huntrleaks,
|
||||||
|
|
|
@ -44,13 +44,12 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
|
||||||
alloc_deltas = [0] * repcount
|
alloc_deltas = [0] * repcount
|
||||||
|
|
||||||
print("beginning", repcount, "repetitions", file=sys.stderr)
|
print("beginning", repcount, "repetitions", file=sys.stderr)
|
||||||
print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr)
|
print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr,
|
||||||
sys.stderr.flush()
|
flush=True)
|
||||||
for i in range(repcount):
|
for i in range(repcount):
|
||||||
indirect_test()
|
indirect_test()
|
||||||
alloc_after, rc_after = dash_R_cleanup(fs, ps, pic, zdc, abcs)
|
alloc_after, rc_after = dash_R_cleanup(fs, ps, pic, zdc, abcs)
|
||||||
sys.stderr.write('.')
|
print('.', end='', flush=True)
|
||||||
sys.stderr.flush()
|
|
||||||
if i >= nwarmup:
|
if i >= nwarmup:
|
||||||
rc_deltas[i] = rc_after - rc_before
|
rc_deltas[i] = rc_after - rc_before
|
||||||
alloc_deltas[i] = alloc_after - alloc_before
|
alloc_deltas[i] = alloc_after - alloc_before
|
||||||
|
@ -74,8 +73,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
|
||||||
if checker(deltas):
|
if checker(deltas):
|
||||||
msg = '%s leaked %s %s, sum=%s' % (
|
msg = '%s leaked %s %s, sum=%s' % (
|
||||||
test, deltas[nwarmup:], item_name, sum(deltas))
|
test, deltas[nwarmup:], item_name, sum(deltas))
|
||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr, flush=True)
|
||||||
sys.stderr.flush()
|
|
||||||
with open(fname, "a") as refrep:
|
with open(fname, "a") as refrep:
|
||||||
print(msg, file=refrep)
|
print(msg, file=refrep)
|
||||||
refrep.flush()
|
refrep.flush()
|
||||||
|
|
|
@ -161,27 +161,23 @@ def runtest_inner(test, verbose, quiet,
|
||||||
test_time = time.time() - start_time
|
test_time = time.time() - start_time
|
||||||
except support.ResourceDenied as msg:
|
except support.ResourceDenied as msg:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(test, "skipped --", msg)
|
print(test, "skipped --", msg, flush=True)
|
||||||
sys.stdout.flush()
|
|
||||||
return RESOURCE_DENIED, test_time
|
return RESOURCE_DENIED, test_time
|
||||||
except unittest.SkipTest as msg:
|
except unittest.SkipTest as msg:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(test, "skipped --", msg)
|
print(test, "skipped --", msg, flush=True)
|
||||||
sys.stdout.flush()
|
|
||||||
return SKIPPED, test_time
|
return SKIPPED, test_time
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except support.TestFailed as msg:
|
except support.TestFailed as msg:
|
||||||
if display_failure:
|
if display_failure:
|
||||||
print("test", test, "failed --", msg, file=sys.stderr)
|
print("test", test, "failed --", msg, file=sys.stderr, flush=True)
|
||||||
else:
|
else:
|
||||||
print("test", test, "failed", file=sys.stderr)
|
print("test", test, "failed", file=sys.stderr, flush=True)
|
||||||
sys.stderr.flush()
|
|
||||||
return FAILED, test_time
|
return FAILED, test_time
|
||||||
except:
|
except:
|
||||||
msg = traceback.format_exc()
|
msg = traceback.format_exc()
|
||||||
print("test", test, "crashed --", msg, file=sys.stderr)
|
print("test", test, "crashed --", msg, file=sys.stderr, flush=True)
|
||||||
sys.stderr.flush()
|
|
||||||
return FAILED, test_time
|
return FAILED, test_time
|
||||||
else:
|
else:
|
||||||
if refleak:
|
if refleak:
|
||||||
|
|
|
@ -70,9 +70,8 @@ def run_tests_slave(slaveargs):
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
result = CHILD_ERROR, str(e)
|
result = CHILD_ERROR, str(e)
|
||||||
sys.stdout.flush()
|
|
||||||
print() # Force a newline (just in case)
|
print() # Force a newline (just in case)
|
||||||
print(json.dumps(result))
|
print(json.dumps(result), flush=True)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,11 +183,9 @@ def run_tests_multiprocess(regrtest):
|
||||||
|
|
||||||
# Copy stdout and stderr from the child process
|
# Copy stdout and stderr from the child process
|
||||||
if stdout:
|
if stdout:
|
||||||
print(stdout)
|
print(stdout, flush=True)
|
||||||
if stderr:
|
if stderr:
|
||||||
print(stderr, file=sys.stderr)
|
print(stderr, file=sys.stderr, flush=True)
|
||||||
sys.stdout.flush()
|
|
||||||
sys.stderr.flush()
|
|
||||||
|
|
||||||
if result[0] == INTERRUPTED:
|
if result[0] == INTERRUPTED:
|
||||||
raise KeyboardInterrupt
|
raise KeyboardInterrupt
|
||||||
|
|
Loading…
Reference in New Issue