]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: clean up after 'go build' even on windows
authorAlex Brainman <alex.brainman@gmail.com>
Thu, 11 Jun 2015 02:20:42 +0000 (12:20 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 12 Jun 2015 02:15:43 +0000 (02:15 +0000)
This CL makes CL 10682 work on windows.

Fixes #9645 (again)

Change-Id: Ie9b9af8b041c483a236b46adad4a50aa6e598c92
Reviewed-on: https://go-review.googlesource.com/10930
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/build.go
src/cmd/go/go_test.go

index e0bf59f6d0c58ae20d7bb2f5a5ab18c4d5b6cd3e..9f6054070e73073e25aa3d6a1b9bbfba071571fa 100644 (file)
@@ -559,8 +559,10 @@ func runInstall(cmd *Command, args []string) {
                fi, err := os.Stat(targ)
                if err == nil {
                        m := fi.Mode()
-                       if m.IsRegular() && m&0111 != 0 {
-                               os.Remove(targ)
+                       if m.IsRegular() {
+                               if m&0111 != 0 || goos == "windows" { // windows never sets executable bit
+                                       os.Remove(targ)
+                               }
                        }
                }
        }
index 104805ec208fbc7b755ff1e9283c78debfc0a768..cdbdfd79ea1725a8dd0be9861bf066f14670c44a 100644 (file)
@@ -589,10 +589,6 @@ func TestGoBuilDashAInReleaseBranch(t *testing.T) {
 }
 
 func TestGoInstallCleansUpAfterGoBuild(t *testing.T) {
-       if runtime.GOOS == "windows" {
-               t.Skip("skipping on Windows because of http://golang.org/issue/9645")
-       }
-
        tg := testgo(t)
        defer tg.cleanup()
        tg.tempFile("src/mycmd/main.go", `package main; func main(){}`)
@@ -621,10 +617,10 @@ func TestGoInstallCleansUpAfterGoBuild(t *testing.T) {
        tg.wantExecutable("mycmd"+exeSuffix, "testgo build did not write command binary (third time)")
        // And especially not outside the directory.
        tg.cd(tg.path("."))
-       if data, err := ioutil.ReadFile("src/mycmd/mycmd"); err != nil {
+       if data, err := ioutil.ReadFile("src/mycmd/mycmd" + exeSuffix); err != nil {
                t.Fatal("could not read file:", err)
        } else {
-               if err := ioutil.WriteFile("mycmd", data, 0555); err != nil {
+               if err := ioutil.WriteFile("mycmd"+exeSuffix, data, 0555); err != nil {
                        t.Fatal("could not write file:", err)
                }
        }