2009-11-18 10:11:17 -07:00
#!/usr/bin/env bash
2008-09-17 13:14:52 -06:00
# 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.
2010-03-30 11:34:57 -06:00
set -e
2012-03-12 18:55:16 -06:00
goos=$(go env GOOS)
2011-12-11 19:15:29 -07:00
defer_panic_recover="
2012-03-04 18:49:31 -07:00
defer
defer2
2011-12-11 19:15:29 -07:00
"
effective_go="
2012-03-04 18:49:31 -07:00
eff_bytesize
eff_qr
eff_sequence
2013-03-08 11:41:20 -07:00
eff_unused2
2011-12-11 19:15:29 -07:00
"
2011-12-12 15:44:06 -07:00
error_handling="
2012-03-04 18:49:31 -07:00
error
error2
error3
error4
2011-12-12 15:44:06 -07:00
"
2012-03-06 14:05:10 -07:00
law_of_reflection="
interface
interface2
"
2012-03-12 16:07:37 -06:00
c_go_cgo="
2012-03-12 18:55:16 -06:00
cgo1
cgo2
cgo3
cgo4
2012-03-12 16:07:37 -06:00
"
2012-03-12 18:55:16 -06:00
# cgo1 and cgo2 don't run on freebsd, srandom has a different signature
if [ "$goos" == "freebsd" ]; then
c_go_cgo="cgo3 cgo4"
fi
2012-06-04 09:43:04 -06:00
# 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
2012-12-20 07:43:19 -07:00
# cgo3 and cgo4 don't run on openbsd, since cgo cannot handle stdout correctly
if [ "$goos" == "openbsd" ]; then
c_go_cgo="cgo1 cgo2"
fi
2012-03-12 16:07:37 -06:00
2012-03-13 20:03:11 -06:00
timeout="
timeout1
timeout2
"
2012-03-15 15:21:13 -06:00
gobs="
gobs1
gobs2
"
2012-03-22 01:25:40 -06:00
json="
json1
json2
json3
json4
json5
"
2012-03-27 21:20:51 -06:00
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)
2012-03-04 18:49:31 -07:00
for i in $all; do
go build $i.go
2008-09-17 13:14:52 -06:00
done
2011-10-14 13:37:07 -06:00
# Write to temporary file to avoid mingw bash bug.
2012-03-06 14:05:10 -07:00
TMPFILE="${TMPDIR:-/tmp}/gotest3.$USER"
2011-10-14 13:37:07 -06:00
2008-09-17 13:14:52 -06:00
function testit {
2012-03-04 18:49:31 -07:00
./$1 >"$TMPFILE" 2>&1 || true
2011-10-14 13:37:07 -06:00
x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
2012-03-04 18:49:31 -07:00
if ! echo "$x" | grep "$2" > /dev/null
2008-09-17 13:14:52 -06:00
then
2012-03-04 18:49:31 -07:00
echo $1 failed: '"'$x'"' is not '"'$2'"'
2008-09-17 13:14:52 -06:00
fi
}
2012-03-04 18:49:31 -07:00
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.$'
2008-09-17 13:14:52 -06:00
2012-03-04 18:49:31 -07:00
testit eff_bytesize '^1.00YB 9.09TB$'
testit eff_sequence '^\[-1 2 6 16 44\]$'
2011-08-22 06:46:59 -06:00
2012-03-04 18:49:31 -07:00
testit go1 '^Christmas is a holiday: true Sleeping for 0.123s.*go1.go already exists$'
2011-12-07 17:11:17 -07:00
2012-03-06 14:05:10 -07:00
testit interface2 "^type: float64$"
2012-03-27 21:20:51 -06:00
2012-03-22 01:25:40 -06:00
testit json1 "^$"
testit json2 "the reciprocal of i is"
testit json3 "Age is int 6"
testit json4 "^$"
2012-03-06 14:05:10 -07:00
2012-03-27 21:20:51 -06:00
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$"
2012-03-04 18:49:31 -07:00
rm -f $all "$TMPFILE"