...

Text file src/cmd/go/testdata/script/build_pgo_auto.txt

Documentation: cmd/go/testdata/script

     1# Test go build -pgo=auto flag.
     2
     3[short] skip 'compiles and links executables'
     4
     5# use default.pgo for a single main package
     6go build -n -pgo=auto -o a1.exe ./a/a1
     7stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
     8
     9# check that pgo applied to dependencies
    10stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
    11
    12# check that pgo appears in build info
    13# N.B. we can't start the stdout check with -pgo because the script assumes that
    14# if the first arg starts with - it is a grep flag.
    15stderr 'build\\t-pgo=.*default\.pgo'
    16
    17# check also that -pgo appears with the other flags, before non-flag settings
    18! stderr 'build\\t[A-Za-z].*build\\t-pgo'
    19
    20# use default.pgo for ... with a single main package
    21go build -n -pgo=auto ./a/...
    22stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
    23
    24# check that pgo appears in build info
    25stderr 'build\\t-pgo=.*default\.pgo'
    26
    27# build succeeds without PGO when default.pgo file is absent
    28go build -n -pgo=auto -o nopgo.exe ./nopgo
    29stderr 'compile.*nopgo.go'
    30! stderr 'compile.*-pgoprofile'
    31
    32# check that pgo doesn't appear in build info
    33! stderr 'build\\t-pgo='
    34
    35# other build-related commands
    36go install -a -n -pgo=auto ./a/a1
    37stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
    38
    39go run -a -n -pgo=auto ./a/a1
    40stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
    41
    42go test -a -n -pgo=auto ./a/a1
    43stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go.*a1_test.go'
    44stderr 'compile.*-pgoprofile=.*default\.pgo.*external_test.go'
    45
    46# go list commands should succeed as usual
    47go list -pgo=auto ./a/a1
    48
    49go list -test -pgo=auto ./a/a1
    50
    51go list -deps -pgo=auto ./a/a1
    52
    53# -pgo=auto is the default. Commands without explicit -pgo=auto
    54# should work as -pgo=auto.
    55go build -a -n -o a1.exe ./a/a1
    56stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
    57stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
    58
    59# check that pgo appears in build info
    60stderr 'build\\t-pgo=.*default\.pgo'
    61
    62go build -a -n -o nopgo.exe ./nopgo
    63stderr 'compile.*nopgo.go'
    64! stderr 'compile.*-pgoprofile'
    65
    66# check that pgo doesn't appear in build info
    67! stderr 'build\\t-pgo='
    68
    69# -pgo=off should turn off PGO.
    70go build -a -n -pgo=off -o a1.exe ./a/a1
    71stderr 'compile.*a1.go'
    72! stderr 'compile.*-pgoprofile'
    73
    74# check that pgo doesn't appear in build info
    75! stderr 'build\\t-pgo='
    76
    77-- go.mod --
    78module test
    79go 1.20
    80-- a/a1/a1.go --
    81package main
    82import _ "test/dep"
    83func main() {}
    84-- a/a1/a1_test.go --
    85package main
    86import "testing"
    87func TestA(*testing.T) {}
    88-- a/a1/external_test.go --
    89package main_test
    90import "testing"
    91func TestExternal(*testing.T) {}
    92-- a/a1/default.pgo --
    93-- nopgo/nopgo.go --
    94package main
    95func main() {}
    96-- dep/dep.go --
    97package dep

View as plain text