Skip to content

Commit 0f3c0d4

Browse files
chore(deps): bump gotest.tools/gotestsum from 1.7.0 to 1.8.0 in /tools
Bumps [gotest.tools/gotestsum](https://github.com/gotestyourself/gotestsum) from 1.7.0 to 1.8.0. - [Release notes](https://github.com/gotestyourself/gotestsum/releases) - [Changelog](https://github.com/gotestyourself/gotestsum/blob/main/.goreleaser.yml) - [Commits](gotestyourself/gotestsum@v1.7.0...v1.8.0) --- updated-dependencies: - dependency-name: gotest.tools/gotestsum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
1 parent 68464f7 commit 0f3c0d4

File tree

13 files changed

+109
-53
lines changed

13 files changed

+109
-53
lines changed

tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/mattn/goveralls v0.0.11
1111
github.com/obalunenko/coverbadger v1.2.0
1212
golang.org/x/tools v0.1.10
13-
gotest.tools/gotestsum v1.7.0
13+
gotest.tools/gotestsum v1.8.0
1414
)
1515

1616
require (

tools/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,8 +1815,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
18151815
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
18161816
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
18171817
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1818-
gotest.tools/gotestsum v1.7.0 h1:RwpqwwFKBAa2h+F6pMEGpE707Edld0etUD3GhqqhDNc=
1819-
gotest.tools/gotestsum v1.7.0/go.mod h1:V1m4Jw3eBerhI/A6qCxUE07RnCg7ACkKj9BYcAm09V8=
1818+
gotest.tools/gotestsum v1.8.0 h1:ltj5KWhbQjt1Yx+IPBj0Dk2HVDUs9OlLmGC2JvivTMo=
1819+
gotest.tools/gotestsum v1.8.0/go.mod h1:ctqdxBSCPv80kAFjYvFNpPntBrE5HAQnLiOKBGLmOBs=
18201820
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
18211821
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
18221822
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

tools/vendor/gotest.tools/gotestsum/.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ linters-settings:
1010
issues:
1111
exclude-use-default: false
1212
exclude-rules:
13-
- linters: [golint]
13+
- linters: [revive]
1414
text: 'should have comment .*or be unexported'
1515
- linters: [stylecheck]
1616
text: 'ST1000: at least one file in a package should have a package comment'
@@ -33,7 +33,6 @@ linters:
3333
- gocyclo
3434
- gofmt
3535
- goimports
36-
- golint
3736
- gosimple
3837
- govet
3938
- ineffassign
@@ -42,6 +41,7 @@ linters:
4241
- misspell
4342
- nakedret
4443
- prealloc
44+
- revive
4545
- staticcheck
4646
- structcheck
4747
- stylecheck

tools/vendor/gotest.tools/gotestsum/README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ See [documentation](#documentation).
1010
## Install
1111

1212
Download a binary from [releases](https://github.com/gotestyourself/gotestsum/releases), or build from
13-
source with `go get gotest.tools/gotestsum`.
13+
source with `go install gotest.tools/gotestsum@latest`. With `go` version before 1.17, use `go get gotest.tools/gotestsum`.
1414

1515
## Demo
1616
A demonstration of three `--format` options.
@@ -152,6 +152,15 @@ example `notify` command only works on macOS with
152152
gotestsum --post-run-command notify
153153
```
154154

155+
**Example: command with flags**
156+
157+
Possitional arguments or command line flags can be passed to the `--post-run-command` by
158+
quoting the whole command.
159+
160+
```
161+
gotestsum --post-run-command "notify me --date"
162+
```
163+
155164
### Re-running failed tests
156165

157166
When the `--rerun-fails` flag is set, `gotestsum` will re-run any failed tests.
@@ -225,13 +234,18 @@ stdout and stderr output:
225234

226235
* The stdout produced by the script must only contain the `test2json` output, or
227236
`gotestsum` will fail. If it isn't possible to change the script to avoid
228-
non-JSON output, you can use `--ignore-non-json-output-lines` to ignore
229-
non-JSON lines and write them to `gotestsum`'s stderr instead.
237+
non-JSON output, you can use `--ignore-non-json-output-lines` (added in version 1.7.0)
238+
to ignore non-JSON lines and write them to `gotestsum`'s stderr instead.
230239
* Any stderr produced by the script will be considered an error (this behaviour
231240
is necessary because package build errors are only reported by writting to
232241
stderr, not the `test2json` stdout). Any stderr produced by tests is not
233242
considered an error (it will be in the `test2json` stdout).
234243

244+
**Example: accept intput from stdin**
245+
```
246+
cat out.json | gotestsum --raw-command -- cat
247+
```
248+
235249
**Example: run tests with profiling enabled**
236250

237251
Using a `profile.sh` script like this:
@@ -334,15 +348,19 @@ directory will be watched. Use the `--packages` flag to specify a different list
334348
While in watch mode, pressing some keys will perform an action:
335349

336350
* `r` will run tests for the previous event.
351+
Added in version 1.6.1.
337352
* `d` will run tests for the previous event using `dlv test`, allowing you to
338353
debug a test failure using [delve]. A breakpoint will automatically be added at
339354
the first line of any tests which failed in the previous run. Additional
340355
breakpoints can be added with [`runtime.Breakpoint`](https://golang.org/pkg/runtime/#Breakpoint)
341356
or by using the delve command prompt.
357+
Added in version 1.6.1.
342358
* `a` will run tests for all packages, by using `./...` as the package selector.
359+
Added in version 1.7.0.
343360
* `l` will scan the directory list again, and if there are any new directories
344361
which contain a file with a `.go` extension, they will be added to the watch
345362
list.
363+
Added in version 1.7.0.
346364

347365
Note that [delve] must be installed in order to use debug (`d`).
348366

tools/vendor/gotest.tools/gotestsum/cmd/handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"os"
77
"os/exec"
8+
"path/filepath"
89

910
"github.com/pkg/errors"
1011
"gotest.tools/gotestsum/internal/junitxml"
@@ -68,6 +69,7 @@ func newEventHandler(opts *options) (*eventHandler, error) {
6869
}
6970
var err error
7071
if opts.jsonFile != "" {
72+
_ = os.MkdirAll(filepath.Dir(opts.jsonFile), 0o755)
7173
handler.jsonFile, err = os.Create(opts.jsonFile)
7274
if err != nil {
7375
return handler, errors.Wrap(err, "failed to open JSON file")
@@ -80,6 +82,7 @@ func writeJUnitFile(opts *options, execution *testjson.Execution) error {
8082
if opts.junitFile == "" {
8183
return nil
8284
}
85+
_ = os.MkdirAll(filepath.Dir(opts.junitFile), 0o755)
8386
junitFile, err := os.Create(opts.junitFile)
8487
if err != nil {
8588
return fmt.Errorf("failed to open JUnit file: %v", err)

tools/vendor/gotest.tools/gotestsum/cmd/main.go

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"os/exec"
99
"os/signal"
1010
"strings"
11+
"sync/atomic"
12+
"syscall"
1113

1214
"github.com/dnephin/pflag"
1315
"github.com/fatih/color"
@@ -46,8 +48,8 @@ func setupFlags(name string) (*pflag.FlagSet, *options) {
4648
junitTestCaseClassnameFormat: &junitFieldFormatValue{},
4749
junitTestSuiteNameFormat: &junitFieldFormatValue{},
4850
postRunHookCmd: &commandValue{},
49-
stdout: os.Stdout,
50-
stderr: os.Stderr,
51+
stdout: color.Output,
52+
stderr: color.Error,
5153
}
5254
flags := pflag.NewFlagSet(name, pflag.ContinueOnError)
5355
flags.SetInterspersed(false)
@@ -65,7 +67,7 @@ func setupFlags(name string) (*pflag.FlagSet, *options) {
6567
flags.StringVar(&opts.jsonFile, "jsonfile",
6668
lookEnvWithDefault("GOTESTSUM_JSONFILE", ""),
6769
"write all TestEvents to file")
68-
flags.BoolVar(&opts.noColor, "no-color", color.NoColor, "disable color output")
70+
flags.BoolVar(&opts.noColor, "no-color", defaultNoColor, "disable color output")
6971

7072
flags.Var(opts.hideSummary, "no-summary",
7173
"do not print summary of: "+testjson.SummarizeAll.String())
@@ -126,6 +128,7 @@ Formats:
126128
127129
Commands:
128130
tool tools for working with test2json output
131+
help print this help next
129132
`)
130133
}
131134

@@ -172,6 +175,13 @@ func (o options) Validate() error {
172175
return nil
173176
}
174177

178+
var defaultNoColor = func() bool {
179+
if os.Getenv("GITHUB_ACTIONS") == "true" {
180+
return false
181+
}
182+
return color.NoColor
183+
}()
184+
175185
func setupLogging(opts *options) {
176186
if opts.debug {
177187
log.SetLevel(log.DebugLevel)
@@ -209,6 +219,9 @@ func run(opts *options) error {
209219
return finishRun(opts, exec, err)
210220
}
211221
exitErr := goTestProc.cmd.Wait()
222+
if signum := atomic.LoadInt32(&goTestProc.signal); signum != 0 {
223+
return finishRun(opts, exec, exitError{num: signalExitCode + int(signum)})
224+
}
212225
if exitErr == nil || opts.rerunFailsMaxAttempts == 0 {
213226
return finishRun(opts, exec, exitErr)
214227
}
@@ -335,38 +348,42 @@ type proc struct {
335348
cmd waiter
336349
stdout io.Reader
337350
stderr io.Reader
351+
// signal is atomically set to the signal value when a signal is received
352+
// by newSignalHandler.
353+
signal int32
338354
}
339355

340356
type waiter interface {
341357
Wait() error
342358
}
343359

344-
func startGoTest(ctx context.Context, args []string) (proc, error) {
360+
func startGoTest(ctx context.Context, args []string) (*proc, error) {
345361
if len(args) == 0 {
346-
return proc{}, errors.New("missing command to run")
362+
return nil, errors.New("missing command to run")
347363
}
348364

349365
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
366+
cmd.Stdin = os.Stdin
350367
p := proc{cmd: cmd}
351368
log.Debugf("exec: %s", cmd.Args)
352369
var err error
353370
p.stdout, err = cmd.StdoutPipe()
354371
if err != nil {
355-
return p, err
372+
return nil, err
356373
}
357374
p.stderr, err = cmd.StderrPipe()
358375
if err != nil {
359-
return p, err
376+
return nil, err
360377
}
361378
if err := cmd.Start(); err != nil {
362-
return p, errors.Wrapf(err, "failed to run %s", strings.Join(cmd.Args, " "))
379+
return nil, errors.Wrapf(err, "failed to run %s", strings.Join(cmd.Args, " "))
363380
}
364381
log.Debugf("go test pid: %d", cmd.Process.Pid)
365382

366383
ctx, cancel := context.WithCancel(ctx)
367-
newSignalHandler(ctx, cmd.Process.Pid)
384+
newSignalHandler(ctx, cmd.Process.Pid, &p)
368385
p.cmd = &cancelWaiter{cancel: cancel, wrapped: p.cmd}
369-
return p, nil
386+
return &p, nil
370387
}
371388

372389
// ExitCodeWithDefault returns the ExitStatus of a process from the error returned by
@@ -387,12 +404,28 @@ type exitCoder interface {
387404
ExitCode() int
388405
}
389406

390-
func isExitCoder(err error) bool {
407+
func IsExitCoder(err error) bool {
391408
_, ok := err.(exitCoder)
392409
return ok
393410
}
394411

395-
func newSignalHandler(ctx context.Context, pid int) {
412+
type exitError struct {
413+
num int
414+
}
415+
416+
func (e exitError) Error() string {
417+
return fmt.Sprintf("exit code %d", e.num)
418+
}
419+
420+
func (e exitError) ExitCode() int {
421+
return e.num
422+
}
423+
424+
// signalExitCode is the base value added to a signal number to produce the
425+
// exit code value. This matches the behaviour of bash.
426+
const signalExitCode = 128
427+
428+
func newSignalHandler(ctx context.Context, pid int, p *proc) {
396429
c := make(chan os.Signal, 1)
397430
signal.Notify(c, os.Interrupt)
398431

@@ -403,6 +436,8 @@ func newSignalHandler(ctx context.Context, pid int) {
403436
case <-ctx.Done():
404437
return
405438
case s := <-c:
439+
atomic.StoreInt32(&p.signal, int32(s.(syscall.Signal)))
440+
406441
proc, err := os.FindProcess(pid)
407442
if err != nil {
408443
log.Errorf("failed to find pid of 'go test': %v", err)

tools/vendor/gotest.tools/gotestsum/cmd/watch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (w *watchRuns) run(event filewatcher.Event) error {
3434
args: w.opts.args,
3535
initFilePath: path,
3636
}
37-
if err := runDelve(o); !isExitCoder(err) {
37+
if err := runDelve(o); !IsExitCoder(err) {
3838
return fmt.Errorf("delve failed: %w", err)
3939
}
4040
return nil
@@ -43,7 +43,7 @@ func (w *watchRuns) run(event filewatcher.Event) error {
4343
opts := w.opts
4444
opts.packages = []string{event.PkgPath}
4545
var err error
46-
if w.prevExec, err = runSingle(&opts); !isExitCoder(err) {
46+
if w.prevExec, err = runSingle(&opts); !IsExitCoder(err) {
4747
return err
4848
}
4949
return nil

tools/vendor/gotest.tools/gotestsum/internal/dotwriter/writer_posix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !windows
12
// +build !windows
23

34
package dotwriter

tools/vendor/gotest.tools/gotestsum/internal/filewatcher/term_unix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !windows
12
// +build !windows
23

34
package filewatcher

tools/vendor/gotest.tools/gotestsum/log/log.go

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package log
22

33
import (
44
"fmt"
5-
"os"
65

76
"github.com/fatih/color"
87
)
@@ -16,15 +15,10 @@ const (
1615
)
1716

1817
var (
19-
level = WarnLevel
20-
out stringWriter = os.Stderr
18+
level = WarnLevel
19+
out = color.Error
2120
)
2221

23-
// TODO: replace with io.StringWriter once support for go1.11 is dropped.
24-
type stringWriter interface {
25-
WriteString(s string) (n int, err error)
26-
}
27-
2822
// SetLevel for the global logger.
2923
func SetLevel(l Level) {
3024
level = l
@@ -35,36 +29,35 @@ func Warnf(format string, args ...interface{}) {
3529
if level < WarnLevel {
3630
return
3731
}
38-
out.WriteString(color.YellowString("WARN "))
39-
out.WriteString(fmt.Sprintf(format, args...))
40-
out.WriteString("\n")
32+
fmt.Fprint(out, color.YellowString("WARN "))
33+
fmt.Fprintf(out, format, args...)
34+
fmt.Fprint(out, "\n")
4135
}
4236

4337
// Debugf prints the message to stderr, with no prefix.
4438
func Debugf(format string, args ...interface{}) {
4539
if level < DebugLevel {
4640
return
4741
}
48-
out.WriteString(fmt.Sprintf(format, args...))
49-
out.WriteString("\n")
42+
fmt.Fprintf(out, format, args...)
43+
fmt.Fprint(out, "\n")
5044
}
5145

5246
// Errorf prints the message to stderr, with a red ERROR prefix.
5347
func Errorf(format string, args ...interface{}) {
5448
if level < ErrorLevel {
5549
return
5650
}
57-
out.WriteString(color.RedString("ERROR "))
58-
out.WriteString(fmt.Sprintf(format, args...))
59-
out.WriteString("\n")
51+
fmt.Fprint(out, color.RedString("ERROR "))
52+
fmt.Fprintf(out, format, args...)
53+
fmt.Fprint(out, "\n")
6054
}
6155

6256
// Error prints the message to stderr, with a red ERROR prefix.
6357
func Error(msg string) {
6458
if level < ErrorLevel {
6559
return
6660
}
67-
out.WriteString(color.RedString("ERROR "))
68-
out.WriteString(msg)
69-
out.WriteString("\n")
61+
fmt.Fprint(out, color.RedString("ERROR "))
62+
fmt.Fprintln(out, msg)
7063
}

0 commit comments

Comments
 (0)