From 27dfaf34da942e01599efa95364c87a3a7ddef51 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 17 Dec 2024 13:37:04 +0100 Subject: [PATCH] 9pm.py: add parent project info to test report Signed-off-by: Richard Alpe --- 9pm.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/9pm.py b/9pm.py index a3d9b02..80f71f3 100755 --- a/9pm.py +++ b/9pm.py @@ -346,10 +346,30 @@ def write_report_output(file, data, depth): if 'suite' in test: write_report_output(file, test, depth + 1) -def write_report(data): +def write_report_parent_info(file, rc): + if 'PARENT_PROJECT_NAME' not in rc or 'PARENT_PROJECT_ROOT' not in rc: + return None + + name = rc['PARENT_PROJECT_NAME'] + root = rc['PARENT_PROJECT_ROOT'] + version = run_git_cmd(root, ["describe", "--tags", "--always"]) + sha = run_git_cmd(root, ['rev-parse', 'HEAD'])[:12] + + file.write(f"\n=== {name} Info\n\n") + + file.write('[cols="1h,2"]\n') + file.write("|===\n") + file.write(f"| Version | {version}\n") + file.write(f"| SHA | {sha}\n") + + file.write("|===\n") + +def write_report(data, rc): with open(os.path.join(LOGDIR, 'report.adoc'), 'a') as file: current_date = datetime.now().strftime("%Y-%m-%d") - file.write("= 9pm Test Report\n") + name = rc['PARENT_PROJECT_NAME'] if 'PARENT_PROJECT_NAME' in rc else "9pm" + + file.write(f"= {name} Test Report\n") file.write("Author: 9pm Test Framework\n") file.write(f"Date: {current_date}\n") file.write(":toc: left\n") @@ -357,6 +377,10 @@ def write_report(data): file.write(":sectnums:\n") file.write(":pdf-page-size: A4\n") + file.write("\n<<<\n") + file.write("\n== Test Summary\n\n") + write_report_parent_info(file, rc) + file.write("\n<<<\n") file.write("\n== Test Result\n\n") @@ -682,7 +706,7 @@ def main(): print_result_tree(cmdl, "") write_md_result(cmdl) write_github_result(cmdl) - write_report(cmdl) + write_report(cmdl, rc) db.close() sys.exit(err)