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

     1  [short] skip
     2  [!cgo] skip
     3  
     4  [!exec:/usr/bin/env] skip
     5  [!exec:bash] skip
     6  
     7  mkdir $WORK/tmp/cache
     8  env 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.)
    20  go build runtime/cgo
    21  
    22  go build -x -o main main.go
    23  cp stderr commands.txt
    24  cat header.txt commands.txt
    25  cp stdout test.sh
    26  
    27  exec ./main
    28  cmp stderr hello.txt
    29  rm ./main
    30  
    31  exec /usr/bin/env bash -x test.sh
    32  exec ./main
    33  cmp stderr hello.txt
    34  
    35  grep '^WORK=(.*)\n' commands.txt
    36  
    37  -- main.go --
    38  package main
    39  
    40  import "C"
    41  
    42  func main() {
    43  	print("hello\n")
    44  }
    45  -- header.txt --
    46  set -e
    47  -- hello.txt --
    48  hello
    49  

View as plain text