summaryrefslogtreecommitdiff
path: root/src/cmd/gofmt/testdata/test.sh
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
committerOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
commit3e45412327a2654a77944249962b3652e6142299 (patch)
treebc3bf69452afa055423cbe0c5cfa8ca357df6ccf /src/cmd/gofmt/testdata/test.sh
parentc533680039762cacbc37db8dc7eed074c3e497be (diff)
downloadgolang-upstream/2011.01.12.tar.gz
Imported Upstream version 2011.01.12upstream/2011.01.12
Diffstat (limited to 'src/cmd/gofmt/testdata/test.sh')
-rwxr-xr-xsrc/cmd/gofmt/testdata/test.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/cmd/gofmt/testdata/test.sh b/src/cmd/gofmt/testdata/test.sh
new file mode 100755
index 000000000..a1d5d823e
--- /dev/null
+++ b/src/cmd/gofmt/testdata/test.sh
@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+# Copyright 2010 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.
+
+CMD="../gofmt"
+TMP=test_tmp.go
+COUNT=0
+
+
+cleanup() {
+ rm -f $TMP
+}
+
+
+error() {
+ echo $1
+ exit 1
+}
+
+
+count() {
+ #echo $1
+ let COUNT=$COUNT+1
+ let M=$COUNT%10
+ if [ $M == 0 ]; then
+ echo -n "."
+ fi
+}
+
+
+test() {
+ count $1
+
+ # compare against .golden file
+ cleanup
+ $CMD -s $1 > $TMP
+ cmp -s $TMP $2
+ if [ $? != 0 ]; then
+ diff $TMP $2
+ error "Error: simplified $1 does not match $2"
+ fi
+
+ # make sure .golden is idempotent
+ cleanup
+ $CMD -s $2 > $TMP
+ cmp -s $TMP $2
+ if [ $? != 0 ]; then
+ diff $TMP $2
+ error "Error: $2 is not idempotent"
+ fi
+}
+
+
+runtests() {
+ smoketest=../../../pkg/go/parser/parser.go
+ test $smoketest $smoketest
+ test composites.input composites.golden
+ # add more test cases here
+}
+
+
+runtests
+cleanup
+echo "PASSED ($COUNT tests)"