diff --git a/src/codemagic/models/xctests/converter.py b/src/codemagic/models/xctests/converter.py index cb7cb677..34f53677 100644 --- a/src/codemagic/models/xctests/converter.py +++ b/src/codemagic/models/xctests/converter.py @@ -4,9 +4,8 @@ import re from abc import ABC from abc import abstractmethod -from collections import defaultdict from datetime import datetime -from typing import Dict +from datetime import timedelta from typing import Iterator from typing import List from typing import Optional @@ -244,21 +243,21 @@ def _get_test_case_skipped(cls, xc_test_case: XcTestNode) -> Optional[Skipped]: @classmethod def parse_xcresult_test_node_duration_value(cls, xc_duration: str) -> float: - counters: Dict[str, float] = defaultdict(float) + duration = timedelta() try: for part in xc_duration.split(): + part_value = float(part[:-1].replace(",", ".")) if part.endswith("s"): - counter = "seconds" + duration += timedelta(seconds=part_value) elif part.endswith("m"): - counter = "minutes" + duration += timedelta(minutes=part_value) else: raise ValueError("Unknown duration unit") - counters[counter] = float(part[:-1].replace(",", ".")) except ValueError as ve: raise ValueError("Invalid duration", xc_duration) from ve - return counters["minutes"] * 60.0 + counters["seconds"] + return duration.total_seconds() @classmethod def _get_test_node_duration(cls, xc_test_case: XcTestNode) -> float: diff --git a/tests/models/xctests/converter/test_xcode_16_converter.py b/tests/models/xctests/converter/test_xcode_16_converter.py index ea4c8422..bf213b86 100644 --- a/tests/models/xctests/converter/test_xcode_16_converter.py +++ b/tests/models/xctests/converter/test_xcode_16_converter.py @@ -139,6 +139,8 @@ def test_converter(mock_datetime, expected_properties): ("0,2s", 0.2), ("2s", 2.0), ("3s", 3.0), + ("1m 3,01s", 63.01), + ("1m 3.01s", 63.01), ("1m 4s", 64.0), ("2m 26s", 146.0), ("5m 3s", 303.0),