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

Proposal: cmd/go : add "go test" with "-watch" argument for automatic reload test #23449

Closed
AnuchitO opened this issue Jan 15, 2018 · 5 comments

Comments

@AnuchitO
Copy link

Currently, I use go test It's useful and work very well,
but when I have developed. I must be to rerun the go test command everytime is code changed. Especially when it is developed with TDD.

I propose we increase the convenience and reduce the development time by adding the flag -watch for automatic reload to run the test when the file is changed.

Example

  1. Scenario I
    go test -watch or go test -watch .

  2. Scenario II
    go test -watch ./...

Both of them It's still the same behavior just add -watch to reload and run go test automatically when file changed.

I think it's a small change that comes along very handy.
And I would like to contribute development this one.
What do we think?

@gopherbot gopherbot added this to the Proposal milestone Jan 15, 2018
@ALTree
Copy link
Member

ALTree commented Jan 15, 2018

Why does this need to be a flag in the go tool? It's already pretty crowded.

You can use https://github.com/nathany/looper to do this.

@ALTree
Copy link
Member

ALTree commented Jan 15, 2018

Apparently this was on the table a few years ago, see this proposal by rsc:

Go 1.3 cmd/go and os/fsnotify

(it mentions a -watch flag toward the end). It looks like it was dropped(?). I'm not sure, though.

@AnuchitO
Copy link
Author

AnuchitO commented Jan 16, 2018

Sure we can use a lot of tool to do that.
I just don't want to setup too much.
However Thank you so much for the information. :)

@index0h
Copy link

index0h commented Jan 20, 2018

while true
do
    inotifywait -qq -r -e create,close_write,modify,move,delete ./ && go test ./...
done

@rsc
Copy link
Contributor

rsc commented Jan 22, 2018

There are a bunch of tools that do this. Doing it in cmd/go would require having fsnotify in the standard library, and we were unable to find a way to define that package portably. Let's keep using the existing tools (and maybe even rally around a single one, but outside the standard distribution).

@rsc rsc closed this as completed Jan 22, 2018
@golang golang locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants