Commit f1840722 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ea808106
......@@ -22,6 +22,8 @@
XXX more docs
"""
from __future__ import print_function, absolute_import
# XXX split -> nxdtest + NXDTestfile (name=?)
from erp5.util.taskdistribution import TaskDistributor
......@@ -51,18 +53,27 @@ def main():
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
# connect to master and create 'test result' object with list of tests to run
tool = TaskDistributor(portal_url = args.master_url, logger = logger)
test_result = tool.createTestResult(
revision = args.revision,
test_name_list = ['test-go', 'test-py', 'bench-local'],
node_title = args.test_node_title,
test_title = args.test_suite_title or args.test_suite,
project_title = args.project_title)
if test_result is None:
# a test run for given name and revision has already been completed
return
# list of tests to run
testv = ['test-go', 'test-py', 'bench-local'] # XXX -> .nxdtest
# master_url provided -> run tests under master control
if args.master_url is not None:
# connect to master and create 'test result' object with list of tests to run
tool = TaskDistributor(portal_url = args.master_url, logger = logger)
test_result = tool.createTestResult(
revision = args.revision,
test_name_list = testv,
node_title = args.test_node_title,
test_title = args.test_suite_title or args.test_suite,
project_title = args.project_title)
if test_result is None:
# a test run for given name and revision has already been completed
return
# master_url not provided -> run tests locally
else:
test_result = LocalTestResult(testv)
# make sure we get output from subprocesses without delay.
# go does not buffer stdout/stderr by default, but python does for stdout.
......@@ -142,7 +153,7 @@ def main():
stdout = stdout,
stderr = stderr,
**status # FIXME popen fail -> status is unbound
**status
)
# tee, similar to tee(1) utility, copies data from fin to fout appending them to buf.
......@@ -164,6 +175,39 @@ def tee(fin, fout, buf):
buf.append(data)
# LocalTestResult* handle tests runs, when master_url was not provided and tests are run locally.
class LocalTestResult:
def __init__(self, test_name_list):
self.testv = test_name_list
self.next = 0 # testv[next] is next test to execute
def start(self): # -> test_result_line
if self.next > len(self.testv):
return None # all tests are done
test_result_line = LocalTestResultLine()
test_result_line.name = self.testv[self.next]
self.next += 1
return test_result_line
class LocalTestResultLine:
def stop(self, **kw):
def v(name):
kw.get('name', '?')
_ = v('error_count')
if _ == '?':
st = '?'
elif _ == 0:
st = 'ok'
else:
st = 'fail'
print('%s\t%s\ti%.3fs\t# %sT %sE %sF %sS' % (st, self.name, v('test_count'), v('error_count'), v('failure_count'), v('skip_count')))
# xint converts number from neo/py test output to integer
def xint(s):
s = s.strip()
......
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