github.com/huandu/go@v0.0.0-20151114150818-04e615e41150/misc/cgo/errors/test.bash (about) 1 #!/usr/bin/env bash 2 3 # Copyright 2013 The Go Authors. All rights reserved. 4 # Use of this source code is governed by a BSD-style 5 # license that can be found in the LICENSE file. 6 7 check() { 8 file=$1 9 line=$(grep -n 'ERROR HERE' $file | sed 's/:.*//') 10 if [ "$line" = "" ]; then 11 echo 1>&2 misc/cgo/errors/test.bash: BUG: cannot find ERROR HERE in $file 12 exit 1 13 fi 14 if go build $file >errs 2>&1; then 15 echo 1>&2 misc/cgo/errors/test.bash: BUG: expected cgo to fail but it succeeded 16 exit 1 17 fi 18 if ! test -s errs; then 19 echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output but saw none 20 exit 1 21 fi 22 if ! fgrep $file:$line: errs >/dev/null 2>&1; then 23 echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error on line $line but saw: 24 cat 1>&2 errs 25 exit 1 26 fi 27 } 28 29 check err1.go 30 check err2.go 31 check err3.go 32 check issue7757.go 33 check issue8442.go 34 35 rm -rf errs _obj 36 exit 0