1
0
mirror of https://github.com/golang/go synced 2024-11-23 19:40:08 -07:00

cmd/go: clean up after 'go build' even on windows

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>
This commit is contained in:
Alex Brainman 2015-06-11 12:20:42 +10:00
parent 637d59859d
commit 117506aab6
2 changed files with 6 additions and 8 deletions

View File

@ -559,11 +559,13 @@ func runInstall(cmd *Command, args []string) {
fi, err := os.Stat(targ)
if err == nil {
m := fi.Mode()
if m.IsRegular() && m&0111 != 0 {
if m.IsRegular() {
if m&0111 != 0 || goos == "windows" { // windows never sets executable bit
os.Remove(targ)
}
}
}
}
}
// Global build parameters (used during package load)

View 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)
}
}