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

enable running all tests when watching by pressing 'a' #197

Merged
merged 2 commits into from
May 28, 2021
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,11 @@ While in watch mode, pressing some keys will perform an action:

* `r` will run tests for the previous event.
* `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
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
breakpoints can be added with [`runtime.Breakpoint`](https://golang.org/pkg/runtime/#Breakpoint)
or by using the delve command prompt.
* `a` will run tests for all packages, by using `./...` as the package selector.

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

Expand Down
3 changes: 3 additions & 0 deletions internal/filewatcher/term_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func (r *redoHandler) Run(ctx context.Context) {
case 'd':
chResume = make(chan struct{})
r.ch <- RunOptions{Debug: true, resume: chResume}
case 'a':
chResume = make(chan struct{})
r.ch <- RunOptions{resume: chResume, PkgPath: "./..."}
case '\n':
fmt.Println()
continue
Expand Down
4 changes: 3 additions & 1 deletion internal/filewatcher/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func Watch(dirs []string, run func(opts RunOptions) error) error {
resetTimer(timer)

redo.ResetTerm()
opts.PkgPath = h.lastPath
if err := h.runTests(opts); err != nil {
return fmt.Errorf("failed to rerun tests for %v: %v", opts.PkgPath, err)
}
Expand Down Expand Up @@ -223,6 +222,9 @@ func (h *handler) handleEvent(event fsnotify.Event) error {
}

func (h *handler) runTests(opts RunOptions) error {
if opts.PkgPath == "" {
opts.PkgPath = h.lastPath
}
fmt.Printf("\nRunning tests in %v\n", opts.PkgPath)

if err := h.fn(opts); err != nil {
Expand Down