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