From 570b49d6fc8d66e5bcb7645dfe2a3f9a118dbf0f Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 16 Oct 2020 14:01:04 -0400 Subject: [PATCH] cmd/go: normalize paths in TestScript/build_overlay Fixes #42008 Change-Id: I1652e8cc4e72b4b7e52571ab12da29e717218a0b Reviewed-on: https://go-review.googlesource.com/c/go/+/263145 Trust: Bryan C. Mills Trust: Jay Conrod Run-TryBot: Bryan C. Mills Reviewed-by: Jay Conrod TryBot-Result: Go Bot --- src/cmd/go/testdata/script/build_overlay.txt | 33 +++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/cmd/go/testdata/script/build_overlay.txt b/src/cmd/go/testdata/script/build_overlay.txt index 5f598f37e7..3c14e0b558 100644 --- a/src/cmd/go/testdata/script/build_overlay.txt +++ b/src/cmd/go/testdata/script/build_overlay.txt @@ -51,7 +51,7 @@ go 1.16 package dir2 func PrintMessage() { - printMessage() + printMessage() } -- m/dir/foo.txt -- The build action code currently expects the package directory @@ -61,12 +61,12 @@ TODO(matloob): Remove this requirement. the actual code is in the overlay -- m/overlay.json -- { - "Replace": { - "f.go": "overlay/f.go", - "dir/g.go": "overlay/dir_g.go", - "dir2/i.go": "overlay/dir2_i.go", - "printpath/main.go": "overlay/printpath.go" - } + "Replace": { + "f.go": "overlay/f.go", + "dir/g.go": "overlay/dir_g.go", + "dir2/i.go": "overlay/dir2_i.go", + "printpath/main.go": "overlay/printpath.go" + } } -- m/overlay/f.go -- package main @@ -74,7 +74,7 @@ package main import "m/dir2" func main() { - dir2.PrintMessage() + dir2.PrintMessage() } -- m/overlay/dir_g.go -- package dir @@ -82,19 +82,24 @@ package dir import "fmt" func PrintMessage() { - fmt.Println("hello") + fmt.Println("hello") } -- m/overlay/printpath.go -- package main import ( - "fmt" - "runtime" + "fmt" + "path/filepath" + "runtime" ) func main() { - _, file, _, _ := runtime.Caller(0) - fmt.Println(file) + _, file, _, _ := runtime.Caller(0) + + // Since https://golang.org/cl/214286, the runtime's debug paths are + // slash-separated regardless of platform, so normalize them to system file + // paths. + fmt.Println(filepath.FromSlash(file)) } -- m/overlay/dir2_i.go -- package dir2 @@ -102,5 +107,5 @@ package dir2 import "m/dir" func printMessage() { - dir.PrintMessage() + dir.PrintMessage() } -- 2.50.0