From 17ab4e1358a5e27c7b1fd1789f09f911266a94e8 Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Sat, 13 Apr 2024 16:40:30 +0200 Subject: [PATCH] Use JSONL format for New Line Delimited JSON https://en.wikipedia.org/wiki/JSON_streaming --- .github/workflows/ci.yaml | 6 +++--- tests/cached_test.go | 2 +- tests/cover_test.go | 2 +- tests/follow_test.go | 2 +- tests/outcome_test.go | 16 ++++++++-------- tests/package_start_test.go | 4 ++-- tests/panic_test.go | 12 ++++++------ tests/race_test.go | 2 +- tests/sort_test.go | 6 +++--- tests/summary_counts_test.go | 8 ++++---- .../cached/{test_01.json => test_01.jsonl} | 0 .../cached/{test_02.json => test_02.jsonl} | 0 .../cover/{test_01.json => test_01.jsonl} | 0 .../cover/{test_02.json => test_02.jsonl} | 0 .../cover/{test_03.json => test_03.jsonl} | 0 .../{elapsed_test.json => elapsed_test.jsonl} | 0 .../failed/{test_01.json => test_01.jsonl} | 0 .../failed/{test_02.json => test_02.jsonl} | 0 .../failed/{test_03.json => test_03.jsonl} | 0 .../failed/{test_04.json => test_04.jsonl} | 0 .../follow/{test_01.json => test_01.jsonl} | 0 .../follow/{test_02.json => test_02.jsonl} | 0 .../follow/{test_03.json => test_03.jsonl} | 0 .../follow/{test_04.json => test_04.jsonl} | 0 .../follow/{test_05.json => test_05.jsonl} | 0 .../follow/{test_06.json => test_06.jsonl} | 0 ...tart_action.json => go120_start_action.jsonl} | 0 .../{metrics_test.json => metrics_test.jsonl} | 0 .../outcome/{test_01.json => test_01.jsonl} | 0 .../outcome/{test_02.json => test_02.jsonl} | 0 .../outcome/{test_03.json => test_03.jsonl} | 0 .../outcome/{test_04.json => test_04.jsonl} | 0 .../outcome/{test_05.json => test_05.jsonl} | 0 .../outcome/{test_06.json => test_06.jsonl} | 0 .../outcome/{test_07.json => test_07.jsonl} | 0 .../outcome/{test_08.json => test_08.jsonl} | 0 .../panic/{test_01.json => test_01.jsonl} | 0 .../panic/{test_02.json => test_02.jsonl} | 0 .../panic/{test_03.json => test_03.jsonl} | 0 .../panic/{test_04.json => test_04.jsonl} | 0 .../panic/{test_05.json => test_05.jsonl} | 0 .../panic/{test_06.json => test_06.jsonl} | 0 .../race/{test_01.json => test_01.jsonl} | 0 .../race/{test_02.json => test_02.jsonl} | 0 .../race/{test_03.json => test_03.jsonl} | 0 .../race/{test_04.json => test_04.jsonl} | 0 .../race/{test_05.json => test_05.jsonl} | 0 .../race/{test_06.json => test_06.jsonl} | 0 .../race/{test_07.json => test_07.jsonl} | 0 .../race/{test_08.json => test_08.jsonl} | 0 50 files changed, 30 insertions(+), 30 deletions(-) rename tests/testdata/cached/{test_01.json => test_01.jsonl} (100%) rename tests/testdata/cached/{test_02.json => test_02.jsonl} (100%) rename tests/testdata/cover/{test_01.json => test_01.jsonl} (100%) rename tests/testdata/cover/{test_02.json => test_02.jsonl} (100%) rename tests/testdata/cover/{test_03.json => test_03.jsonl} (100%) rename tests/testdata/{elapsed_test.json => elapsed_test.jsonl} (100%) rename tests/testdata/failed/{test_01.json => test_01.jsonl} (100%) rename tests/testdata/failed/{test_02.json => test_02.jsonl} (100%) rename tests/testdata/failed/{test_03.json => test_03.jsonl} (100%) rename tests/testdata/failed/{test_04.json => test_04.jsonl} (100%) rename tests/testdata/follow/{test_01.json => test_01.jsonl} (100%) rename tests/testdata/follow/{test_02.json => test_02.jsonl} (100%) rename tests/testdata/follow/{test_03.json => test_03.jsonl} (100%) rename tests/testdata/follow/{test_04.json => test_04.jsonl} (100%) rename tests/testdata/follow/{test_05.json => test_05.jsonl} (100%) rename tests/testdata/follow/{test_06.json => test_06.jsonl} (100%) rename tests/testdata/{go120_start_action.json => go120_start_action.jsonl} (100%) rename tests/testdata/{metrics_test.json => metrics_test.jsonl} (100%) rename tests/testdata/outcome/{test_01.json => test_01.jsonl} (100%) rename tests/testdata/outcome/{test_02.json => test_02.jsonl} (100%) rename tests/testdata/outcome/{test_03.json => test_03.jsonl} (100%) rename tests/testdata/outcome/{test_04.json => test_04.jsonl} (100%) rename tests/testdata/outcome/{test_05.json => test_05.jsonl} (100%) rename tests/testdata/outcome/{test_06.json => test_06.jsonl} (100%) rename tests/testdata/outcome/{test_07.json => test_07.jsonl} (100%) rename tests/testdata/outcome/{test_08.json => test_08.jsonl} (100%) rename tests/testdata/panic/{test_01.json => test_01.jsonl} (100%) rename tests/testdata/panic/{test_02.json => test_02.jsonl} (100%) rename tests/testdata/panic/{test_03.json => test_03.jsonl} (100%) rename tests/testdata/panic/{test_04.json => test_04.jsonl} (100%) rename tests/testdata/panic/{test_05.json => test_05.jsonl} (100%) rename tests/testdata/panic/{test_06.json => test_06.jsonl} (100%) rename tests/testdata/race/{test_01.json => test_01.jsonl} (100%) rename tests/testdata/race/{test_02.json => test_02.jsonl} (100%) rename tests/testdata/race/{test_03.json => test_03.jsonl} (100%) rename tests/testdata/race/{test_04.json => test_04.jsonl} (100%) rename tests/testdata/race/{test_05.json => test_05.jsonl} (100%) rename tests/testdata/race/{test_06.json => test_06.jsonl} (100%) rename tests/testdata/race/{test_07.json => test_07.jsonl} (100%) rename tests/testdata/race/{test_08.json => test_08.jsonl} (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2727697..25dc5cd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,10 +29,10 @@ jobs: - name: Run tests with GITHUB_STEP_SUMMARY # Note the use of || true. This so the job doesn't fail at that line. We want to preserve -follow # as part of the test output, but not output it to the summary page, which is done in the proceeding - # command when we parse the output.json file. + # command when we parse the output.jsonl file. run: | go test -v -count=1 -race ./... -json -coverpkg github.com/mfridman/tparse/parse \ - | tee output.json | ./tparse -notests -follow -all || true - ./tparse -format markdown -file output.json -all -slow 20 > $GITHUB_STEP_SUMMARY + | tee output.jsonl | ./tparse -notests -follow -all || true + ./tparse -format markdown -file output.jsonl -all -slow 20 > $GITHUB_STEP_SUMMARY - name: Run tparse w/ std lib run: go test -count=1 fmt strings bytes bufio crypto log mime sort time -json -cover | ./tparse -follow -all diff --git a/tests/cached_test.go b/tests/cached_test.go index 497b70d..d5414e3 100644 --- a/tests/cached_test.go +++ b/tests/cached_test.go @@ -54,7 +54,7 @@ func TestPackageCache(t *testing.T) { for _, tc := range tt { t.Run(tc.fileName, func(t *testing.T) { - intputFile := filepath.Join(base, tc.fileName+".json") + intputFile := filepath.Join(base, tc.fileName+".jsonl") f, err := os.Open(intputFile) check.NoError(t, err) diff --git a/tests/cover_test.go b/tests/cover_test.go index 56e0fbe..78fbe0a 100644 --- a/tests/cover_test.go +++ b/tests/cover_test.go @@ -57,7 +57,7 @@ func Test(t *testing.T) { } for _, tc := range tt { t.Run(tc.fileName, func(t *testing.T) { - intputFile := filepath.Join(base, tc.fileName+".json") + intputFile := filepath.Join(base, tc.fileName+".jsonl") f, err := os.Open(intputFile) check.NoError(t, err) diff --git a/tests/follow_test.go b/tests/follow_test.go index aaf5c4c..7ed5c1f 100644 --- a/tests/follow_test.go +++ b/tests/follow_test.go @@ -33,7 +33,7 @@ func TestFollow(t *testing.T) { } for _, tc := range tt { t.Run(tc.fileName, func(t *testing.T) { - intputFile := filepath.Join(base, tc.fileName+".json") + intputFile := filepath.Join(base, tc.fileName+".jsonl") options := app.Options{ FileName: intputFile, FollowOutput: true, diff --git a/tests/outcome_test.go b/tests/outcome_test.go index 7b06e66..f81c158 100644 --- a/tests/outcome_test.go +++ b/tests/outcome_test.go @@ -21,10 +21,10 @@ func TestFinalOutcome(t *testing.T) { exitCode int registry }{ - {"test_01.json", 1, registry{ + {"test_01.jsonl", 1, registry{ "github.com/mfridman/tparse/tests": parse.ActionFail, }}, - {"test_02.json", 1, registry{ + {"test_02.jsonl", 1, registry{ "github.com/astromail/rover/tests": parse.ActionFail, "github.com/astromail/rover/cmd/roverd": parse.ActionPass, "github.com/astromail/rover/smtp": parse.ActionPass, @@ -33,22 +33,22 @@ func TestFinalOutcome(t *testing.T) { "github.com/astromail/rover/storage/badger": parse.ActionPass, "github.com/astromail/rover": parse.ActionPass, }}, - {"test_03.json", 0, registry{ + {"test_03.jsonl", 0, registry{ "fmt": parse.ActionPass, }}, - {"test_04.json", 0, registry{ + {"test_04.jsonl", 0, registry{ "github.com/astromail/rover/tests": parse.ActionPass, }}, - {"test_05.json", 0, registry{ + {"test_05.jsonl", 0, registry{ "github.com/astromail/rover/tests": parse.ActionPass, }}, - {"test_06.json", 0, registry{ + {"test_06.jsonl", 0, registry{ "fmt": parse.ActionPass, }}, - {"test_07.json", 0, registry{ + {"test_07.jsonl", 0, registry{ "debug/errorcause": parse.ActionPass, }}, - {"test_08.json", 0, registry{ + {"test_08.jsonl", 0, registry{ "github.com/awesome/pkg": parse.ActionPass, }}, } diff --git a/tests/package_start_test.go b/tests/package_start_test.go index 861f43d..9be48a2 100644 --- a/tests/package_start_test.go +++ b/tests/package_start_test.go @@ -12,7 +12,7 @@ import ( func TestPackageStartTime(t *testing.T) { t.Parallel() - // This test depends on go120_start_action.json, which contains test output from go1.20 + // This test depends on go120_start_action.jsonl, which contains test output from go1.20 expected := map[string]string{ "github.com/pressly/goose/v4": "2023-05-28T18:36:01.280967-04:00", @@ -28,7 +28,7 @@ func TestPackageStartTime(t *testing.T) { "github.com/pressly/goose/v4/internal/testdb": "2023-05-28T18:36:01.446973-04:00", } - fileName := "./testdata/go120_start_action.json" + fileName := "./testdata/go120_start_action.jsonl" f, err := os.Open(fileName) check.NoError(t, err) defer f.Close() diff --git a/tests/panic_test.go b/tests/panic_test.go index 7ef1818..4acc543 100644 --- a/tests/panic_test.go +++ b/tests/panic_test.go @@ -22,22 +22,22 @@ func TestPanic(t *testing.T) { expected }{ { - "test_01.json", expected{ + "test_01.jsonl", expected{ "github.com/pressly/goose/v3/tests/e2e": true, }, }, { - "test_02.json", expected{ + "test_02.jsonl", expected{ "github.com/mfridman/tparse/parse": true, }, }, { - "test_03.json", expected{ + "test_03.jsonl", expected{ "github.com/mfridman/tparse/tests": true, }, }, { - "test_04.json", expected{ + "test_04.jsonl", expected{ "github.com/mfridman/tparse/tests": true, "github.com/mfridman/tparse/ignore": false, "github.com/mfridman/tparse/parse": false, @@ -45,7 +45,7 @@ func TestPanic(t *testing.T) { }, }, { - "test_05.json", expected{ + "test_05.jsonl", expected{ "github.com/mfridman/tparse/tests": true, "github.com/mfridman/tparse/parse": false, "github.com/mfridman/tparse": false, @@ -53,7 +53,7 @@ func TestPanic(t *testing.T) { }, }, { - "test_06.json", expected{ + "test_06.jsonl", expected{ "github.com/mfridman/tparse/tests": false, "github.com/mfridman/tparse/parse": true, "github.com/mfridman/tparse": false, diff --git a/tests/race_test.go b/tests/race_test.go index 38fdbd1..fd5c2d9 100644 --- a/tests/race_test.go +++ b/tests/race_test.go @@ -55,7 +55,7 @@ func TestRaceDetected(t *testing.T) { for _, tc := range tt { t.Run(tc.fileName, func(t *testing.T) { - intputFile := filepath.Join(base, tc.fileName+".json") + intputFile := filepath.Join(base, tc.fileName+".jsonl") f, err := os.Open(intputFile) check.NoError(t, err) defer f.Close() diff --git a/tests/sort_test.go b/tests/sort_test.go index 464fa35..3657b6e 100644 --- a/tests/sort_test.go +++ b/tests/sort_test.go @@ -50,7 +50,7 @@ func TestSortName(t *testing.T) { } for _, tc := range tt { t.Run(tc.fileName, func(t *testing.T) { - intputFile := filepath.Join(base, tc.fileName+".json") + intputFile := filepath.Join(base, tc.fileName+".jsonl") f, err := os.Open(intputFile) check.NoError(t, err) @@ -112,7 +112,7 @@ func TestSortCoverage(t *testing.T) { } for _, tc := range tt { t.Run(tc.fileName, func(t *testing.T) { - intputFile := filepath.Join(base, tc.fileName+".json") + intputFile := filepath.Join(base, tc.fileName+".jsonl") f, err := os.Open(intputFile) check.NoError(t, err) @@ -174,7 +174,7 @@ func TestSortElapsed(t *testing.T) { } for _, tc := range tt { t.Run(tc.fileName, func(t *testing.T) { - intputFile := filepath.Join(base, tc.fileName+".json") + intputFile := filepath.Join(base, tc.fileName+".jsonl") f, err := os.Open(intputFile) check.NoError(t, err) diff --git a/tests/summary_counts_test.go b/tests/summary_counts_test.go index 7b57494..6c1fda9 100644 --- a/tests/summary_counts_test.go +++ b/tests/summary_counts_test.go @@ -11,10 +11,10 @@ import ( func TestSummaryCounts(t *testing.T) { t.Parallel() - // This test depends on metrics_test.json, which contains the output of 9 std lib packages: + // This test depends on metrics_test.jsonl, which contains the output of 9 std lib packages: // go test -count=1 fmt strings bytes bufio crypto log mime sort time -json - fileName := "./testdata/metrics_test.json" + fileName := "./testdata/metrics_test.jsonl" f, err := os.Open(fileName) check.NoError(t, err) @@ -80,7 +80,7 @@ func TestSummaryCounts(t *testing.T) { func TestElapsed(t *testing.T) { t.Parallel() - // This test depends on elapsed_test.json, which contains the output of 2 std lib tests + // This test depends on elapsed_test.jsonl, which contains the output of 2 std lib tests // with known elapsed time. // go test -count=1 strings -run="^(TestCompareStrings|TestCaseConsistency$)" -json -cover @@ -89,7 +89,7 @@ func TestElapsed(t *testing.T) { "TestCaseConsistency": 0.17, } - fileName := "./testdata/elapsed_test.json" + fileName := "./testdata/elapsed_test.jsonl" f, err := os.Open(fileName) check.NoError(t, err) defer f.Close() diff --git a/tests/testdata/cached/test_01.json b/tests/testdata/cached/test_01.jsonl similarity index 100% rename from tests/testdata/cached/test_01.json rename to tests/testdata/cached/test_01.jsonl diff --git a/tests/testdata/cached/test_02.json b/tests/testdata/cached/test_02.jsonl similarity index 100% rename from tests/testdata/cached/test_02.json rename to tests/testdata/cached/test_02.jsonl diff --git a/tests/testdata/cover/test_01.json b/tests/testdata/cover/test_01.jsonl similarity index 100% rename from tests/testdata/cover/test_01.json rename to tests/testdata/cover/test_01.jsonl diff --git a/tests/testdata/cover/test_02.json b/tests/testdata/cover/test_02.jsonl similarity index 100% rename from tests/testdata/cover/test_02.json rename to tests/testdata/cover/test_02.jsonl diff --git a/tests/testdata/cover/test_03.json b/tests/testdata/cover/test_03.jsonl similarity index 100% rename from tests/testdata/cover/test_03.json rename to tests/testdata/cover/test_03.jsonl diff --git a/tests/testdata/elapsed_test.json b/tests/testdata/elapsed_test.jsonl similarity index 100% rename from tests/testdata/elapsed_test.json rename to tests/testdata/elapsed_test.jsonl diff --git a/tests/testdata/failed/test_01.json b/tests/testdata/failed/test_01.jsonl similarity index 100% rename from tests/testdata/failed/test_01.json rename to tests/testdata/failed/test_01.jsonl diff --git a/tests/testdata/failed/test_02.json b/tests/testdata/failed/test_02.jsonl similarity index 100% rename from tests/testdata/failed/test_02.json rename to tests/testdata/failed/test_02.jsonl diff --git a/tests/testdata/failed/test_03.json b/tests/testdata/failed/test_03.jsonl similarity index 100% rename from tests/testdata/failed/test_03.json rename to tests/testdata/failed/test_03.jsonl diff --git a/tests/testdata/failed/test_04.json b/tests/testdata/failed/test_04.jsonl similarity index 100% rename from tests/testdata/failed/test_04.json rename to tests/testdata/failed/test_04.jsonl diff --git a/tests/testdata/follow/test_01.json b/tests/testdata/follow/test_01.jsonl similarity index 100% rename from tests/testdata/follow/test_01.json rename to tests/testdata/follow/test_01.jsonl diff --git a/tests/testdata/follow/test_02.json b/tests/testdata/follow/test_02.jsonl similarity index 100% rename from tests/testdata/follow/test_02.json rename to tests/testdata/follow/test_02.jsonl diff --git a/tests/testdata/follow/test_03.json b/tests/testdata/follow/test_03.jsonl similarity index 100% rename from tests/testdata/follow/test_03.json rename to tests/testdata/follow/test_03.jsonl diff --git a/tests/testdata/follow/test_04.json b/tests/testdata/follow/test_04.jsonl similarity index 100% rename from tests/testdata/follow/test_04.json rename to tests/testdata/follow/test_04.jsonl diff --git a/tests/testdata/follow/test_05.json b/tests/testdata/follow/test_05.jsonl similarity index 100% rename from tests/testdata/follow/test_05.json rename to tests/testdata/follow/test_05.jsonl diff --git a/tests/testdata/follow/test_06.json b/tests/testdata/follow/test_06.jsonl similarity index 100% rename from tests/testdata/follow/test_06.json rename to tests/testdata/follow/test_06.jsonl diff --git a/tests/testdata/go120_start_action.json b/tests/testdata/go120_start_action.jsonl similarity index 100% rename from tests/testdata/go120_start_action.json rename to tests/testdata/go120_start_action.jsonl diff --git a/tests/testdata/metrics_test.json b/tests/testdata/metrics_test.jsonl similarity index 100% rename from tests/testdata/metrics_test.json rename to tests/testdata/metrics_test.jsonl diff --git a/tests/testdata/outcome/test_01.json b/tests/testdata/outcome/test_01.jsonl similarity index 100% rename from tests/testdata/outcome/test_01.json rename to tests/testdata/outcome/test_01.jsonl diff --git a/tests/testdata/outcome/test_02.json b/tests/testdata/outcome/test_02.jsonl similarity index 100% rename from tests/testdata/outcome/test_02.json rename to tests/testdata/outcome/test_02.jsonl diff --git a/tests/testdata/outcome/test_03.json b/tests/testdata/outcome/test_03.jsonl similarity index 100% rename from tests/testdata/outcome/test_03.json rename to tests/testdata/outcome/test_03.jsonl diff --git a/tests/testdata/outcome/test_04.json b/tests/testdata/outcome/test_04.jsonl similarity index 100% rename from tests/testdata/outcome/test_04.json rename to tests/testdata/outcome/test_04.jsonl diff --git a/tests/testdata/outcome/test_05.json b/tests/testdata/outcome/test_05.jsonl similarity index 100% rename from tests/testdata/outcome/test_05.json rename to tests/testdata/outcome/test_05.jsonl diff --git a/tests/testdata/outcome/test_06.json b/tests/testdata/outcome/test_06.jsonl similarity index 100% rename from tests/testdata/outcome/test_06.json rename to tests/testdata/outcome/test_06.jsonl diff --git a/tests/testdata/outcome/test_07.json b/tests/testdata/outcome/test_07.jsonl similarity index 100% rename from tests/testdata/outcome/test_07.json rename to tests/testdata/outcome/test_07.jsonl diff --git a/tests/testdata/outcome/test_08.json b/tests/testdata/outcome/test_08.jsonl similarity index 100% rename from tests/testdata/outcome/test_08.json rename to tests/testdata/outcome/test_08.jsonl diff --git a/tests/testdata/panic/test_01.json b/tests/testdata/panic/test_01.jsonl similarity index 100% rename from tests/testdata/panic/test_01.json rename to tests/testdata/panic/test_01.jsonl diff --git a/tests/testdata/panic/test_02.json b/tests/testdata/panic/test_02.jsonl similarity index 100% rename from tests/testdata/panic/test_02.json rename to tests/testdata/panic/test_02.jsonl diff --git a/tests/testdata/panic/test_03.json b/tests/testdata/panic/test_03.jsonl similarity index 100% rename from tests/testdata/panic/test_03.json rename to tests/testdata/panic/test_03.jsonl diff --git a/tests/testdata/panic/test_04.json b/tests/testdata/panic/test_04.jsonl similarity index 100% rename from tests/testdata/panic/test_04.json rename to tests/testdata/panic/test_04.jsonl diff --git a/tests/testdata/panic/test_05.json b/tests/testdata/panic/test_05.jsonl similarity index 100% rename from tests/testdata/panic/test_05.json rename to tests/testdata/panic/test_05.jsonl diff --git a/tests/testdata/panic/test_06.json b/tests/testdata/panic/test_06.jsonl similarity index 100% rename from tests/testdata/panic/test_06.json rename to tests/testdata/panic/test_06.jsonl diff --git a/tests/testdata/race/test_01.json b/tests/testdata/race/test_01.jsonl similarity index 100% rename from tests/testdata/race/test_01.json rename to tests/testdata/race/test_01.jsonl diff --git a/tests/testdata/race/test_02.json b/tests/testdata/race/test_02.jsonl similarity index 100% rename from tests/testdata/race/test_02.json rename to tests/testdata/race/test_02.jsonl diff --git a/tests/testdata/race/test_03.json b/tests/testdata/race/test_03.jsonl similarity index 100% rename from tests/testdata/race/test_03.json rename to tests/testdata/race/test_03.jsonl diff --git a/tests/testdata/race/test_04.json b/tests/testdata/race/test_04.jsonl similarity index 100% rename from tests/testdata/race/test_04.json rename to tests/testdata/race/test_04.jsonl diff --git a/tests/testdata/race/test_05.json b/tests/testdata/race/test_05.jsonl similarity index 100% rename from tests/testdata/race/test_05.json rename to tests/testdata/race/test_05.jsonl diff --git a/tests/testdata/race/test_06.json b/tests/testdata/race/test_06.jsonl similarity index 100% rename from tests/testdata/race/test_06.json rename to tests/testdata/race/test_06.jsonl diff --git a/tests/testdata/race/test_07.json b/tests/testdata/race/test_07.jsonl similarity index 100% rename from tests/testdata/race/test_07.json rename to tests/testdata/race/test_07.jsonl diff --git a/tests/testdata/race/test_08.json b/tests/testdata/race/test_08.jsonl similarity index 100% rename from tests/testdata/race/test_08.json rename to tests/testdata/race/test_08.jsonl