-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/go: "go test" needlessly recompiles package on each test run (Windows) #7285
Labels
Comments
If the installed package was, for example, build using different build tags, would you still want it not to be (re)compiled? Also, I don't think that test running in seconds "discourages to run them at all.". There are packages which legitimately needs minutes to test. Do you claim they should not be tested? And if you, by chance, have a save hook which automagically run tests, then simply disable it. There's no reason to alter the tool chain to suit anyone's misconfigured editor. |
Running "go test" routinely rebuilds the package. That is because the tests are often in the same package as the code being tested, so they can access internal functions. Thus the code must be recompiled. Your solution seems like the best one for your use case. We could modify "go test" so that if the tests use a different package name, and the sources are installed and up to date, it does not rebuild the sources. I don't know whether that would be a good idea or not. |
"go test" already does what Ian suggests in #3. If the test files say 'package cef_test' (and need no access to internals of package cef) then only the test package is built, not the original. For example, sync/atomic only has test files in package atomic_test, not in package atomic: g% go list -f '{{.TestGoFiles}} {{.XTestGoFiles}}' sync/atomic [] [atomic_test.go] g% So go test sync/atomic does not rebuild the package, just the tests: g% go test -x sync/atomic WORK=/var/folders/00/05_b8000h01000cxqpysvccm000n9d/T/go-build969876488 mkdir -p $WORK/sync/atomic/_test/sync/ mkdir -p $WORK/sync/atomic/_test/_obj_xtest/ cd /Users/rsc/g/go/src/pkg/sync/atomic /Users/rsc/g/go/pkg/tool/darwin_amd64/6g -o $WORK/sync/atomic/_test/sync/atomic_test.a -p sync/atomic_test -complete -D _/Users/rsc/g/go/src/pkg/sync/atomic -I $WORK -pack ./atomic_test.go mkdir -p $WORK/sync/atomic/_test/ cd $WORK/sync/atomic/_test /Users/rsc/g/go/pkg/tool/darwin_amd64/6g -o ./main.a -p testmain -complete -D "" -I . -I $WORK -pack ./_testmain.go cd . /Users/rsc/g/go/pkg/tool/darwin_amd64/6l -o $WORK/sync/atomic/_test/atomic.test -L $WORK/sync/atomic/_test -L $WORK -w -extld=clang $WORK/sync/atomic/_test/main.a $WORK/sync/atomic/_test/atomic.test ok sync/atomic 1.665s g% Status changed to WorkingAsIntended. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by czarek.tomczak:
The text was updated successfully, but these errors were encountered: