Skip to content

Commit b66946f

Browse files
authored
testscript: remove errgo dependency (#155)
There's no need to use it and every dependency lost is good.
1 parent f3cb5c2 commit b66946f

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ module github.com/rogpeppe/go-internal
22

33
go 1.16
44

5-
require (
6-
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
7-
gopkg.in/errgo.v2 v2.1.0
8-
)
5+
require github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e

go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
2-
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
3-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
4-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
5-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
61
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=
72
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
8-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
9-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10-
gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=
11-
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=

testscript/cover.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package testscript
66

77
import (
88
"bufio"
9+
"errors"
910
"fmt"
1011
"io"
1112
"os"
@@ -15,8 +16,6 @@ import (
1516
"strings"
1617
"sync/atomic"
1718
"testing"
18-
19-
"gopkg.in/errgo.v2/fmt/errors"
2019
)
2120

2221
// mergeCoverProfile merges the coverage information in f into
@@ -30,10 +29,10 @@ func mergeCoverProfile(cover *testing.Cover, path string) error {
3029
defer f.Close()
3130
scanner, err := newProfileScanner(f)
3231
if err != nil {
33-
return errors.Wrap(err)
32+
return err
3433
}
3534
if scanner.Mode() != testing.CoverMode() {
36-
return errors.Newf("unexpected coverage mode in subcommand")
35+
return errors.New("unexpected coverage mode in subcommand")
3736
}
3837
if cover.Mode == "" {
3938
cover.Mode = scanner.Mode()
@@ -83,7 +82,7 @@ func mergeCoverProfile(cover *testing.Cover, path string) error {
8382
}
8483
flush()
8584
if scanner.Err() != nil {
86-
return errors.Notef(err, nil, "error scanning profile")
85+
return fmt.Errorf("error scanning profile: %v", err)
8786
}
8887
return nil
8988
}
@@ -104,7 +103,7 @@ func finalizeCoverProfile(dir string) error {
104103
}
105104
return nil
106105
}); err != nil {
107-
return errors.Wrap(err)
106+
return err
108107
}
109108
if err := os.RemoveAll(dir); err != nil {
110109
// The RemoveAll seems to fail very rarely, with messages like
@@ -116,7 +115,7 @@ func finalizeCoverProfile(dir string) error {
116115
}
117116
return nil
118117
})
119-
return errors.Wrap(err)
118+
return err
120119
}
121120

122121
// We need to include our own top-level coverage profile too.
@@ -128,18 +127,18 @@ func finalizeCoverProfile(dir string) error {
128127
// Finally, write the resulting merged profile.
129128
f, err := os.Create(cprof)
130129
if err != nil {
131-
return errors.Notef(err, nil, "cannot create cover profile")
130+
return fmt.Errorf("cannot create cover profile: %v", err)
132131
}
133132
defer f.Close()
134133
w := bufio.NewWriter(f)
135134
if err := writeCoverProfile1(w, cover); err != nil {
136-
return errors.Wrap(err)
135+
return err
137136
}
138137
if err := w.Flush(); err != nil {
139-
return errors.Wrap(err)
138+
return err
140139
}
141140
if err := f.Close(); err != nil {
142-
return errors.Wrap(err)
141+
return err
143142
}
144143
return nil
145144
}
@@ -164,7 +163,7 @@ func writeCoverProfile1(w io.Writer, cover testing.Cover) error {
164163
count,
165164
)
166165
if err != nil {
167-
return errors.Wrap(err)
166+
return err
168167
}
169168
}
170169
}
@@ -207,7 +206,7 @@ func newProfileScanner(r io.Reader) (*profileScanner, error) {
207206
// encoding/base64/base64.go:34.44,37.40 3 1
208207
// where the fields are: name.go:line.column,line.column numberOfStatements count
209208
if !s.scanner.Scan() {
210-
return nil, errors.Newf("no lines found in profile: %v", s.Err())
209+
return nil, fmt.Errorf("no lines found in profile: %v", s.Err())
211210
}
212211
line := s.scanner.Text()
213212
mode := strings.TrimPrefix(line, "mode: ")
@@ -263,7 +262,7 @@ func (s *profileScanner) Scan() bool {
263262
}
264263
m := profileLineRe.FindStringSubmatch(s.scanner.Text())
265264
if m == nil {
266-
s.err = errors.Newf("line %q doesn't match expected format %v", m, profileLineRe)
265+
s.err = fmt.Errorf("line %q doesn't match expected format %v", m, profileLineRe)
267266
return false
268267
}
269268
s.filename = m[1]

0 commit comments

Comments
 (0)