Skip to content

Commit

Permalink
[fix] Skip non-JSON lines (#10605)
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-cordenier authored Sep 12, 2023
1 parent 1d425b9 commit fae227d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/flakeytests/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ func parseOutput(readers ...io.Reader) (map[string]map[string]int, error) {
continue
}

if !strings.HasPrefix(string(t), "{") {
continue
}

e, err := newEvent(t)
if err != nil {

return nil, err
}

Expand Down
15 changes: 15 additions & 0 deletions tools/flakeytests/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ func TestParser(t *testing.T) {
assert.Equal(t, ts["core/assets"]["TestLink"], 1)
}

func TestParser_SkipsNonJSON(t *testing.T) {
output := `Failed tests and panics:
-------
{"Time":"2023-09-07T15:39:46.378315+01:00","Action":"fail","Package":"github.com/smartcontractkit/chainlink/v2/core/assets","Test":"TestLink","Elapsed":0}
`

r := strings.NewReader(output)
ts, err := parseOutput(r)
require.NoError(t, err)

assert.Len(t, ts, 1)
assert.Len(t, ts["core/assets"], 1)
assert.Equal(t, ts["core/assets"]["TestLink"], 1)
}

func TestParser_PanicDueToLogging(t *testing.T) {
output := `
{"Time":"2023-09-07T16:01:40.649849+01:00","Action":"output","Package":"github.com/smartcontractkit/chainlink/v2/core/assets","Test":"TestAssets_LinkScanValue","Output":"panic: foo\n"}
Expand Down

0 comments on commit fae227d

Please sign in to comment.