mirror of
https://github.com/golang/go
synced 2024-11-23 16:40:03 -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:
parent
637d59859d
commit
117506aab6
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user