Text file
src/cmd/go/testdata/script/mod_build_trimpath_issue48557.txt
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
9 env GOFLAGS=-trimpath
10 env 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
16 cd $WORK/tmp/foo
17 go build -x -o a.exe main.go
18 stderr ${/}compile$GOEXE.*' -nolocalimports'
19 ! stderr ${/}compile$GOEXE.*' -D[ =]'
20
21 go tool buildid a.exe
22 cp stdout ../foo-buildid.txt
23 go version a.exe
24 cp stdout ../foo-version.txt
25 cd ..
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
32 mkdir bar
33 cp foo/main.go bar/main.go
34 cd bar
35 go build -x -o a.exe main.go
36 ! stderr ${/}compile$GOEXE
37
38 go tool buildid a.exe
39 cp stdout ../bar-buildid.txt
40 go version a.exe
41 cp stdout ../bar-version.txt
42 cd ..
43
44 cmp bar-buildid.txt foo-buildid.txt
45 cmp bar-version.txt foo-version.txt
46 cmp bar/a.exe foo/a.exe
47
48
49 -- $WORK/tmp/foo/main.go --
50 package main
51
52 func main() {}
53
View as plain text