From d2e00d62e244b293b5b2459942b3a55447c191f3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 23 Aug 2019 14:09:48 +0200 Subject: [PATCH] integration: test2json: enable timestamps to fix zero-time test durations Without these options set, test2json does not include a `Time` field in the generated JSON; {"Action":"run","Test":"TestCgroupNamespacesBuild"} {"Action":"output","Test":"TestCgroupNamespacesBuild","Output":"=== RUN TestCgroupNamespacesBuild\n"} {"Action":"output","Test":"TestCgroupNamespacesBuild","Output":"--- PASS: TestCgroupNamespacesBuild (1.70s)\n"} ... {"Action":"pass","Test":"TestCgroupNamespacesBuild"} As a result, `gotestsum` was not able to calculate test-duration, and reported `time="0.000000"` for all tests; With this patch applied: {"Time":"2019-08-23T22:42:41.644361357Z","Action":"run","Package":"amd64.integration.build","Test":"TestCgroupNamespacesBuild"} {"Time":"2019-08-23T22:42:41.644367647Z","Action":"output","Package":"amd64.integration.build","Test":"TestCgroupNamespacesBuild","Output":"=== RUN TestCgroupNamespacesBuild\n"} {"Time":"2019-08-23T22:42:44.926933252Z","Action":"output","Package":"amd64.integration.build","Test":"TestCgroupNamespacesBuild","Output":"--- PASS: TestCgroupNamespacesBuild (3.28s)\n"} ... {"Time":"2019-08-23T22:42:44.927003836Z","Action":"pass","Package":"amd64.integration.build","Test":"TestCgroupNamespacesBuild","Elapsed":3.28} Which now correctly reports the test's duration: Signed-off-by: Sebastiaan van Stijn --- hack/make/.integration-test-helpers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index 69b2744036..cc2e8ac518 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -67,7 +67,7 @@ run_test_integration_suites() { --jsonfile="${ABS_DEST}/$(basename "$dir")-go-test-report.json" \ --junitfile="${ABS_DEST}/$(basename "$dir")-junit-report.xml" \ --raw-command \ - -- go tool test2json ./test.main ${flags} + -- go tool test2json -t ./test.main ${flags} ); then exit 1; fi done }