]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: only attempt to match subset of $GOCACHE in test
authorMichael Pratt <mpratt@google.com>
Thu, 18 Apr 2024 17:52:44 +0000 (13:52 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 18 Apr 2024 18:28:25 +0000 (18:28 +0000)
This test attempted to be clever by looking for the entirety of $GOCACHE
in the compile command line to ensure that the profile was coming from
cache.

Unfortunately, on Windows $GOCACHE contains \, which needs extra
escaping in a regexp. As an approximate alternative, just look for the
"gocache" component specified when defining GOCACHE.

This fixes the Windows longtest builders.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest
Change-Id: If6c77cf066d8612431e0720405254e1fdf528e9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/580137
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>

src/cmd/go/testdata/script/build_cache_pgo.txt

index 5efecab49ee6012c77ee2dc3bcb43e36ed4e4a62..cedae03cf8247a1310e1dc5c66b315ac8723bf81 100644 (file)
@@ -16,10 +16,15 @@ go build -x -pgo=default.pgo lib.go
 go build -a -x -pgo=default.pgo lib.go
 stderr 'preprofile.*default\.pgo'
 
-# ... building a different package should not run preprofile again, instead using a profile from cache.
+# ... building a different package should not run preprofile again, instead
+# using a profile from cache.
+#
+# Note we can't directly look for $GOCACHE in the regex below because the
+# Windows slashes would need to be escaped. Instead just look for the "gocache"
+# component (specified above) as an approximation.
 go build -x -pgo=default.pgo lib2.go
 ! stderr 'preprofile.*default\.pgo'
-stderr 'compile.*-pgoprofile=.*'$GOCACHE'.*lib2.go'
+stderr 'compile.*-pgoprofile=\S+gocache.*lib2.go'
 
 -- lib.go --
 package lib