Made test.py output parsable by summary.py

Also fixed an issue with truncation that resulted in a bunch of null
bytes being injected into the CSV output.
This commit is contained in:
Christopher Haster
2022-09-16 03:55:34 -05:00
parent acdea1880e
commit 1fcd82d5d8
2 changed files with 6 additions and 4 deletions

View File

@@ -18,7 +18,8 @@ CSV_PATHS = ['*.csv']
MERGES = { MERGES = {
'add': ( 'add': (
['code_size', 'data_size', 'stack_frame', 'struct_size', ['code_size', 'data_size', 'stack_frame', 'struct_size',
'coverage_lines', 'coverage_branches'], 'coverage_lines', 'coverage_branches',
'test_passed'],
lambda xs: sum(xs[1:], start=xs[0]) lambda xs: sum(xs[1:], start=xs[0])
), ),
'mul': ( 'mul': (

View File

@@ -663,6 +663,7 @@ class TestOutput:
else: else:
# need to rewrite the file # need to rewrite the file
self.head.extend(row.keys() - (self.head + self.tail)) self.head.extend(row.keys() - (self.head + self.tail))
self.f.seek(0)
self.f.truncate() self.f.truncate()
self.writer = csv.DictWriter(self.f, self.head + self.tail) self.writer = csv.DictWriter(self.f, self.head + self.tail)
self.writer.writeheader() self.writer.writeheader()
@@ -767,7 +768,7 @@ def run_stage(name, runner_, ids, output_, **args):
runner_, m.group('id'), **args) runner_, m.group('id'), **args)
output_.writerow({ output_.writerow({
'case': m.group('case'), 'case': m.group('case'),
'test_pass': 1, 'test_passed': '1/1',
**defines}) **defines})
elif op == 'skipped': elif op == 'skipped':
locals.seen_perms += 1 locals.seen_perms += 1
@@ -822,7 +823,7 @@ def run_stage(name, runner_, ids, output_, **args):
defines = find_defines(runner_, failure.id, **args) defines = find_defines(runner_, failure.id, **args)
output_.writerow({ output_.writerow({
'case': ':'.join([suite, case]), 'case': ':'.join([suite, case]),
'test_pass': 0, 'test_passed': '0/1',
**defines}) **defines})
# race condition for multiple failures? # race condition for multiple failures?
@@ -936,7 +937,7 @@ def run(runner, test_ids=[], **args):
trace = openio(args['trace'], 'w', 1) trace = openio(args['trace'], 'w', 1)
output = None output = None
if args.get('output'): if args.get('output'):
output = TestOutput(args['output'], ['case'], ['test_pass']) output = TestOutput(args['output'], ['case'], ['test_passed'])
# measure runtime # measure runtime
start = time.time() start = time.time()