add test, use filepath.Separator

This commit is contained in:
motemen 2018-02-21 17:37:37 +09:00
parent 3c3f1cf6c4
commit 1493f38baf
2 changed files with 10 additions and 2 deletions

View File

@ -5921,3 +5921,11 @@ echo $* >>`+tg.path("pkg-config.out"))
t.Errorf("got %q want %q", out, want)
}
}
// Issue 23982
func TestFilepathUnderCwdFormat(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.run("test", "-x", "-cover", "log")
tg.grepStderrNot(`\.log\.cover\.go`, "-x output should contain correctly formatted filepath under cwd")
}

View File

@ -1365,8 +1365,8 @@ func (b *Builder) fmtcmd(dir string, format string, args ...interface{}) string
cmd := fmt.Sprintf(format, args...)
if dir != "" && dir != "/" {
dot := " ."
if dir[len(dir)-1] == '/' {
dot += "/"
if dir[len(dir)-1] == filepath.Separator {
dot += string(filepath.Separator)
}
cmd = strings.Replace(" "+cmd, " "+dir, dot, -1)[1:]
if b.scriptDir != dir {