]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: make go test -i -o x.test actually write x.test
authorRuss Cox <rsc@golang.org>
Tue, 18 Oct 2016 03:05:27 +0000 (23:05 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 19 Oct 2016 02:31:26 +0000 (02:31 +0000)
Fixes #17078.

Change-Id: I1dfb71f64361b575ec461ed44b0779f2d5cf45fc
Reviewed-on: https://go-review.googlesource.com/31352
Reviewed-by: Quentin Smith <quentin@golang.org>
src/cmd/go/go_test.go
src/cmd/go/test.go

index 5ee7f04ade8cd2970befa765a3ff769079b3b908..96cc197e093ab7348b1857ea5f9239743cf0866b 100644 (file)
@@ -1703,6 +1703,16 @@ func TestGoTestDashOWritesBinary(t *testing.T) {
        tg.wantExecutable(tg.path("myerrors.test"+exeSuffix), "go test -o myerrors.test did not create myerrors.test")
 }
 
+func TestGoTestDashIDashOWritesBinary(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       tg.parallel()
+       tg.makeTempdir()
+       tg.run("test", "-v", "-i", "-o", tg.path("myerrors.test"+exeSuffix), "errors")
+       tg.grepBothNot("PASS|FAIL", "test should not have run")
+       tg.wantExecutable(tg.path("myerrors.test"+exeSuffix), "go test -o myerrors.test did not create myerrors.test")
+}
+
 // Issue 4568.
 func TestSymlinksList(t *testing.T) {
        switch runtime.GOOS {
index 4b65c1ccdcdc4c5dcc883aab4d7a474dc25843d8..015355d3d76cc4f4609581be943fc47b3812adf9 100644 (file)
@@ -435,6 +435,11 @@ func runTest(cmd *Command, args []string) {
        testStreamOutput = len(pkgArgs) == 0 || testBench ||
                (testShowPass && (len(pkgs) == 1 || buildP == 1))
 
+       // For 'go test -i -o x.test', we want to build x.test. Imply -c to make the logic easier.
+       if buildI && testO != "" {
+               testC = true
+       }
+
        var b builder
        b.init()