Skip to content

Commit 527bd24

Browse files
author
Pierre-vh
committed
[debuginfo-tests][dexter] Add a test tool --calculate-average option
Differential Revision: https://reviews.llvm.org/D75235
1 parent 7369ad3 commit 527bd24

File tree

1 file changed

+17
-0
lines changed
  • debuginfo-tests/dexter/dex/tools/test

1 file changed

+17
-0
lines changed

debuginfo-tests/dexter/dex/tools/test/Tool.py

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77
"""Test tool."""
88

9+
import math
910
import os
1011
import csv
1112
import pickle
@@ -94,6 +95,9 @@ def add_tool_arguments(self, parser, defaults):
9495
help='exit with status FAIL(2) if the test result'
9596
' is less than this value.',
9697
metavar='<float>')
98+
parser.add_argument('--calculate-average',
99+
action="store_true",
100+
help='calculate the average score of every test run')
97101
super(Tool, self).add_tool_arguments(parser, defaults)
98102

99103
def _build_test_case(self):
@@ -226,6 +230,19 @@ def _handle_results(self) -> ReturnCode:
226230
if not options.verbose:
227231
self.context.o.auto('\n')
228232

233+
if options.calculate_average:
234+
# Calculate and print the average score
235+
score_sum = 0.0
236+
num_tests = 0
237+
for test_case in self._test_cases:
238+
score = test_case.score
239+
if not test_case.error and not math.isnan(score):
240+
score_sum += test_case.score
241+
num_tests += 1
242+
243+
if num_tests != 0:
244+
print("@avg: ({:.4f})".format(score_sum/num_tests))
245+
229246
summary_path = os.path.join(options.results_directory, 'summary.csv')
230247
with open(summary_path, mode='w', newline='') as fp:
231248
writer = csv.writer(fp, delimiter=',')

0 commit comments

Comments
 (0)