Commit f1840722 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ea808106
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
XXX more docs XXX more docs
""" """
from __future__ import print_function, absolute_import
# XXX split -> nxdtest + NXDTestfile (name=?) # XXX split -> nxdtest + NXDTestfile (name=?)
from erp5.util.taskdistribution import TaskDistributor from erp5.util.taskdistribution import TaskDistributor
...@@ -51,11 +53,16 @@ def main(): ...@@ -51,11 +53,16 @@ def main():
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger() logger = logging.getLogger()
# 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 # connect to master and create 'test result' object with list of tests to run
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 = ['test-go', 'test-py', 'bench-local'], test_name_list = testv,
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)
...@@ -64,6 +71,10 @@ def main(): ...@@ -64,6 +71,10 @@ def main():
# a test run for given name and revision has already been completed # a test run for given name and revision has already been completed
return return
# master_url not provided -> run tests locally
else:
test_result = LocalTestResult(testv)
# make sure we get output from subprocesses without delay. # make sure we get output from subprocesses without delay.
# go does not buffer stdout/stderr by default, but python does for stdout. # go does not buffer stdout/stderr by default, but python does for stdout.
# tell python not to buffer anything. # tell python not to buffer anything.
...@@ -142,7 +153,7 @@ def main(): ...@@ -142,7 +153,7 @@ def main():
stdout = stdout, stdout = stdout,
stderr = stderr, 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. # 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): ...@@ -164,6 +175,39 @@ def tee(fin, fout, buf):
buf.append(data) 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 # xint converts number from neo/py test output to integer
def xint(s): def xint(s):
s = s.strip() 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