| [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 |