stderr 'compile.*-pgoprofile=.*prof.*triv.go'
# check that PGO appears in build info
+# N.B. we can't start the stdout check with -pgo because the script assumes that
+# if the first arg starts with - it is a grep flag.
go version -m triv.exe
-stdout '-pgo=.*/prof'
+stdout 'build\s+-pgo=.*'${/}'prof'
# store the build ID
go list -export -json=BuildID -pgo=prof triv.go
# check that path is trimmed
go version -m triv.exe
-stdout '-pgo=prof'
+stdout 'build\s+-pgo=prof'
-- prof --
-- triv.go --
stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
# check that pgo appears in build info
+# N.B. we can't start the stdout check with -pgo because the script assumes that
+# if the first arg starts with - it is a grep flag.
go version -m a1.exe
-stdout '-pgo=.*default\.pgo'
+stdout 'build\s+-pgo=.*default\.pgo'
# use default.pgo for ... with a single main package
go build -a -x -pgo=auto ./a/...
# check that pgo appears in build info
go version -m a1$GOEXE
-stdout '-pgo=.*default\.pgo'
+stdout 'build\s+-pgo=.*default\.pgo'
# build succeeds without PGO when default.pgo file is absent
go build -a -x -pgo=auto -o nopgo.exe ./nopgo
stderr 'compile.*nopgo.go'
-! stderr '-pgoprofile'
+! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
go version -m nopgo.exe
-! stdout -pgo=
+! stdout 'build\s+-pgo='
# other build-related commands
go install -a -n -pgo=auto ./a/a1
# check that pgo appears in build info
go version -m a1.exe
-stdout '-pgo=.*default\.pgo'
+stdout 'build\s+-pgo=.*default\.pgo'
go build -a -x -o nopgo.exe ./nopgo
stderr 'compile.*nopgo.go'
-! stderr '-pgoprofile'
+! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
go version -m nopgo.exe
-! stdout -pgo=
+! stdout 'build\s+-pgo='
# -pgo=off should turn off PGO.
go build -a -x -pgo=off -o a1.exe ./a/a1
stderr 'compile.*a1.go'
-! stderr '-pgoprofile'
+! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
go version -m a1.exe
-! stdout -pgo=
+! stdout 'build\s+-pgo='
-- go.mod --
module test
stderr -count=2 'compile.*-pgoprofile=.*dep3(/|\\\\)dep3\.go'
# check that pgo appears or not in build info as expected
+# N.B. we can't start the stdout check with -pgo because the script assumes that
+# if the first arg starts with - it is a grep flag.
go version -m $GOBIN/a$GOEXE
-stdout '-pgo=.*a'${/}'default\.pgo'
+stdout 'build\s+-pgo=.*a'${/}'default\.pgo'
go version -m $GOBIN/b$GOEXE
-stdout '-pgo=.*b'${/}'default\.pgo'
+stdout 'build\s+-pgo=.*b'${/}'default\.pgo'
go version -m $GOBIN/nopgo$GOEXE
-! stdout -pgo=
+! stdout 'build\s+-pgo='
# go test works the same way
go test -a -n -pgo=auto ./a ./b ./nopgo