...

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

Documentation: cmd/go/testdata/script

     1[short] skip
     2[!cgo] skip
     3
     4[!exec:/usr/bin/env] skip
     5[!exec:bash] skip
     6
     7mkdir $WORK/tmp/cache
     8env GOCACHE=$WORK/tmp/cache
     9
    10# Before building our test main.go, ensure that an up-to-date copy of
    11# runtime/cgo is present in the cache. If it isn't, the 'go build' step below
    12# will fail with "can't open import". See golang.org/issue/29004.
    13#
    14# (The fix in golang.org/issue/29004 didn't completely fix the underlying issue:
    15# cmd/go/internal/load adds a bunch of implicit dependencies
    16# based on various heuristics, and, due to a bug described in
    17# https://golang.org/issue/31544#issuecomment-490607180,
    18# those implicit dependencies are not added early enough during
    19# loading to properly affect the import graph.)
    20go build runtime/cgo
    21
    22go build -x -o main main.go
    23cp stderr commands.txt
    24cat header.txt commands.txt
    25cp stdout test.sh
    26
    27exec ./main
    28cmp stderr hello.txt
    29rm ./main
    30
    31exec /usr/bin/env bash -x test.sh
    32exec ./main
    33cmp stderr hello.txt
    34
    35grep '^WORK=(.*)\n' commands.txt
    36
    37-- main.go --
    38package main
    39
    40import "C"
    41
    42func main() {
    43	print("hello\n")
    44}
    45-- header.txt --
    46set -e
    47-- hello.txt --
    48hello

View as plain text