]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/go: retain test binary when go test is run with -mutexprofile
authorKale Blankenship <kale@lemnisys.com>
Mon, 2 Jan 2017 21:41:39 +0000 (13:41 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 5 Jan 2017 00:57:43 +0000 (00:57 +0000)
Fixes #18494

Change-Id: I8a190acae6d5f1d20d4e4e4547d84e10e8a7fe68
Reviewed-on: https://go-review.googlesource.com/34793
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

src/cmd/go/go_test.go
src/cmd/go/testflag.go

index f7ea6c8bbd6cb514480e54c89a036bad250bb8bf..5727eb094e5473a1b5eadaed70a53e16aa9f0ef9 100644 (file)
@@ -1885,6 +1885,26 @@ func TestGoTestCpuprofileDashOControlsBinaryLocation(t *testing.T) {
        tg.wantExecutable("myerrors.test"+exeSuffix, "go test -cpuprofile -o myerrors.test did not create myerrors.test")
 }
 
+func TestGoTestMutexprofileLeavesBinaryBehind(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       // TODO: tg.parallel()
+       tg.makeTempdir()
+       tg.cd(tg.path("."))
+       tg.run("test", "-mutexprofile", "errors.prof", "errors")
+       tg.wantExecutable("errors.test"+exeSuffix, "go test -mutexprofile did not create errors.test")
+}
+
+func TestGoTestMutexprofileDashOControlsBinaryLocation(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       // TODO: tg.parallel()
+       tg.makeTempdir()
+       tg.cd(tg.path("."))
+       tg.run("test", "-mutexprofile", "errors.prof", "-o", "myerrors.test"+exeSuffix, "errors")
+       tg.wantExecutable("myerrors.test"+exeSuffix, "go test -mutexprofile -o myerrors.test did not create myerrors.test")
+}
+
 func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {
        tg := testgo(t)
        defer tg.cleanup()
index cf4d2b47ff9cfbdfcf00283ad9b4a4ea7b933adb..fa53bfcdf095b3ddfa2000016eb440478da79807 100644 (file)
@@ -151,10 +151,10 @@ func testFlags(args []string) (packageNames, passToTest []string) {
                                testBench = true
                        case "timeout":
                                testTimeout = value
-                       case "blockprofile", "cpuprofile", "memprofile":
+                       case "blockprofile", "cpuprofile", "memprofile", "mutexprofile":
                                testProfile = true
                                testNeedBinary = true
-                       case "mutexprofile", "trace":
+                       case "trace":
                                testProfile = true
                        case "coverpkg":
                                testCover = true