tg.run("test", "-x", "-cover", "log")
tg.grepStderrNot(`\.log\.cover\.go`, "-x output should contain correctly formatted filepath under cwd")
}
+
+// Issue 24396.
+func TestDontReportRemoveOfEmptyDir(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.tempFile("src/a/a.go", `package a`)
+ tg.setenv("GOPATH", tg.path("."))
+ tg.run("install", "-x", "a")
+ tg.run("install", "-x", "a")
+ // The second install should have printed only a WORK= line,
+ // nothing else.
+ if bytes.Count(tg.stdout.Bytes(), []byte{'\n'})+bytes.Count(tg.stderr.Bytes(), []byte{'\n'}) > 1 {
+ t.Error("unnecessary output when installing installed package")
+ }
+}
func (b *Builder) cleanup(a *Action) {
if !cfg.BuildWork {
if cfg.BuildX {
- b.Showcmd("", "rm -r %s", a.Objdir)
+ // Don't say we are removing the directory if
+ // we never created it.
+ if _, err := os.Stat(a.Objdir); err == nil || cfg.BuildN {
+ b.Showcmd("", "rm -r %s", a.Objdir)
+ }
}
os.RemoveAll(a.Objdir)
}