Skip to content

Commit

Permalink
Merge pull request #3859 from dgageot/fix-gotest-helper
Browse files Browse the repository at this point in the history
Fix go test helper
  • Loading branch information
nkubala authored Mar 23, 2020
2 parents e9c4111 + e47ca3b commit 86b290e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hack/tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"os/exec"
"sort"
Expand Down Expand Up @@ -66,9 +65,14 @@ func goTest(testArgs []string) error {
// Print logs while tests are running
scanner := bufio.NewScanner(out)
for i := 0; scanner.Scan(); i++ {
line := scanner.Bytes()

var l LogLine
if err := json.Unmarshal(scanner.Bytes(), &l); err != nil {
log.Panicf("unable to parse line %d: %v", i, err)
if err := json.Unmarshal(line, &l); err != nil {
// Sometimes, `go test -json` outputs plain text instead of json.
// For example in case of a build error.
fmt.Println(failInRed(string(line)))
continue
}

allLogs = append(allLogs, l)
Expand Down

0 comments on commit 86b290e

Please sign in to comment.