From a827cb1fac515aaf7c8c1fb86e0998f7cdad75a5 Mon Sep 17 00:00:00 2001 From: Rail Aliiev Date: Tue, 23 Nov 2021 13:57:58 -0500 Subject: [PATCH] Save test output in test2json format If `GO_TEST_JSON_OUTPUT_FILE` environment variable is set, write the test output in test2json format. --- go/tools/bzltestutil/wrap.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go/tools/bzltestutil/wrap.go b/go/tools/bzltestutil/wrap.go index 382d636a66..cbb2e7e66c 100644 --- a/go/tools/bzltestutil/wrap.go +++ b/go/tools/bzltestutil/wrap.go @@ -85,6 +85,11 @@ func Wrap(pkg string) error { return fmt.Errorf("error while generating testreport: %s", werr) } } + if out, ok := os.LookupEnv("GO_TEST_JSON_OUTPUT_FILE"); ok { + if err := ioutil.WriteFile(out, jsonBuffer.Bytes(), 0664); err != nil { + return fmt.Errorf("error writing test json: %s", err) + } + } return err }