Commit a129b560 authored by Jérome Perrin's avatar Jérome Perrin

Flush output right after printing running test name

If test program output on stderr (which is unbuffered), the
output of the test program will appear before output from nxdtest
advertising the program that is about to be executed, because nxdtest
stdout is buffered (testnode does not set PYTHONUNBUFFERED, and eventhough
nxdtest sets PYTHONUNBUFFERED in its own environ, this only applies to sub
processes)
parent bca50060
......@@ -101,6 +101,12 @@ class TestEnv:
self.testv.append(t)
self.byname[name] = t
def emit(*message):
"""Emit a message on stdout and flush output.
"""
print(*message)
sys.stdout.flush()
def main():
# testnode executes us giving URL to master results collecting instance and other details
# https://lab.nexedi.com/nexedi/erp5/blob/744f3fde/erp5/util/testnode/UnitTestRunner.py#L137
......@@ -136,7 +142,7 @@ def main():
# --list
if args.list:
for t in tenv.testv:
print(t.name)
emit(t.name)
return
# master_url provided -> run tests under master control
......@@ -185,8 +191,8 @@ def main():
t = tenv.byname[test_result_line.name]
tstart = time()
print('\n>>> %s' % t.name)
print('$ %s' % t.command_str())
emit('\n>>> %s' % t.name)
emit('$ %s' % t.command_str())
# default status dict
status = {
......@@ -256,7 +262,7 @@ def main():
}
tres.update(status)
print(_test_result_summary(t.name, tres))
emit(_test_result_summary(t.name, tres))
test_result_line.stop(**tres)
# tee, similar to tee(1) utility, copies data from fin to fout appending them to buf.
......@@ -304,11 +310,11 @@ def _test_result_summary(name, kw):
# system_info prints information about local computer.
def system_info():
print('date:\t%s' % (strftime("%a, %d %b %Y %H:%M:%S %Z", localtime())))
emit('date:\t%s' % (strftime("%a, %d %b %Y %H:%M:%S %Z", localtime())))
whoami = pwd.getpwuid(os.getuid()).pw_name
print('xnode:\t%s@%s' % (whoami, socket.getfqdn()))
print('uname:\t%s' % ' '.join(os.uname()))
print('cpu:\t%s' % get1('/proc/cpuinfo', 'model name'))
emit('xnode:\t%s@%s' % (whoami, socket.getfqdn()))
emit('uname:\t%s' % ' '.join(os.uname()))
emit('cpu:\t%s' % get1('/proc/cpuinfo', 'model name'))
# get1 returns first entry from file @path prefixed with ^<field>\s*:
def get1(path, field, default=None):
......
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