From fae227dad7612b57b57fe898fffd6e8bd86d171d Mon Sep 17 00:00:00 2001 From: Cedric Date: Tue, 12 Sep 2023 18:14:52 +0100 Subject: [PATCH] [fix] Skip non-JSON lines (#10605) --- tools/flakeytests/runner.go | 5 +++++ tools/flakeytests/runner_test.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tools/flakeytests/runner.go b/tools/flakeytests/runner.go index 67ef27fca6d..316a23dcffb 100644 --- a/tools/flakeytests/runner.go +++ b/tools/flakeytests/runner.go @@ -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 } diff --git a/tools/flakeytests/runner_test.go b/tools/flakeytests/runner_test.go index 4aadf916976..be53ec7e8ec 100644 --- a/tools/flakeytests/runner_test.go +++ b/tools/flakeytests/runner_test.go @@ -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"}