aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/build_trimpath.txt
blob: 668f75599e77b406b0a10b4f47d92725cb183b44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
[short] skip

env -r GOROOT_REGEXP=$GOROOT
env -r WORK_REGEXP='$WORK'  # don't expand $WORK; grep replaces $WORK in text before matching.
env GOROOT GOROOT_REGEXP WORK WORK_REGEXP

# A binary built without -trimpath should contain the current workspace
# and GOROOT for debugging and stack traces.
cd a
go build -o hello.exe hello.go
grep -q $WORK_REGEXP hello.exe
grep -q $GOROOT_REGEXP hello.exe

# A binary built with -trimpath should not contain the current workspace
# or GOROOT.
go build -trimpath -o hello.exe hello.go
! grep -q $GOROOT_REGEXP hello.exe
! grep -q $WORK_REGEXP hello.exe
cd ..

# A binary from an external module built with -trimpath should not contain
# the current workspace or GOROOT.
env GO111MODULE=on
go build -trimpath -o fortune.exe rsc.io/fortune
! grep -q $GOROOT_REGEXP fortune.exe
! grep -q $WORK_REGEXP fortune.exe

# Two binaries built from identical packages in different directories
# should be identical.
mkdir b
cp a/go.mod a/hello.go b
cd a
go build -trimpath -o ../a.exe .
cd ../b
go build -trimpath -o ../b.exe .
cd ..
cmp -q a.exe b.exe

-- a/hello.go --
package main
func main() { println("hello") }

-- a/go.mod --
module m