Skip to content

Commit

Permalink
docs: fix up typos (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoVeille committed Apr 18, 2024
1 parent a915386 commit ff9dac1
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.13.1] - 2023-08-04

- Fix failing GoReleaser github action (release notes location).
- Fix failing GoReleaser GitHub action (release notes location).

Summary from [v0.13.0](https://github.com/mfridman/tparse/releases/tag/v0.13.0)

Expand Down
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Options struct {
DisableTableOutput bool

//
// Experiemntal
// Experimental
//

// Compare includes a diff of a previous test output file in the summary table.
Expand Down
2 changes: 1 addition & 1 deletion internal/app/console_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type OutputFormat int

const (
// OutputFormatBasic is a normal table withput a border
// OutputFormatBasic is a normal table without a border
OutputFormatPlain OutputFormat = iota + 1
// OutputFormatBasic is a normal table with border
OutputFormatBasic
Expand Down
2 changes: 1 addition & 1 deletion internal/app/table_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func shortenPackageName(name string, prefix string, maxLength int, trim bool) st

if prefix == "" {
dir, name := path.Split(name)
// For SIV-style imports show the last non-versioned path identifer.
// For SIV-style imports show the last non-versioned path identifier.
// Example: github.com/foo/bar/helper/v3 returns helper/v3
if dir != "" && versionMajorRe.MatchString(name) {
_, subpath := path.Split(path.Clean(dir))
Expand Down
2 changes: 1 addition & 1 deletion internal/app/table_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func getTestsFromPackages(pkg *parse.Package, option TestTableOptions) *packageT
sort.Slice(tests.passed, func(i, j int) bool {
return tests.passed[i].Elapsed() > tests.passed[j].Elapsed()
})
// Optionall, display only the slowest N tests by elapsed time.
// Optional, display only the slowest N tests by elapsed time.
if option.Slow > 0 && len(tests.passed) > option.Slow {
tests.passed = tests.passed[:option.Slow]
}
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ func main() {
Progress: *progressPtr,
Compare: *comparePtr,

// Do not expose publically.
// Do not expose publicly.
DisableTableOutput: false,
}
exitCode, err := app.Run(os.Stdout, options)
if err != nil {
msg := err.Error()
if errors.Is(err, parse.ErrNotParseable) {
msg = "no parseable events: Make sure to run go test with -json flag"
if errors.Is(err, parse.ErrNotParsable) {
msg = "no parsable events: Make sure to run go test with -json flag"
}
fmt.Fprintln(os.Stderr, msg)
}
Expand Down
6 changes: 3 additions & 3 deletions parse/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
failedBuildOrSetupRe = regexp.MustCompile(`^FAIL(.*)\[(build failed|setup failed)\]`)
)

// Event represents a single line of json output from go test with the -json flag.
// Event represents a single line of JSON output from go test with the -json flag.
//
// For more info see, https://golang.org/cmd/test2json and
// https://github.com/golang/go/blob/master/src/cmd/internal/test2json/test2json.go
Expand All @@ -27,7 +27,7 @@ type Event struct {
// Portion of the test's output (standard output and standard error merged together)
Output string

// Time at which the the event occurred, encodes as an RFC3339-format string.
// Time at which the event occurred, encodes as an RFC3339-format string.
// It is conventionally omitted for cached test results.
Time time.Time

Expand Down Expand Up @@ -189,7 +189,7 @@ const (
ActionOutput Action = "output" // test printed output
ActionSkip Action = "skip" // test was skipped or the package contained no tests

// Added in go1.20 to denote the begining of each test program's execution.
// Added in go1.20 to denote the beginning of each test program's execution.
ActionStart Action = "start" // the start at the beginning of each test program's execution
)

Expand Down
28 changes: 14 additions & 14 deletions parse/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strings"
)

// ErrNotParseable indicates the event line was not parseable.
var ErrNotParseable = errors.New("failed to parse")
// ErrNotParsable indicates the event line was not parsable.
var ErrNotParsable = errors.New("failed to parse")

// Process is the entry point to parse. It consumes a reader
// and parses go test output in JSON format until EOF.
Expand All @@ -32,20 +32,20 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {
var started bool
var badLines int
for sc.Scan() {
// Scan up-to 50 lines for a parseable event, if we get one, expect
// Scan up-to 50 lines for a parsable event, if we get one, expect
// no errors to follow until EOF.
e, err := NewEvent(sc.Bytes())
if err != nil {
// We failed to parse a go test JSON event, but there are special cases for failed
// builds, setup, etc. Let's special case these and bubble them up in the summary
// builds, setup, etc. Let special case these and bubble them up in the summary
// if the output belongs to a package.
summary.AddRawEvent(sc.Text())

badLines++
if started || badLines > 50 {
var syntaxError *json.SyntaxError
if errors.As(err, &syntaxError) {
err = fmt.Errorf("line %d json error: %s: %w", badLines, syntaxError.Error(), ErrNotParseable)
err = fmt.Errorf("line %d JSON error: %s: %w", badLines, syntaxError.Error(), ErrNotParsable)
if option.debug {
// In debug mode we can surface a more verbose error message which
// contains the current line number and exact JSON parsing error.
Expand All @@ -61,14 +61,14 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {
}
started = true

// TODO(mf): when running tparse locally it's very useful to see progress for long
// running test suites. Since we have access to the event we can send it on a chan
// TODO(mf): when running tparse locally it's very useful to see progress for long-running
// test suites. Since we have access to the event we can send it on a chan
// or just directly update a spinner-like component. This cannot be run with the
// follow option. Lastly, need to consider what local vs CI behaviour would be like.
// Depending how often the frames update, this could cause a lot of noise, so maybe
// follow option. Lastly, need to consider what local vs CI behavior would be like.
// Depending on how often the frames update, this could cause a lot of noise, so maybe
// we need to expose an interval option, so in CI it would update infrequently.

// Optionally, as test output is piped to us we write the plain
// Optionally, as test output is piped to us, we write the plain
// text Output as if go test was run without the -json flag.
if option.follow && option.w != nil {
fmt.Fprint(option.w, e.Output)
Expand All @@ -84,16 +84,16 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {
if err := sc.Err(); err != nil {
return nil, fmt.Errorf("received scanning error: %w", err)
}
// Entire input has been scanned and no go test json output was found.
// Entire input has been scanned and no go test JSON output was found.
if !started {
return nil, ErrNotParseable
return nil, ErrNotParsable
}

return summary, nil
}

// printProgress prints a single summary line for each PASS or FAIL package.
// This is useful for long running test suites.
// This is useful for long-running test suites.
func printProgress(w io.Writer, e *Event, summary map[string]*Package) {
if !e.LastLine() {
return
Expand Down Expand Up @@ -201,7 +201,7 @@ func (s *GoTestSummary) AddEvent(e *Event) {
pkg.NoTestFiles = true
// Manually mark [no test files] as "pass", because the go test tool reports the
// package Summary action as "skip".
// TODO(mf): revisit this behaviour?
// TODO(mf): revisit this behavior?
pkg.Summary.Package = e.Package
pkg.Summary.Action = ActionPass
case e.NoTestsWarn():
Expand Down
4 changes: 2 additions & 2 deletions tests/cached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func TestPackageCache(t *testing.T) {

for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(intputFile)
inputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(inputFile)
check.NoError(t, err)

summary, err := parse.Process(f)
Expand Down
4 changes: 2 additions & 2 deletions tests/cover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func Test(t *testing.T) {
}
for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(intputFile)
inputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(inputFile)
check.NoError(t, err)

summary, err := parse.Process(f)
Expand Down
8 changes: 4 additions & 4 deletions tests/follow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func TestFollow(t *testing.T) {
{"test_02", nil, 0},
{"test_03", nil, 0},
{"test_04", nil, 0},
{"test_05", parse.ErrNotParseable, 1},
{"test_05", parse.ErrNotParsable, 1},
// build failure in one package
{"test_06", nil, 2},
}
for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName+".jsonl")
inputFile := filepath.Join(base, tc.fileName+".jsonl")
options := app.Options{
FileName: intputFile,
FileName: inputFile,
FollowOutput: true,
DisableTableOutput: true,
}
Expand All @@ -54,7 +54,7 @@ func TestFollow(t *testing.T) {
t.Error("input does not match expected output; diff files in follow dir suffixed with .FAIL to debug")
t.Logf("diff %v %v",
"tests/"+goldenFile+".FAIL",
"tests/"+intputFile+".FAIL",
"tests/"+inputFile+".FAIL",
)
if err := os.WriteFile(goldenFile+".FAIL", buf.Bytes(), 0644); err != nil {
t.Fatal(err)
Expand Down
12 changes: 6 additions & 6 deletions tests/prescan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ func TestPrescan(t *testing.T) {
err error
}{
{"test_01.txt", "want <nil> err", nil},
{"test_02.txt", "want failure after reading >50 lines of non-parseable events", parse.ErrNotParseable},
// logic: unparseable event(s), good event(s), at least one event = fail.
{"test_02.txt", "want failure after reading >50 lines of non-parsable events", parse.ErrNotParsable},
// logic: unparsable event(s), good event(s), at least one event = fail.
// Once we get a good event, we expect only good events to follow until EOF.
{"test_03.txt", "want failure when stream contains a bad event(s) -> good event(s) -> bad event", parse.ErrNotParseable},
{"test_04.txt", "want failure reading <50 lines of non-parseable events", parse.ErrNotParseable},
{"test_03.txt", "want failure when stream contains a bad event(s) -> good event(s) -> bad event", parse.ErrNotParsable},
{"test_04.txt", "want failure reading <50 lines of non-parsable events", parse.ErrNotParsable},
}

for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName)
f, err := os.Open(intputFile)
inputFile := filepath.Join(base, tc.fileName)
f, err := os.Open(inputFile)
check.NoError(t, err)

_, err = parse.Process(f)
Expand Down
4 changes: 2 additions & 2 deletions tests/race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func TestRaceDetected(t *testing.T) {

for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(intputFile)
inputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(inputFile)
check.NoError(t, err)
defer f.Close()

Expand Down
12 changes: 6 additions & 6 deletions tests/sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func TestSortName(t *testing.T) {
}
for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(intputFile)
inputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(inputFile)
check.NoError(t, err)

summary, err := parse.Process(f)
Expand Down Expand Up @@ -112,8 +112,8 @@ func TestSortCoverage(t *testing.T) {
}
for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(intputFile)
inputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(inputFile)
check.NoError(t, err)

summary, err := parse.Process(f)
Expand Down Expand Up @@ -174,8 +174,8 @@ func TestSortElapsed(t *testing.T) {
}
for _, tc := range tt {
t.Run(tc.fileName, func(t *testing.T) {
intputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(intputFile)
inputFile := filepath.Join(base, tc.fileName+".jsonl")
f, err := os.Open(inputFile)
check.NoError(t, err)

summary, err := parse.Process(f)
Expand Down
8 changes: 4 additions & 4 deletions tests/testdata/cover/test_02.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -3132,10 +3132,10 @@
{"Time":"2022-05-23T15:56:16.39256-04:00","Action":"output","Package":"net","Test":"TestSendfileParts","Output":"=== RUN TestSendfileParts\n"}
{"Time":"2022-05-23T15:56:16.39288-04:00","Action":"output","Package":"net","Test":"TestSendfileParts","Output":"--- PASS: TestSendfileParts (0.00s)\n"}
{"Time":"2022-05-23T15:56:16.392893-04:00","Action":"pass","Package":"net","Test":"TestSendfileParts","Elapsed":0}
{"Time":"2022-05-23T15:56:16.3929-04:00","Action":"run","Package":"net","Test":"TestSendfileSeeked"}
{"Time":"2022-05-23T15:56:16.392907-04:00","Action":"output","Package":"net","Test":"TestSendfileSeeked","Output":"=== RUN TestSendfileSeeked\n"}
{"Time":"2022-05-23T15:56:16.393357-04:00","Action":"output","Package":"net","Test":"TestSendfileSeeked","Output":"--- PASS: TestSendfileSeeked (0.00s)\n"}
{"Time":"2022-05-23T15:56:16.393423-04:00","Action":"pass","Package":"net","Test":"TestSendfileSeeked","Elapsed":0}
{"Time":"2022-05-23T15:56:16.3929-04:00","Action":"run","Package":"net","Test":"TestSendfileSought"}
{"Time":"2022-05-23T15:56:16.392907-04:00","Action":"output","Package":"net","Test":"TestSendfileSought","Output":"=== RUN TestSendfileSought\n"}
{"Time":"2022-05-23T15:56:16.393357-04:00","Action":"output","Package":"net","Test":"TestSendfileSought","Output":"--- PASS: TestSendfileSought (0.00s)\n"}
{"Time":"2022-05-23T15:56:16.393423-04:00","Action":"pass","Package":"net","Test":"TestSendfileSought","Elapsed":0}
{"Time":"2022-05-23T15:56:16.393439-04:00","Action":"run","Package":"net","Test":"TestSendfilePipe"}
{"Time":"2022-05-23T15:56:16.393446-04:00","Action":"output","Package":"net","Test":"TestSendfilePipe","Output":"=== RUN TestSendfilePipe\n"}
{"Time":"2022-05-23T15:56:16.393453-04:00","Action":"output","Package":"net","Test":"TestSendfilePipe","Output":"=== PAUSE TestSendfilePipe\n"}
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/failed/test_03.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
{"Time":"2022-05-21T00:01:21.469411-04:00","Action":"output","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan/input03.txt","Output":" prescan_test.go:51: want failure when stream contains a bad event(s) -\u003e good event(s) -\u003e bad event: got err type *fmt.wrapError want *errors.fundamental: line 6 json error: invalid character 'r' looking for beginning of value: failed to parse\n"}
{"Time":"2022-05-21T00:01:21.469419-04:00","Action":"cont","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan/input02.txt"}
{"Time":"2022-05-21T00:01:21.469422-04:00","Action":"output","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan/input02.txt","Output":"=== CONT TestPrescan/input02.txt\n"}
{"Time":"2022-05-21T00:01:21.469525-04:00","Action":"output","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan/input02.txt","Output":" prescan_test.go:51: want failure after reading \u003e50 lines of non-parseable events: got err type *fmt.wrapError want *errors.fundamental: line 51 json error: invalid character 'p' looking for beginning of value: failed to parse\n"}
{"Time":"2022-05-21T00:01:21.469525-04:00","Action":"output","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan/input02.txt","Output":" prescan_test.go:51: want failure after reading \u003e50 lines of non-parsable events: got err type *fmt.wrapError want *errors.fundamental: line 51 json error: invalid character 'p' looking for beginning of value: failed to parse\n"}
{"Time":"2022-05-21T00:01:21.46953-04:00","Action":"output","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan","Output":"--- FAIL: TestPrescan (0.00s)\n"}
{"Time":"2022-05-21T00:01:21.469533-04:00","Action":"output","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan/input01.txt","Output":" --- PASS: TestPrescan/input01.txt (0.00s)\n"}
{"Time":"2022-05-21T00:01:21.469538-04:00","Action":"pass","Package":"github.com/mfridman/tparse/parse","Test":"TestPrescan/input01.txt","Elapsed":0}
Expand Down

0 comments on commit ff9dac1

Please sign in to comment.