8000 chore(deps): bump gotest.tools/gotestsum from 1.8.0 to 1.8.1 in /tool… · obalunenko/advent-of-code@c6c2a13 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6c2a13

Browse files
chore(deps): bump gotest.tools/gotestsum from 1.8.0 to 1.8.1 in /tools (#126)
Bumps [gotest.tools/gotestsum](https://github.com/gotestyourself/gotestsum) from 1.8.0 to 1.8.1. - [Release notes](https://github.com/gotestyourself/gotestsum/releases) - [Changelog](https://github.com/gotestyourself/gotestsum/blob/main/.goreleaser.yml) - [Commits](gotestyourself/gotestsum@v1.8.0...v1.8.1) --- updated-dependencies: - dependency-name: gotest.tools/gotestsum dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 7bba844 commit c6c2a13

File tree

10 files changed

+89
-33
lines changed

10 files changed

+89
-33
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.8.0
13+
gotest.tools/gotestsum v1.8.1
1414
)
1515

1616
require (

tools/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
18171817
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
18181818
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
18191819
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1820-
gotest.tools/gotestsum v1.8.0 h1:ltj5KWhbQjt1Yx+IPBj0Dk2HVDUs9OlLmGC2JvivTMo=
1821-
gotest.tools/gotestsum v1.8.0/go.mod h1:ctqdxBSCPv80kAFjYvFNpPntBrE5HAQnLiOKBGLmOBs=
1820+
gotest.tools/gotestsum v1.8.1 h1:C6dYd5K39WAv52jikEUuWgyMqJDhY90eauUjsFzwluc=
1821+
gotest.tools/gotestsum v1.8.1/go.mod h1:ctqdxBSCPv80kAFjYvFNpPntBrE5HAQnLiOKBGLmOBs=
18221822
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
18231823
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
18241824
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gotestsum
22

3-
`gotestsum` runs tests using `go test --json`, prints formatted test output, and a summary of the test run.
3+
`gotestsum` runs tests using `go test -json`, prints formatted test output, and a summary of the test run.
44
It is designed to work well for both local development, and for automation like CI.
55
`gotest.tools/gotestsum/testjson` ([godoc](https://pkg.go.dev/gotest.tools/gotestsum/testjson)) is a library
66
that can be used to read [`test2json`](https://golang.org/cmd/test2json/) output.
@@ -112,7 +112,7 @@ warning.
112112
When the `--jsonfile` flag or `GOTESTSUM_JSONFILE` environment variable are set
113113
to a file path, `gotestsum` will write a line-delimited JSON file with all the
114114
[test2json](https://golang.org/cmd/test2json/#hdr-Output_Format)
115-
output that was written by `go test --json`. This file can be used to compare test
115+
output that was written by `go test -json`. This file can be used to compare test
116116
runs, or find flaky tests.
117117

118118
```
@@ -202,7 +202,7 @@ how you specify args to `go test`:
202202

203203
### Custom `go test` command
204204

205-
By default `gotestsum` runs tests using the command `go test --json ./...`. You
205+
By default `gotestsum` runs tests using the command `go test -json ./...`. You
206206
can change the command with positional arguments after a `--`. You can change just the
207207
test directory value (which defaults to `./...`) by setting the `TEST_DIRECTORY`
208208
environment variable.
@@ -345,10 +345,19 @@ tests for the package which contains the changed file. By default all
345345
directories with at least one file with a `.go` extension, under the current
346346
directory will be watched. Use the `--packages` flag to specify a different list.
347347

348+
If `--watch` is used with a command line that includes the name of one or more
349+
packages as command line arguments (ex: `gotestsum --watch -- ./...` or
350+
`gotestsum --watch -- ./extrapkg`), the
351+
tests in those packages will also be run when any file changes.
352+
348353
While in watch mode, pressing some keys will perform an action:
349354

350355
* `r` will run tests for the previous event.
351356
Added in version 1.6.1.
357+
* `u` will run tests for the previous event, with the `-update` flag added.
358+
Many [golden]< 8000 span class="pl-s">(https://gotest.tools/v3/golden) packages use this flag to automatically
359+
update expected values of tests.
360+
Added in version 1.8.1.
352361
* `d` will run tests for the previous event using `dlv test`, allowing you to
353362
debug a test failure using [delve]. A breakpoint will automatically be added at
354363
the first line of any tests which failed in the previous run. Additional

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import (
1313
)
1414

1515
func runWatcher(opts *options) error {
16+
ctx, cancel := context.WithCancel(context.Background())
17+
defer cancel()
18+
1619
w := &watchRuns{opts: *opts}
17-
return filewatcher.Watch(opts.packages, w.run)
20+
return filewatcher.Watch(ctx, opts.packages, w.run)
1821
}
1922

2023
type watchRuns struct {
@@ -40,8 +43,11 @@ func (w *watchRuns) run(event filewatcher.Event) error {
4043
return nil
4144
}
4245

43-
opts := w.opts
44-
opts.packages = []string{event.PkgPath}
46+
opts := w.opts // shallow copy opts
47+
opts.packages = append([]string{}, opts.packages...)
48+
opts.packages = append(opts.packages, event.PkgPath)
49+
opts.packages = append(opts.packages, event.Args...)
50+
4551
var err error
4652
if w.prevExec, err = runSingle(&opts); !IsExitCoder(err) {
4753
return err
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build aix
2+
// +build aix
3+
4+
package filewatcher
5+
6+
import "golang.org/x/sys/unix"
7+
8+
const tcGet = unix.TCGETA
9+
const tcSet = unix.TCSETA

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build darwin || dragonfly || freebsd || netbsd || openbsd
12
// +build darwin dragonfly freebsd netbsd openbsd
23

34
package filewatcher

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
//go:build !windows
2-
// +build !windows
1+
//go:build !windows && !aix
2+
// +build !windows,!aix
33

44
package filewatcher
55

66
import (
77
"bufio"
88
"context"
99
"fmt"
10+
"io"
1011
"os"
1112

1213
"golang.org/x/sys/unix"
@@ -62,13 +63,15 @@ func enableNonBlockingRead(fd int) (func(), error) {
6263
return reset, nil
6364
}
6465 3379

66+
var stdin io.Reader = os.Stdin
67+
6568
// Monitor the terminal for key presses. If the key press is associated with an
6669
// action, an event will be sent to channel returned by Events.
6770
func (r *terminal) Monitor(ctx context.Context) {
6871
if r == nil {
6972
return
7073
}
71-
in := bufio.NewReader(os.Stdin)
74+
in := bufio.NewReader(stdin)
7275
for {
7376
char, err := in.ReadByte()
7477
if err != nil {
@@ -77,20 +80,18 @@ func (r *terminal) Monitor(ctx context.Context) {
7780
}
7881
log.Debugf("received byte %v (%v)", char, string(char))
7982

80-
var chResume chan struct{}
83+
chResume := make(chan struct{})
8184
switch char {
8285
case 'r':
83-
chResume = make(chan struct{})
84-
r.ch <- Event{resume: chResume}
86+
r.ch <- Event{resume: chResume, useLastPath: true}
8587
case 'd':
86-
chResume = make(chan struct{})
87-
r.ch <- Event{Debug: true, resume: chResume}
88+
r.ch <- Event{resume: chResume, useLastPath: true, Debug: true}
8889
case 'a':
89-
chResume = make(chan struct{})
9090
r.ch <- Event{resume: chResume, PkgPath: "./..."}
9191
case 'l':
92-
chResume = make(chan struct{})
9392
r.ch <- Event{resume: chResume, reloadPaths: true}
93+
case 'u':
94+
r.ch <- Event{resume: chResume, useLastPath: true, Args: []string{"-update"}}
9495
case '\n':
9596
fmt.Println()
9697
continue

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

Lines changed: 25 additions & 13 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build !aix
2+
// +build !aix
3+
14
package filewatcher
25

36
import (
@@ -16,18 +19,25 @@ import (
1619
const maxDepth = 7
1720

1821
type Event struct {
19-
PkgPath string
20-
Debug bool
21-
resume chan struct{}
22+
// PkgPath of the package that triggered the event.
23+
PkgPath string
24+
// Args will be appended to the command line args for 'go test'.
25+
Args []string
26+
// Debug runs the tests with delve.
27+
Debug bool
28+
// resume the Watch goroutine when this channel is closed. Used to block
29+
// the Watch goroutine while tests are running.
30+
resume chan struct{}
31+
// reloadPaths will cause the watched path list to be reloaded, to watch
32+
// new directories.
2233
reloadPaths bool
34+
// useLastPath when true will use the PkgPath from the previous run.
35+
useLastPath bool
2336
}
2437

2538
// Watch dirs for filesystem events, and run tests when .go files are saved.
2639
// nolint: gocyclo
27-
func Watch(dirs []string, run func(Event) error) error {
28-
ctx, cancel := context.WithCancel(context.Background())
29-
defer cancel()
30-
40+
func Watch(ctx context.Context, dirs []string, run func(Event) error) error {
3141
watcher, err := fsnotify.NewWatcher()
3242
if err != nil {
3343
return fmt.Errorf("failed to create file watcher: %w", err)
@@ -45,9 +55,11 @@ func Watch(dirs []string, run func(Event) error) error {
4555
defer term.Reset()
4656
go term.Monitor(ctx)
4757

48-
h := &handler{last: time.Now(), fn: run}
58+
h := &fsEventHandler{last: time.Now(), fn: run}
4959
for {
5060
select {
61+
case <-ctx.Done():
62+
return nil
5163
case <-timer.C:
5264
return fmt.Errorf("exceeded idle timeout while watching files")
5365

@@ -215,15 +227,15 @@ func handleDirCreated(watcher *fsnotify.Watcher, event fsnotify.Event) (handled
215227
return true
216228
}
217229

218-
type handler struct {
230+
type fsEventHandler struct {
219231
last time.Time
220232
lastPath string
221233
fn func(opts Event) error
222234
}
223235

224-
const floodThreshold = 250 * time.Millisecond
236+
var floodThreshold = 250 * time.Millisecond
225237

226-
func (h *handler) handleEvent(event fsnotify.Event) error {
238+
func (h *fsEventHandler) handleEvent(event fsnotify.Event) error {
227239
if event.Op&(fsnotify.Write|fsnotify.Create) == 0 {
228240
return nil
229241
}
@@ -239,8 +251,8 @@ func (h *handler) handleEvent(event fsnotify.Event) error {
239251
return h.runTests(Event{PkgPath: "./" + filepath.Dir(event.Name)})
240252
}
241253

242-
func (h *handler) runTests(opts Event) error {
243-
if opts.PkgPath == "" {
254+
func (h *fsEventHandler) runTests(opts Event) error {
255+
if opts.useLastPath {
244256
opts.PkgPath = h.lastPath
245257
}
246258
fmt.Printf("\nRunning tests in %v\n", opts.PkgPath)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build aix
2+
// +build aix
3+
4+
package filewatcher
5+
6+
import (
7+
"fmt"
8+
"runtime"
9+
)
10+
11+
type Event struct {
12+
PkgPath string
13+
Debug bool
14+
}
15+
16+
func Watch(dirs []string, run func(Event) error) error {
17+
return fmt.Errorf("file watching is not supported on %v/%v", runtime.GOOS, runtime.GOARCH)
18+
}

tools/vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ gopkg.in/yaml.v2
16071607
# gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
16081608
## explicit
16091609
gopkg.in/yaml.v3
1610-
# gotest.tools/gotestsum v1.8.0
1610+
# gotest.tools/gotestsum v1.8.1
16111611
## explicit; go 1.13
16121612
gotest.tools/gotestsum
16131613
gotest.tools/gotestsum/cmd

0 commit comments

Comments
 (0)
0