Skip to content

Commit 1493f38

Browse files
committed
add test, use filepath.Separator
1 parent 3c3f1cf commit 1493f38

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/cmd/go/go_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5921,3 +5921,11 @@ echo $* >>`+tg.path("pkg-config.out"))
59215921
t.Errorf("got %q want %q", out, want)
59225922
}
59235923
}
5924+
5925+
// Issue 23982
5926+
func TestFilepathUnderCwdFormat(t *testing.T) {
5927+
tg := testgo(t)
5928+
defer tg.cleanup()
5929+
tg.run("test", "-x", "-cover", "log")
5930+
tg.grepStderrNot(`\.log\.cover\.go`, "-x output should contain correctly formatted filepath under cwd")
5931+
}

src/cmd/go/internal/work/exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,8 +1365,8 @@ func (b *Builder) fmtcmd(dir string, format string, args ...interface{}) string
13651365
cmd := fmt.Sprintf(format, args...)
13661366
if dir != "" && dir != "/" {
13671367
dot := " ."
1368-
if dir[len(dir)-1] == '/' {
1369-
dot += "/"
1368+
if dir[len(dir)-1] == filepath.Separator {
1369+
dot += string(filepath.Separator)
13701370
}
13711371
cmd = strings.Replace(" "+cmd, " "+dir, dot, -1)[1:]
13721372
if b.scriptDir != dir {

0 commit comments

Comments
 (0)