Skip to content

Commit f3d79ea

Browse files
authored
Merge pull request #363 from afbjorklund/elapsed-sec
Add the time unit to elapsed time duration
2 parents 73827dd + 0d4e428 commit f3d79ea

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ test run has completed. The binary will be run with the following environment
139139
variables set:
140140

141141
```
142-
GOTESTSUM_ELAPSED # test time elapsed, in seconds
143-
GOTESTSUM_FORMAT # gotestsum format (ex: short)
142+
GOTESTSUM_ELAPSED # test run time in seconds (ex: 2.45s)
143+
GOTESTSUM_FORMAT # gotestsum format (ex: pkgname)
144144
GOTESTSUM_JSONFILE # path to the jsonfile, empty if no file path was given
145145
GOTESTSUM_JUNITFILE # path to the junit.xml file, empty if no file path was given
146146
TESTS_ERRORS # number of errors

cmd/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func postRunHook(opts *options, execution *testjson.Execution) error {
170170
"GOTESTSUM_JSONFILE="+opts.jsonFile,
171171
"GOTESTSUM_JSONFILE_TIMING_EVENTS="+opts.jsonFileTimingEvents,
172172
"GOTESTSUM_JUNITFILE="+opts.junitFile,
173-
fmt.Sprintf("GOTESTSUM_ELAPSED=%.3f", execution.Elapsed().Seconds()),
173+
fmt.Sprintf("GOTESTSUM_ELAPSED=%.3fs", execution.Elapsed().Seconds()),
174174
fmt.Sprintf("TESTS_TOTAL=%d", execution.Total()),
175175
fmt.Sprintf("TESTS_FAILED=%d", len(execution.Failed())),
176176
fmt.Sprintf("TESTS_SKIPPED=%d", len(execution.Skipped())),

cmd/handler_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ func TestPostRunHook(t *testing.T) {
3939
assert.NilError(t, err)
4040

4141
actual := text.ProcessLines(t, buf, func(line string) string {
42-
if strings.HasPrefix(line, "GOTESTSUM_ELAPSED=0.0") {
42+
if strings.HasPrefix(line, "GOTESTSUM_ELAPSED=0.0") &&
43+
strings.HasSuffix(line, "s") {
4344
i := strings.Index(line, "=")
44-
return line[:i] + "=0.000"
45+
return line[:i] + "=0.000s"
4546
}
4647
return line
4748
})

cmd/testdata/post-run-hook-expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GOTESTSUM_ELAPSED=0.000
1+
GOTESTSUM_ELAPSED=0.000s
22
GOTESTSUM_FORMAT=short
33
GOTESTSUM_JSONFILE=events.json
44
GOTESTSUM_JSONFILE_TIMING_EVENTS=timing.json

0 commit comments

Comments
 (0)