From 31ab84f6fa74895fcb04077aa0e38d8178acf3f2 Mon Sep 17 00:00:00 2001 From: Detlev Casanova Date: Mon, 30 Oct 2023 16:25:38 -0400 Subject: [PATCH] junitxml: Add each vector test time In gitlab junit reports, the testsuite time is not used to show the complete test time and is shown as 0.0 even if set. Instead, it shows the sum of each test case time. This adds each test case time in the junit report. The sum will not give the actual total time when multiple threads are used, but it can already give an idea of the used time. Signed-off-by: Detlev Casanova --- fluster/fluster.py | 2 ++ fluster/test.py | 11 +++++++++++ fluster/test_vector.py | 2 ++ 3 files changed, 15 insertions(+) diff --git a/fluster/fluster.py b/fluster/fluster.py index 2f2ff96..95a2ef1 100644 --- a/fluster/fluster.py +++ b/fluster/fluster.py @@ -382,6 +382,8 @@ def _parse_suite_results( ]: jcase.result = _parse_vector_errors(vector) + jcase.time = vector.test_time + jsuite.add_testcase(jcase) if vector.test_result is TestVectorResult.TIMEOUT and ctx.jobs == 1: diff --git a/fluster/test.py b/fluster/test.py index fcc2625..bae6784 100644 --- a/fluster/test.py +++ b/fluster/test.py @@ -19,6 +19,7 @@ from subprocess import TimeoutExpired import unittest from typing import Any +from time import perf_counter from fluster.decoder import Decoder from fluster.test_vector import TestVector, TestVectorResult @@ -75,6 +76,7 @@ def _test(self) -> None: input_filepath = normalize_path(input_filepath) try: + start = perf_counter() result = self.decoder.decode( input_filepath, output_filepath, @@ -83,15 +85,24 @@ def _test(self) -> None: self.verbose, self.keep_files, ) + self.test_suite.test_vectors[self.test_vector.name].test_time = ( + perf_counter() - start + ) except TimeoutExpired: self.test_suite.test_vectors[ self.test_vector.name ].test_result = TestVectorResult.TIMEOUT + self.test_suite.test_vectors[self.test_vector.name].test_time = ( + perf_counter() - start + ) raise except Exception: self.test_suite.test_vectors[ self.test_vector.name ].test_result = TestVectorResult.ERROR + self.test_suite.test_vectors[self.test_vector.name].test_time = ( + perf_counter() - start + ) raise if ( diff --git a/fluster/test_vector.py b/fluster/test_vector.py index 925c97b..e81b0d8 100644 --- a/fluster/test_vector.py +++ b/fluster/test_vector.py @@ -60,6 +60,7 @@ def __init__( # Not included in JSON self.test_result = TestVectorResult.NOT_RUN + self.test_time = 0.0 self.errors: List[List[str]] = [] @classmethod @@ -76,6 +77,7 @@ def data_to_serialize(self) -> Dict[str, object]: data = self.__dict__.copy() data.pop("test_result") data.pop("errors") + data.pop("test_time") data["output_format"] = str(self.output_format.value) return data