8000 chore(deps): bump gotest.tools/gotestsum from 1.8.0 to 1.8.1 in /tools by dependabot[bot] · Pull Request #126 · obalunenko/advent-of-code · GitHub
[go: up one dir, main page]

Skip to content

chore(deps): bump gotest.tools/gotestsum from 1.8.0 to 1.8.1 in /tools #126

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

Merged
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
8000
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/mattn/goveralls v0.0.11
github.com/obalunenko/coverbadger v1.2.0
golang.org/x/tools v0.1.10
gotest.tools/gotestsum v1.8.0
gotest.tools/gotestsum v1.8.1
)

require (
Expand Down
4 changes: 2 additions & 2 deletions tools/go.sum
Original file line number Diff line number Diff line c 8000 hange
Expand Up @@ -1817,8 +1817,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/gotestsum v1.8.0 h1:ltj5KWhbQjt1Yx+IPBj0Dk2HVDUs9OlLmGC2JvivTMo=
gotest.tools/gotestsum v1.8.0/go.mod h1:ctqdxBSCPv80kAFjYvFNpPntBrE5HAQnLiOKBGLmOBs=
gotest.tools/gotestsum v1.8.1 h1:C6dYd5K39WAv52jikEUuWgyMqJDhY90eauUjsFzwluc=
gotest.tools/gotestsum v1.8.1/go.mod h1:ctqdxBSCPv80kAFjYvFNpPntBrE5HAQnLiOKBGLmOBs=
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
15 changes: 12 additions & 3 deletions tools/vendor/gotest.tools/gotestsum/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gotestsum

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

```
Expand Down Expand Up @@ -202,7 +202,7 @@ how you specify args to `go test`:

### Custom `go test` command

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

If `--watch` is used with a command line that includes the name of one or more
packages as command line arguments (ex: `gotestsum --watch -- ./...` or
`gotestsum --watch -- ./extrapkg`), the
tests in those packages will also be run when any file changes.

While in watch mode, pressing some keys will perform an action:

* `r` will run tests for the previous event.
Added in version 1.6.1.
* `u` will run tests for the previous event, with the `-update` flag added.
Many [golden](https://gotest.tools/v3/golden) packages use this flag to automatically
update expected values of tests.
Added in version 1.8.1.
* `d` will run tests for the previous event using `dlv test`, allowing you to
debug a test failure using [delve]. A breakpoint will automatically be added at
the first line of any tests which failed in the previous run. Additional
Expand Down
12 changes: 9 additions & 3 deletions tools/vendor/gotest.tools/gotestsum/cmd/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import (
)

func runWatcher(opts *options) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

w := &watchRuns{opts: *opts}
return filewatcher.Watch(opts.packages, w.run)
return filewatcher.Watch(ctx, opts.packages, w.run)
}

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

opts := w.opts
opts.packages = []string{event.PkgPath}
opts := w.opts // shallow copy opts
opts.packages = append([]string{}, opts.packages...)
opts.packages = append(opts.packages, event.PkgPath)
opts.packages = append(opts.packages, event.Args...)

var err error
if w.prevExec, err = runSingle(&opts); !IsExitCoder(err) {
return err
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build aix
// +build aix

package filewatcher

import "golang.org/x/sys/unix"

const tcGet = unix.TCGETA
const tcSet = unix.TCSETA
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build darwin || dragonfly || freebsd || netbsd || openbsd
// +build darwin dragonfly freebsd netbsd openbsd

package filewatcher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//go:build !windows
// +build !windows
//go:build !windows && !aix
// +build !windows,!aix

package filewatcher

import (
"bufio"
"context"
"fmt"
"io"
"os"

"golang.org/x/sys/unix"
Expand Down Expand Up @@ -62,13 +63,15 @@ func enableNonBlockingRead(fd int) (func(), error) {
return reset, nil
}

var stdin io.Reader = os.Stdin

// Monitor the terminal for key presses. If the key press is associated with an
// action, an event will be sent to channel returned by Events.
func (r *terminal) Monitor(ctx context.Context) {
if r == nil {
return
}
in := bufio.NewReader(os.Stdin)
in := bufio.NewReader(stdin)
for {
char, err := in.ReadByte()
if err != nil {
Expand All @@ -77,20 +80,18 @@ func (r *terminal) Monitor(ctx context.Context) {
}
log.Debugf("received byte %v (%v)", char, string(char))

var chResume chan struct{}
chResume := make(chan struct{})
switch char {
case 'r':
chResume = make(chan struct{})
r.ch <- Event{resume: chResume}
r.ch <- Event{resume: chResume, useLastPath: true}
case 'd':
chResume = make(chan struct{})
r.ch <- Event{Debug: true, resume: chResume}
r.ch <- Event{resume: chResume, useLastPath: true, Debug: true}
case 'a':
chResume = make(chan struct{})
r.ch <- Event{resume: chResume, PkgPath: "./..."}
case 'l':
chResume = make(chan struct{})
r.ch <- Event{resume: chResume, reloadPaths: true}
case 'u':
r.ch <- Event{resume: chResume, useLastPath: true, Args: []string{"-update"}}
case '\n':
fmt.Println()
continue
Expand Down
38 changes: 25 additions & 13 deletions tools/vendor/gotest.tools/gotestsum/internal/filewatcher/watch.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !aix
// +build !aix

package filewatcher

import (
Expand All @@ -16,18 +19,25 @@ import (
const maxDepth = 7

type Event struct {
PkgPath string
Debug bool
resume chan struct{}
// PkgPath of the package that triggered the event.
PkgPath string
// Args will be appended to the command line args for 'go test'.
Args []string
// Debug runs the tests with delve.
Debug bool
// resume the Watch goroutine when this channel is closed. Used to block
// the Watch goroutine while tests are running.
resume chan struct{}
// reloadPaths will cause the watched path list to be reloaded, to watch
// new directories.
reloadPaths bool
// useLastPath when true will use the PkgPath from the previous run.
useLastPath bool
}

// Watch dirs for filesystem events, and run tests when .go files are saved.
// nolint: gocyclo
func Watch(dirs []string, run func(Event) error) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

func Watch(ctx context.Context, dirs []string, run func(Event) error) error {
watcher, err := fsnotify.NewWatcher()
if err != nil {
return fmt.Errorf("failed to create file watcher: %w", err)
Expand All @@ -45,9 +55,11 @@ func Watch(dirs []string, run func(Event) error) error {
defer term.Reset()
go term.Monitor(ctx)

h := &handler{last: time.Now(), fn: run}
h := &fsEventHandler{last: time.Now(), fn: run}
for {
select {
case <-ctx.Done():
return nil
case <-timer.C:
return fmt.Errorf("exceeded idle timeout while watching files")

Expand Down Expand Up @@ -215,15 +227,15 @@ func handleDirCreated(watcher *fsnotify.Watcher, event fsnotify.Event) (handled
return true
}

type handler struct {
type fsEventHandler struct {
last time.Time
lastPath string
fn func(opts Event) error
}

const floodThreshold = 250 * time.Millisecond
var floodThreshold = 250 * time.Millisecond

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

func (h *handler) runTests(opts Event) error {
if opts.PkgPath == "" {
func (h *fsEventHandler) runTests(opts Event) error {
if opts.useLastPath {
opts.PkgPath = h.lastPath
}
fmt.Printf("\nRunning tests in %v\n", opts.PkgPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build aix
// +build aix

package filewatcher

import (
"fmt"
"runtime"
)

type Event struct {
PkgPath string
Debug bool
}

func Watch(dirs []string, run func(Event) error) error {
return fmt.Errorf("file watching is not supported on %v/%v", runtime.GOOS, runtime.GOARCH)
}
2 changes: 1 addition & 1 deletion tools/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ gopkg.in/yaml.v2
# gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
## explicit
gopkg.in/yaml.v3
# gotest.tools/gotestsum v1.8.0
# gotest.tools/gotestsum v1.8.1
## explicit; go 1.13
gotest.tools/gotestsum
gotest.tools/gotestsum/cmd
Expand Down
0