1
0
mirror of https://github.com/golang/go synced 2024-11-25 10:17:57 -07:00

cmd/go: only attempt to match subset of $GOCACHE in test

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>
This commit is contained in:
Michael Pratt 2024-04-18 13:52:44 -04:00 committed by Gopher Robot
parent ad87d44047
commit 68c0ad3a68

View 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