Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade code to respect new conventions. #111

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions parse/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {

badLines++
if started || badLines > 50 {
switch err.(type) {
case *json.SyntaxError:
err = fmt.Errorf("line %d json error: %s: %w", badLines, err.Error(), ErrNotParseable)
var syntaxError *json.SyntaxError
if errors.As(err, &syntaxError) {
ccoVeille marked this conversation as resolved.
Show resolved Hide resolved
err = fmt.Errorf("line %d json error: %s: %w", badLines, syntaxError.Error(), ErrNotParseable)
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.
fmt.Fprintf(os.Stderr, "debug: %s", err.Error())
}
return nil, err
default:
return nil, err
}
return nil, err
}
if option.follow && option.w != nil {
fmt.Fprintf(option.w, "%s\n", sc.Bytes())
Expand Down
6 changes: 3 additions & 3 deletions tests/follow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parsetest
import (
"bytes"
"errors"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -46,7 +46,7 @@ func TestFollow(t *testing.T) {
}
check.Number(t, gotExitCode, tc.exitCode)
goldenFile := filepath.Join(base, tc.fileName+".golden")
want, err := ioutil.ReadFile(goldenFile)
want, err := os.ReadFile(goldenFile)
if err != nil {
t.Fatal(err)
}
Expand All @@ -56,7 +56,7 @@ func TestFollow(t *testing.T) {
"tests/"+goldenFile+".FAIL",
"tests/"+intputFile+".FAIL",
)
if err := ioutil.WriteFile(goldenFile+".FAIL", buf.Bytes(), 0644); err != nil {
if err := os.WriteFile(goldenFile+".FAIL", buf.Bytes(), 0644); err != nil {
t.Fatal(err)
}
}
Expand Down
Loading