Skip to content

Commit

Permalink
Use JSONL format for New Line Delimited JSON (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoVeille committed Apr 16, 2024
1 parent 79399b4 commit a915386
Show file tree
Hide file tree
Showing 50 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/cached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/cover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/follow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions tests/outcome_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}},
}
Expand Down
4 changes: 2 additions & 2 deletions tests/package_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions tests/panic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,38 @@ 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,
"github.com/mfridman/tparse": false,
},
},
{
"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,
"github.com/mfridman/tparse/ignore": false,
},
},
{
"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,
Expand Down
2 changes: 1 addition & 1 deletion tests/race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions tests/sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions tests/summary_counts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a915386

Please sign in to comment.