...

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

Documentation: cmd/go/testdata/script

     1# Regression test for issue #48557.
     2# Since builds in module mode do not support relative imports at all, the build
     3# ID for (and other contents of) a binary built with -trimpath in module mode
     4# should not depend on its working directory, even if the binary is specified as
     5# a list of relative source files.
     6
     7[short] skip  # links and runs binaries
     8
     9env GOFLAGS=-trimpath
    10env GOCACHE=$WORK/gocache
    11
    12
    13# When we build a binary in module mode with -trimpath, the -D flag (for the
    14# "local import prefix") should not be passed to it.
    15
    16cd $WORK/tmp/foo
    17go build -x -o a.exe main.go
    18stderr ${/}compile$GOEXE.*' -nolocalimports'
    19! stderr ${/}compile$GOEXE.*' -D[ =]'
    20
    21go tool buildid a.exe
    22cp stdout ../foo-buildid.txt
    23go version a.exe
    24cp stdout ../foo-version.txt
    25cd ..
    26
    27
    28# On the second build — in a different directory but with -trimpath — the
    29# compiler should not be invoked, since the cache key should be identical.
    30# Only the linker and buildid tool should be needed.
    31
    32mkdir bar
    33cp foo/main.go bar/main.go
    34cd bar
    35go build -x -o a.exe main.go
    36! stderr ${/}compile$GOEXE
    37
    38go tool buildid a.exe
    39cp stdout ../bar-buildid.txt
    40go version a.exe
    41cp stdout ../bar-version.txt
    42cd ..
    43
    44cmp bar-buildid.txt foo-buildid.txt
    45cmp bar-version.txt foo-version.txt
    46cmp bar/a.exe foo/a.exe
    47
    48
    49-- $WORK/tmp/foo/main.go --
    50package main
    51
    52func main() {}

View as plain text