Skip to content

Commit

Permalink
junitxml: Add each vector test time
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cazou authored and rgonzalezfluendo committed Nov 23, 2023
1 parent 3fefc8c commit 854b13f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fluster/fluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions fluster/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions fluster/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 854b13f

Please sign in to comment.