...

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

Documentation: cmd/go/testdata/script

     1env GO111MODULE=off
     2env GODEBUG=gocachetest=1
     3
     4[!compiler:gc] skip
     5[short] skip # clears cache, rebuilds too much
     6
     7# Set up fresh GOCACHE.
     8env GOCACHE=$WORK/gocache
     9mkdir $GOCACHE
    10
    11# Building a trivial non-main package should run compiler the first time.
    12go build -x -gcflags=-m lib.go
    13stderr 'compile( |\.exe"?)'
    14stderr 'lib.go:2.* can inline f'
    15
    16# ... but not the second, even though it still prints the compiler output.
    17go build -x -gcflags=-m lib.go
    18! stderr 'compile( |\.exe"?)'
    19stderr 'lib.go:2.* can inline f'
    20
    21# Building a trivial main package should run the compiler and linker the first time.
    22go build -x -gcflags=-m -ldflags='-v -w' main.go
    23stderr 'compile( |\.exe"?)'
    24stderr 'main.go:2.* can inline main' # from compiler
    25stderr 'link(\.exe"?)? -'
    26stderr '\d+ symbols' # from linker
    27
    28# ... but not the second, even though it still prints the compiler and linker output.
    29go build -x -gcflags=-m -ldflags='-v -w' main.go
    30! stderr 'compile( |\.exe"?)'
    31stderr 'main.go:2.* can inline main' # from compiler
    32! stderr 'link(\.exe"?)? -'
    33stderr '\d+ symbols' # from linker
    34
    35# Running a test should run the compiler, linker, and the test the first time.
    36go test -v -x -gcflags=-m -ldflags=-v p
    37stderr 'compile( |\.exe"?)'
    38stderr 'p_test.go:.*can inline Test' # from compile of p_test
    39stderr 'testmain\.go:.*inlin' # from compile of testmain
    40stderr 'link(\.exe"?)? -'
    41stderr '\d+ symbols' # from linker
    42stderr 'p\.test( |\.exe"?)'
    43stdout 'TEST' # from test
    44
    45# ... but not the second, even though it still prints the compiler, linker, and test output.
    46go test -v -x -gcflags=-m -ldflags=-v p
    47! stderr 'compile( |\.exe"?)'
    48stderr 'p_test.go:.*can inline Test' # from compile of p_test
    49stderr 'testmain\.go:.*inlin' # from compile of testmain
    50! stderr 'link(\.exe"?)? -'
    51stderr '\d+ symbols' # from linker
    52! stderr 'p\.test( |\.exe"?)'
    53stdout 'TEST' # from test
    54
    55
    56-- lib.go --
    57package p
    58func f(x *int) *int { return x }
    59
    60-- main.go --
    61package main
    62func main() {}
    63
    64-- p/p_test.go --
    65package p
    66import "testing"
    67func Test(t *testing.T) {println("TEST")}

View as plain text