Commit 5286c06e authored by Stefan Behnel's avatar Stefan Behnel

Direct all test output in the test runner to stderr because that's where...

Direct all test output in the test runner to stderr because that's where unittest is writing it, and it gives better ordering on Windows to not mix stdout and stderr.
parent 71b4285a
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function
import atexit import atexit
import os import os
import sys import sys
...@@ -69,7 +71,7 @@ except ImportError: ...@@ -69,7 +71,7 @@ except ImportError:
class SkipTest(Exception): # don't raise, only provided to allow except-ing it! class SkipTest(Exception): # don't raise, only provided to allow except-ing it!
pass pass
def skip_test(reason): def skip_test(reason):
print("Skipping test: %s" % reason) sys.stderr.write("Skipping test: %s\n" % reason)
else: else:
def skip_test(reason): def skip_test(reason):
raise SkipTest(reason) raise SkipTest(reason)
...@@ -1664,9 +1666,8 @@ class EndToEndTest(unittest.TestCase): ...@@ -1664,9 +1666,8 @@ class EndToEndTest(unittest.TestCase):
out, err = p.communicate() out, err = p.communicate()
res = p.returncode res = p.returncode
if res != 0: if res != 0:
print(command) sys.stderr.write("%s\n%s\n%s\n" % (
print(self._try_decode(out)) command, self._try_decode(out), self._try_decode(err)))
print(self._try_decode(err))
self.assertEqual(0, res, "non-zero exit status") self.assertEqual(0, res, "non-zero exit status")
self.success = True self.success = True
...@@ -2049,21 +2050,22 @@ def main(): ...@@ -2049,21 +2050,22 @@ def main():
for shard_num, return_code in pool.imap_unordered(runtests_callback, tasks): for shard_num, return_code in pool.imap_unordered(runtests_callback, tasks):
if return_code != 0: if return_code != 0:
errors.append(shard_num) errors.append(shard_num)
print("FAILED (%s/%s)" % (shard_num, options.shard_count)) sys.stderr.write("FAILED (%s/%s)\n" % (shard_num, options.shard_count))
print("ALL DONE (%s/%s)" % (shard_num, options.shard_count)) sys.stderr.write("ALL DONE (%s/%s)\n" % (shard_num, options.shard_count))
pool.close() pool.close()
pool.join() pool.join()
total_time = time.time() - total_time total_time = time.time() - total_time
print("Sharded tests run in %d seconds (%.1f minutes)" % (round(total_time), total_time / 60.)) sys.stderr.write("Sharded tests run in %d seconds (%.1f minutes)\n" % (round(total_time), total_time / 60.))
if errors: if errors:
print("Errors for shards %s" % ", ".join([str(e) for e in errors])) sys.stderr.write("Errors for shards %s\n" % ", ".join([str(e) for e in errors]))
return_code = 1 return_code = 1
else: else:
return_code = 0 return_code = 0
else: else:
with time_stamper_thread(): with time_stamper_thread():
_, return_code = runtests(options, cmd_args, coverage) _, return_code = runtests(options, cmd_args, coverage)
print("ALL DONE") sys.stderr.write("ALL DONE\n")
sys.stderr.flush()
try: try:
check_thread_termination(ignore_seen=False) check_thread_termination(ignore_seen=False)
...@@ -2091,6 +2093,7 @@ def time_stamper_thread(interval=10): ...@@ -2091,6 +2093,7 @@ def time_stamper_thread(interval=10):
interval = _xrange(interval * 4) interval = _xrange(interval * 4)
now = datetime.now now = datetime.now
write = sys.stderr.write
stop = False stop = False
def time_stamper(): def time_stamper():
...@@ -2099,7 +2102,7 @@ def time_stamper_thread(interval=10): ...@@ -2099,7 +2102,7 @@ def time_stamper_thread(interval=10):
if stop: if stop:
return return
sleep(1./4) sleep(1./4)
print('\n#### %s' % now()) write('\n#### %s\n' % now())
thread = threading.Thread(target=time_stamper) thread = threading.Thread(target=time_stamper)
thread.start() thread.start()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment