From e3569d8559f91d491a46c506ad5bd8c2c7c475e5 Mon Sep 17 00:00:00 2001 From: olgavrou Date: Fri, 17 May 2019 09:36:31 +0100 Subject: [PATCH] Adding coverage to perf summary csv (#74) --- tests/coverage/add_perf_summary.py | 20 ++++++++++++++++++++ tests/coverage/generate_coverage.sh | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/coverage/add_perf_summary.py diff --git a/tests/coverage/add_perf_summary.py b/tests/coverage/add_perf_summary.py new file mode 100644 index 000000000..7b356af2e --- /dev/null +++ b/tests/coverage/add_perf_summary.py @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache 2.0 License. +import time +import json + +with open("coverage.json", "r") as file: + timestamp = str(int(time.time())) + data = json.load(file)["data"][0] + lines_covered = str(data["totals"]["lines"]["covered"]) + lines_valid = str(data["totals"]["lines"]["count"]) + +with open("perf_summary.csv", "a") as f: + f.write( + timestamp + + "," + + lines_valid + + ",Unit_Test_Coverage,0,0,0," + + lines_covered + + ",0,0,0,0" + ) diff --git a/tests/coverage/generate_coverage.sh b/tests/coverage/generate_coverage.sh index 32a4f354a..b7c6e5ab1 100755 --- a/tests/coverage/generate_coverage.sh +++ b/tests/coverage/generate_coverage.sh @@ -20,4 +20,5 @@ llvm-cov-7 export -instr-profile coverage.profdata -format=text ds_test "${objec mv cov_* coverage/ python3.7 ../tests/coverage/cobertura_generator.py -python3.7 ../tests/coverage/style_html.py \ No newline at end of file +python3.7 ../tests/coverage/style_html.py +python3.7 ../tests/coverage/add_perf_summary.py \ No newline at end of file