]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix TestScript/build_json on Windows
authorAustin Clements <austin@google.com>
Mon, 18 Nov 2024 03:18:02 +0000 (22:18 -0500)
committerAustin Clements <austin@google.com>
Mon, 18 Nov 2024 16:36:43 +0000 (16:36 +0000)
The file system directory separator affects this test's output.

Fixes #70397.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-linux-amd64-longtest
Change-Id: Id8a3f3e1c26c94ea8f635df4e62e7b0cc2cd5515
Reviewed-on: https://go-review.googlesource.com/c/go/+/628916
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/go/testdata/script/build_json.txt
src/cmd/go/testdata/script/test_json_build.txt

index 4506660fe6e58a9dc873f4741967a6b3ef7d4046..716bdf4fa9dab687fbfc8f9f2a61a874a3762fe0 100644 (file)
@@ -3,7 +3,7 @@
 # Basic build error. This test also checks that the output is fully-formed JSON.
 ! go build -json -o=$devnull ./compileerror
 stdout '^\{"ImportPath":"m/compileerror","Action":"build-output","Output":"# m/compileerror\\n"\}$'
-stdout '^\{"ImportPath":"m/compileerror","Action":"build-output","Output":"compileerror/main.go:3:11: undefined: y\\n"}$'
+stdout '^\{"ImportPath":"m/compileerror","Action":"build-output","Output":"compileerror(/|\\\\)main.go:3:11: undefined: y\\n"}$'
 stdout '^\{"ImportPath":"m/compileerror","Action":"build-fail"\}$'
 ! stderr '.'
 
index d3d0c8bb1ea5c9d5080502ae6b004546d7afb1dd..9587ebca95f984caaec9bf1ee6a048da34564109 100644 (file)
@@ -3,10 +3,17 @@ skip
 
 [short] skip
 
+# There are several places where paths appear in JSON in regexps here.
+# For the path separator we use (/|\\\\).
+# Unfortunately, we can't just use ${/} because, while script test automatically
+# escapes Windows-style \ in regexps, it doesn't know that it needs to escape
+# them *again* for JSON. If we ever teach script test about matching JSON,
+# we can probably fix this.
+
 # Test a build error directly in a test file.
 ! go test -json -o=$devnull ./builderror
 stdout '"ImportPath":"m/builderror \[m/builderror\.test\]","Action":"build-output","Output":"# m/builderror \[m/builderror.test\]\\n"'
-stdout '"ImportPath":"m/builderror \[m/builderror\.test\]","Action":"build-output","Output":"builderror/main_test.go:3:11: undefined: y\\n"'
+stdout '"ImportPath":"m/builderror \[m/builderror\.test\]","Action":"build-output","Output":"builderror(/|\\\\)main_test.go:3:11: undefined: y\\n"'
 stdout '"ImportPath":"m/builderror \[m/builderror\.test\]","Action":"build-fail"'
 stdout '"Action":"start","Package":"m/builderror"'
 stdout '"Action":"output","Package":"m/builderror","Output":"FAIL\\tm/builderror \[build failed\]\\n"'
@@ -16,7 +23,7 @@ stdout '"Action":"fail","Package":"m/builderror","Elapsed":.*,"FailedBuild":"m/b
 # Test a build error in an imported package. Make sure it's attributed to the right package.
 ! go test -json -o=$devnull ./builderror2
 stdout '"ImportPath":"m/builderror2/x","Action":"build-output","Output":"# m/builderror2/x\\n"'
-stdout '"ImportPath":"m/builderror2/x","Action":"build-output","Output":"builderror2/x/main.go:3:11: undefined: y\\n"'
+stdout '"ImportPath":"m/builderror2/x","Action":"build-output","Output":"builderror2(/|\\\\)x(/|\\\\)main.go:3:11: undefined: y\\n"'
 stdout '"ImportPath":"m/builderror2/x","Action":"build-fail"'
 stdout '"Action":"start","Package":"m/builderror2"'
 stdout '"Action":"output","Package":"m/builderror2","Output":"FAIL\\tm/builderror2 \[build failed\]\\n"'
@@ -38,7 +45,7 @@ stdout '"Action":"fail","Package":"m/loaderror","Elapsed":.*,"FailedBuild":"x"'
 ! go test -json -o=$devnull ./veterror
 stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# m/veterror\\n"'
 stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# \[m/veterror\]\\n"'
-stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"veterror/main_test.go:9:9: fmt.Printf format %s reads arg #1, but call has 0 args\\n"'
+stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"veterror(/|\\\\)main_test.go:9:9: fmt.Printf format %s reads arg #1, but call has 0 args\\n"'
 stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-fail"'
 stdout '"Action":"start","Package":"m/veterror"'
 stdout '"Action":"output","Package":"m/veterror","Output":"FAIL\\tm/veterror \[build failed\]\\n"'