File tree 2 files changed +21
-1
lines changed 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -5960,3 +5960,19 @@ func TestFilepathUnderCwdFormat(t *testing.T) {
5960
5960
tg .run ("test" , "-x" , "-cover" , "log" )
5961
5961
tg .grepStderrNot (`\.log\.cover\.go` , "-x output should contain correctly formatted filepath under cwd" )
5962
5962
}
5963
+
5964
+ // Issue 24396.
5965
+ func TestDontReportRemoveOfEmptyDir (t * testing.T ) {
5966
+ tg := testgo (t )
5967
+ defer tg .cleanup ()
5968
+ tg .parallel ()
5969
+ tg .tempFile ("src/a/a.go" , `package a` )
5970
+ tg .setenv ("GOPATH" , tg .path ("." ))
5971
+ tg .run ("install" , "-x" , "a" )
5972
+ tg .run ("install" , "-x" , "a" )
5973
+ // The second install should have printed only a WORK= line,
5974
+ // nothing else.
5975
+ if bytes .Count (tg .stdout .Bytes (), []byte {'\n' })+ bytes .Count (tg .stderr .Bytes (), []byte {'\n' }) > 1 {
5976
+ t .Error ("unnecessary output when installing installed package" )
5977
+ }
5978
+ }
Original file line number Diff line number Diff line change @@ -1136,7 +1136,11 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) {
1136
1136
func (b * Builder ) cleanup (a * Action ) {
1137
1137
if ! cfg .BuildWork {
1138
1138
if cfg .BuildX {
1139
- b .Showcmd ("" , "rm -r %s" , a .Objdir )
1139
+ // Don't say we are removing the directory if
1140
+ // we never created it.
1141
+ if _ , err := os .Stat (a .Objdir ); err == nil || cfg .BuildN {
1142
+ b .Showcmd ("" , "rm -r %s" , a .Objdir )
1143
+ }
1140
1144
}
1141
1145
os .RemoveAll (a .Objdir )
1142
1146
}
You can’t perform that action at this time.
0 commit comments