Skip to content

Commit e6ea37f

Browse files
committed
Reformat test report output, blend spec + report in same section
Change disposition of the report from separate output and specification sections, to a combined specification, result and output for each test. This greatly improves the accessibility for the generated PDF, keeping all relevant information in one place, and eliminating the unintuitive link to the Test Specification from the output. Links are problematic in printed media. The call to write_report_result_tree() is temporarily dropped in this commit, only to reintroduce it in the next in a new Test Info section under the Test Summary. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 2e250e2 commit e6ea37f

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

9pm.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -334,41 +334,42 @@ def write_report_result_tree(file, includes, data, depth):
334334
else:
335335
string += f" {test['name']}"
336336

337-
# Append (Spec) if there's a test specification
338-
if 'test-spec-sha' in test:
339-
string += f" <<incl-{test['test-spec-sha']},(Spec)>>"
340-
341337
file.write(f"{string}\n")
342338

343339
if 'suite' in test:
344340
write_report_result_tree(file, includes, test, depth + 1)
345341

346-
def write_report_output(file, data, depth):
342+
def write_report_output(file, data, depth, is_first=True):
343+
"""For each test in suite, write specification¹, result, and output"""
347344
for test in data['suite']:
348-
349345
if 'outfile' in test:
350-
file.write(f"\n=== {test['name']}\n")
351-
352-
if 'test-spec-sha' in test:
353-
file.write(f"\n<<incl-{test['test-spec-sha']},Test Specification>>\n")
346+
# Add page break before each test, except first one
347+
if is_first:
348+
is_first = False
349+
else:
350+
file.write("\n<<<\n")
354351

355352
file.write(f"\n[[output-{test['name']}]]\n")
353+
# Use heading from spec, ¹if a spec is available
354+
if 'test-spec' in test:
355+
file.write("include::{}[]\n" . format(test['test-spec']))
356+
else:
357+
file.write(f"\n=== {test['name']}\n")
358+
359+
# Show result of test as a dedicated heading
360+
result = test.get('result', 'unknown').upper()
361+
file.write("\n==== Result\n")
362+
file.write(f"\n[.{test.get('result', 'unknown')}]#{result}#\n")
363+
364+
file.write("\n==== Output\n")
356365
file.write(f"----\n")
357366
file.write(f"include::{test['outfile']}[]\n")
358367
file.write(f"----\n")
359368

360369
if 'suite' in test:
361-
write_report_output(file, test, depth + 1)
362-
363-
def write_report_specifications(file, data, depth):
364-
for test in data['suite']:
365-
366-
if 'test-spec-sha' in test:
367-
file.write(f"\n[[incl-{test['test-spec-sha']}]]\n")
368-
file.write("include::{}[]\n" . format(test['test-spec']))
370+
is_first = write_report_output(file, test, depth + 1, is_first)
369371

370-
if 'suite' in test:
371-
write_report_specifications(file, test, depth + 1)
372+
return is_first
372373

373374
def write_report_project_info(file, config):
374375
if 'PROJECT-NAME' not in config or 'PROJECT-ROOT' not in config:
@@ -409,18 +410,8 @@ def write_report(data, config):
409410

410411
file.write("\n<<<\n")
411412
file.write("\n== Test Result\n\n")
412-
413-
includes = []
414-
write_report_result_tree(file, includes, data, 0)
415-
416-
file.write("\n<<<\n")
417-
file.write("\n== Test Output\n")
418413
write_report_output(file, data, 0)
419414

420-
file.write("\n<<<\n")
421-
file.write("\n== Test Specification\n")
422-
write_report_specifications(file, data, 0)
423-
424415

425416
def write_github_result_tree(file, data, depth):
426417
icon_map = {

0 commit comments

Comments
 (0)