Skip to content

Commit 0d345ce

Browse files
authored
Parse long durations (#257)
1 parent 3c731de commit 0d345ce

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

test/converters/xcresult3/model3/conversion.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ func extractTestCases(nodes []TestNode, fallbackName string) ([]TestCaseWithRetr
102102
}
103103

104104
func extractDuration(text string) time.Duration {
105-
// Duration is in the format "123.456789s" or "123,456789s", so we need to replace the comma with a dot.
106-
text = strings.Replace(text, ",", ".", -1)
107-
duration, err := time.ParseDuration(text)
105+
// Duration is in the format "123.456789s", "123,456789s" or "4m 34s", so we need to do some normalization. We
106+
// need to replace the comma with a dot and remove the space to be able to parse it with time.ParseDuration.
107+
normalized := strings.ReplaceAll(text, ",", ".")
108+
normalized = strings.ReplaceAll(normalized, " ", "")
109+
110+
duration, err := time.ParseDuration(normalized)
108111
if err != nil {
109112
return 0
110113
}

test/converters/xcresult3/model3/conversion_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestConversion(t *testing.T) {
3939
Type: TestNodeTypeTestCase,
4040
Name: "TC2",
4141
Result: TestResultFailed,
42-
Duration: "1s",
42+
Duration: "1m 11s",
4343
},
4444
},
4545
},
@@ -108,7 +108,7 @@ func TestConversion(t *testing.T) {
108108
TestCase: TestCase{
109109
Name: "TC2",
110110
ClassName: "TS1",
111-
Time: 1 * time.Second,
111+
Time: 71 * time.Second,
112112
Result: "Failed",
113113
},
114114
},

0 commit comments

Comments
 (0)