From 91d9373b28f85e85abe4cd3eef55e939ddc616ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Mon, 21 Aug 2023 08:10:32 +0200 Subject: [PATCH] Rename TESTS_ELAPSED environment variable --- README.md | 2 +- cmd/handler.go | 2 +- cmd/handler_test.go | 2 +- cmd/testdata/post-run-hook-expected | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cca98cf1..8c662c46 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ test run has completed. The binary will be run with the following environment variables set: ``` +GOTESTSUM_ELAPSED # test time elapsed, in seconds GOTESTSUM_FORMAT # gotestsum format (ex: short) GOTESTSUM_JSONFILE # path to the jsonfile, empty if no file path was given GOTESTSUM_JUNITFILE # path to the junit.xml file, empty if no file path was given @@ -146,7 +147,6 @@ TESTS_ERRORS # number of errors TESTS_FAILED # number of failed tests TESTS_SKIPPED # number of skipped tests TESTS_TOTAL # number of tests run -TESTS_ELAPSED # test time elapsed, in seconds ``` To get more details about the test run, such as failure messages or the full list of failed diff --git a/cmd/handler.go b/cmd/handler.go index 0820ee68..99fd002d 100644 --- a/cmd/handler.go +++ b/cmd/handler.go @@ -170,11 +170,11 @@ func postRunHook(opts *options, execution *testjson.Execution) error { "GOTESTSUM_JSONFILE="+opts.jsonFile, "GOTESTSUM_JSONFILE_TIMING_EVENTS="+opts.jsonFileTimingEvents, "GOTESTSUM_JUNITFILE="+opts.junitFile, + fmt.Sprintf("GOTESTSUM_ELAPSED=%.3f", execution.Elapsed().Seconds()), fmt.Sprintf("TESTS_TOTAL=%d", execution.Total()), fmt.Sprintf("TESTS_FAILED=%d", len(execution.Failed())), fmt.Sprintf("TESTS_SKIPPED=%d", len(execution.Skipped())), fmt.Sprintf("TESTS_ERRORS=%d", len(execution.Errors())), - fmt.Sprintf("TESTS_ELAPSED=%.3f", execution.Elapsed().Seconds()), ) return cmd.Run() } diff --git a/cmd/handler_test.go b/cmd/handler_test.go index dabefd26..5d55f9d1 100644 --- a/cmd/handler_test.go +++ b/cmd/handler_test.go @@ -39,7 +39,7 @@ func TestPostRunHook(t *testing.T) { assert.NilError(t, err) actual := text.ProcessLines(t, buf, func(line string) string { - if strings.HasPrefix(line, "TESTS_ELAPSED=0.0") { + if strings.HasPrefix(line, "GOTESTSUM_ELAPSED=0.0") { i := strings.Index(line, "=") return line[:i] + "=0.000" } diff --git a/cmd/testdata/post-run-hook-expected b/cmd/testdata/post-run-hook-expected index 55ea6b5d..a2a6b9e5 100644 --- a/cmd/testdata/post-run-hook-expected +++ b/cmd/testdata/post-run-hook-expected @@ -1,8 +1,8 @@ +GOTESTSUM_ELAPSED=0.000 GOTESTSUM_FORMAT=short GOTESTSUM_JSONFILE=events.json GOTESTSUM_JSONFILE_TIMING_EVENTS=timing.json GOTESTSUM_JUNITFILE=junit.xml -TESTS_ELAPSED=0.000 TESTS_ERRORS=0 TESTS_FAILED=13 TESTS_SKIPPED=5