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

cmd/go: test -i and -o options together don't work as expected #17078

Closed
aaronlehmann opened this issue Sep 12, 2016 · 4 comments
Closed

cmd/go: test -i and -o options together don't work as expected #17078

aaronlehmann opened this issue Sep 12, 2016 · 4 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@aaronlehmann
Copy link

What version of Go are you using (go version)?

go version go1.7 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/aaronl/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

I tried to run go test with both the -i and -o flags. The help output implies this combination is supported:

           -i
               Install packages that are dependencies of the test.
               Do not run the test.

           -o file
               Compile the test binary to the named file.
               The test still runs (unless -c or -i is specified).
$ go test
PASS
ok      fmt     0.070s
$ go test -i -o testbinary
$ ./testbinary
-bash: ./testbinary: No such file or directory

What did you expect to see?

I expected go test -i -o testbinary to create a testbinary executable, and also install the package's dependencies.

What did you see instead?

No executable created.

@quentinmit quentinmit changed the title go test with -i and -o options doesn't work as expected test: -i and -o options together don't work as expected Sep 12, 2016
@quentinmit quentinmit added this to the Go1.8 milestone Sep 12, 2016
@0xmohit
Copy link
Contributor

0xmohit commented Sep 13, 2016

This appears to be more of a documentation issue. You'd need to specify -c, i.e. go test -c -i -o testbinary:

        -c
                Compile the test binary to pkg.test but do not run it
                (where pkg is the last element of the package's import path).
                The file name can be changed with the -o flag.

Perhaps, -o should state that it renames the compiled binary to the named file instead of suggesting that it compiles.

@robpike
Copy link
Contributor

robpike commented Sep 15, 2016

I agree this is a documentation issue. The code is working as expected.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
@rsc
Copy link
Contributor

rsc commented Oct 18, 2016

I don't believe the code is working as expected. The docs spell out the behavior of -o quite clearly, and the code doesn't do what the docs say. It is trivial to make 'go test -i -o x.test' work as documented, and harder to document the current behavior clearly. I'll send a CL for the code.

@rsc rsc changed the title test: -i and -o options together don't work as expected cmd/go: test -i and -o options together don't work as expected Oct 18, 2016
@gopherbot
Copy link

CL https://golang.org/cl/31352 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants