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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
#!/usr/bin/env bash
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
set -e
goos=$(go env GOOS)
defer_panic_recover="
defer
defer2
"
effective_go="
eff_bytesize
eff_qr
eff_sequence
eff_unused2
"
error_handling="
error
error2
error3
error4
"
law_of_reflection="
interface
interface2
"
c_go_cgo="
cgo1
cgo2
cgo3
cgo4
"
# cgo1 and cgo2 don't run on freebsd, srandom has a different signature
if [ "$goos" == "freebsd" ]; then
c_go_cgo="cgo3 cgo4"
fi
# cgo1 and cgo2 don't run on netbsd, srandom has a different signature
# cgo3 and cgo4 don't run on netbsd, since cgo cannot handle stdout correctly
if [ "$goos" == "netbsd" ]; then
c_go_cgo=""
fi
# cgo3 and cgo4 don't run on openbsd, since cgo cannot handle stdout correctly
if [ "$goos" == "openbsd" ]; then
c_go_cgo="cgo1 cgo2"
fi
if [ "$CGO_ENABLED" != 1 ]; then
c_go_cgo=""
fi
timeout="
timeout1
timeout2
"
gobs="
gobs1
gobs2
"
json="
json1
json2
json3
json4
json5
"
image_package="
image_package1
image_package2
image_package3
image_package4
image_package5
image_package6
"
all=$(echo $defer_panic_recover $effective_go $error_handling $law_of_reflection $c_go_cgo $timeout $gobs $json $image_package slices go1)
for i in $all; do
go build $i.go
done
# Write to temporary file to avoid mingw bash bug.
TMPFILE="${TMPDIR:-/tmp}/gotest3.$USER"
function testit {
./$1 >"$TMPFILE" 2>&1 || true
x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
if ! echo "$x" | grep "$2" > /dev/null
then
echo $1 failed: '"'$x'"' is not '"'$2'"'
fi
}
testit defer '^0 3210 2$'
testit defer2 '^Calling g. Printing in g 0 Printing in g 1 Printing in g 2 Printing in g 3 Panicking! Defer in g 3 Defer in g 2 Defer in g 1 Defer in g 0 Recovered in f 4 Returned normally from f.$'
testit eff_bytesize '^1.00YB 9.09TB$'
testit eff_sequence '^\[-1 2 6 16 44\]$'
testit go1 '^Christmas is a holiday: true Sleeping for 0.123s.*go1.go already exists$'
testit interface2 "^type: float64$"
testit json1 "^$"
testit json2 "the reciprocal of i is"
testit json3 "Age is int 6"
testit json4 "^$"
testit image_package1 "^X is 2 Y is 1$"
testit image_package2 "^3 4 false$"
testit image_package3 "^3 4 true$"
testit image_package4 "^image.Point{X:2, Y:1}$"
testit image_package5 "^{255 0 0 255}$"
testit image_package6 "^8 4 true$"
rm -f $all "$TMPFILE"
|