Commit ae543059 authored by Kirill Smelkov's avatar Kirill Smelkov

go/neo/t/nxd/runTestSuite: Also run go & py unit tests in addition to bench-local

parent a143f8e6
...@@ -25,7 +25,7 @@ neotest must be on $PATH. ...@@ -25,7 +25,7 @@ neotest must be on $PATH.
from erp5.util.taskdistribution import TaskDistributor from erp5.util.taskdistribution import TaskDistributor
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from time import time, strftime, gmtime from time import time, strftime, gmtime
import os, sys, threading, argparse, logging, traceback import os, sys, threading, argparse, logging, traceback, re
def main(): def main():
...@@ -53,7 +53,7 @@ def main(): ...@@ -53,7 +53,7 @@ def main():
tool = TaskDistributor(portal_url = args.master_url, logger = logger) tool = TaskDistributor(portal_url = args.master_url, logger = logger)
test_result = tool.createTestResult( test_result = tool.createTestResult(
revision = args.revision, revision = args.revision,
test_name_list = ['bench-local'], test_name_list = ['test-go', 'test-py', 'bench-local'],
node_title = args.test_node_title, node_title = args.test_node_title,
test_title = args.test_suite_title or args.test_suite, test_title = args.test_suite_title or args.test_suite,
project_title = args.project_title) project_title = args.project_title)
...@@ -76,7 +76,8 @@ def main(): ...@@ -76,7 +76,8 @@ def main():
break break
# run `neotest <test-name>` # run `neotest <test-name>`
argv = ['neotest', test_result_line.name] testname = test_result_line.name
argv = ['neotest', testname]
tstart = time() tstart = time()
try: try:
...@@ -102,8 +103,31 @@ def main(): ...@@ -102,8 +103,31 @@ def main():
p.wait() p.wait()
ok = (p.returncode == 0) ok = (p.returncode == 0)
tend = time() # default status dict just by exit code
status = {
'test_count': 1,
'error_count': (0 if ok else 1),
'failure_count': 0,
'skip_count': 0,
#html_test_result
}
# postprocess output, if we can
summaryf = globals().get(testname.replace('-', '_') + '_summary')
if summaryf is not None:
try:
summary = summaryf(stdout)
except:
bad = traceback.format_exc()
sys.stderr.write(bad)
stderr += bad
status['error_count'] += 1
else:
status.update(summary)
tend = time()
# report result of test run back to master # report result of test run back to master
test_result_line.stop( test_result_line.stop(
...@@ -114,11 +138,7 @@ def main(): ...@@ -114,11 +138,7 @@ def main():
stdout = stdout, stdout = stdout,
stderr = stderr, stderr = stderr,
test_count = 1, **status
error_count = (0 if ok else 1),
failure_count = 0,
skip_count = 0,
#html_test_result
) )
# tee, similar to tee(1) utility, copies data from fin to fout appending them to buf. # tee, similar to tee(1) utility, copies data from fin to fout appending them to buf.
...@@ -140,5 +160,31 @@ def tee(fin, fout, buf): ...@@ -140,5 +160,31 @@ def tee(fin, fout, buf):
buf.append(data) buf.append(data)
# xint converts number from neo/py test output to integer
def xint(s):
s = s.strip()
if s == '.':
return 0
else:
return int(s)
# extract summary from neo/py test run
def test_py_summary(stdout):
# Test Module | run | unexpected | expected | skipped | time
# ...
# Summary | 366 | . | 9 | . | 353.47s
m = re.search(r'^\s*summary.*$', stdout, re.M | re.I)
assert m is not None, "could not find summary line"
summary = m.group(0)
_, nrun, nfail, nxfail, nskip, _ = summary.split('|')
return {
'test_count': xint(nrun),
'error_count': xint(nfail),
'failure_count': xint(nxfail),
'skip_count': xint(nskip),
}
if __name__ == '__main__': if __name__ == '__main__':
main() main()
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