diff --git a/testr/packages.py b/testr/packages.py index efe4404..e9f4261 100644 --- a/testr/packages.py +++ b/testr/packages.py @@ -16,6 +16,8 @@ import collections import junit_xml import json +import datetime +import platform opt = None logger = None @@ -215,7 +217,7 @@ def run_tests(package, tests): cmd = './' + test['file'] else: cmd = interpreter + ' ' + test['file'] - + test['t_start'] = datetime.datetime.now().strftime('%Y:%m:%dT%H:%M:%S') try: bash(cmd, logfile=logfile, env=env) except ShellError: @@ -223,6 +225,7 @@ def run_tests(package, tests): test['status'] = 'FAIL' else: test['status'] = 'pass' + test['t_stop'] = datetime.datetime.now().strftime('%Y:%m:%dT%H:%M:%S') box_output(['{} Test Summary'.format(package)] + ['{:20s} {}'.format(test['file'], test['status']) for test in tests]) @@ -362,10 +365,18 @@ def _parse_xml(filename): def write_log(tests, formats=['json', 'xml'], include_stdout=False): - import datetime now = datetime.datetime.now().strftime('%Y:%m:%dT%H:%M:%S') all_test_suites = [] + uname = platform.uname() + architecture, _ = platform.architecture() + sys_info = { + 'system': uname.system, + 'architecture': architecture, + 'hostname': uname.node, + 'platform': platform.platform(True, True) + } + for package in sorted(tests): pkg_test_suites = [] orphan_tests = [] @@ -379,10 +390,12 @@ def write_log(tests, formats=['json', 'xml'], include_stdout=False): xml_file = os.path.join(test['out_dir'], f'{test["file"]}.xml') if os.path.exists(xml_file): + properties.test.copy() + properties.update(sys_info) test_suites = _parse_xml(xml_file) for ts in test_suites: ts['name'] = f"{package}-{ts['name']}" - ts['properties'] = test.copy() + ts['properties'] = properties ts['log'] = f"{test['file']}.log" if len(test_suites) == 1: test_suites[0]['stdout'] = stdout @@ -412,6 +425,7 @@ def write_log(tests, formats=['json', 'xml'], include_stdout=False): 'package': package, 'version': test['package_version'], } + properties.update(sys_info) test_suite = dict( name=f"{package}-tests", package=package,