summaryrefslogtreecommitdiff
path: root/test/testlib
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-01-02 15:31:49 -0500
committerRuss Cox <rsc@golang.org>2013-01-02 15:31:49 -0500
commit22ec0d37b101267e0c01536d0dd869d7b0a9ad5f (patch)
tree0d125760914fe9c5b1e02491cac0ad2247c5693a /test/testlib
parentfe527908d3b049293899d699f646021cbfc5881a (diff)
downloadgo-22ec0d37b101267e0c01536d0dd869d7b0a9ad5f.tar.gz
test/run: handle compiledir and errorcheckdir with multi-file packages
Multiple files with the same package all get compiled together. R=golang-dev, iant, dave CC=golang-dev https://codereview.appspot.com/7005053
Diffstat (limited to 'test/testlib')
-rw-r--r--test/testlib43
1 files changed, 28 insertions, 15 deletions
diff --git a/test/testlib b/test/testlib
index 5bb5669b7..b58e8831c 100644
--- a/test/testlib
+++ b/test/testlib
@@ -5,14 +5,25 @@
# These function names are also known to
# (and are the plan for transitioning to) run.go.
+# helper (not known to run.go)
+# group file list by packages and return list of packages
+# each package is a comma-separated list of go files.
+pkgs() {
+ pkglist=$(grep -h '^package ' $* | awk '{print $2}' | sort -u)
+ for p in $pkglist
+ do
+ echo $(grep -l "^package $p\$" $*) | tr ' ' ,
+ done | sort
+}
+
compile() {
$G $D/$F.go
}
compiledir() {
- for gofile in $D/$F.dir/*.go
+ for pkg in $(pkgs $D/$F.dir/*.go)
do
- $G -I. "$gofile" || return 1
+ $G -I . $(echo $pkg | tr , ' ') || return 1
done
}
@@ -21,38 +32,40 @@ errorcheckdir() {
if [ "$1" = "-0" ]; then
lastzero="-0"
fi
- files=($D/$F.dir/*.go)
- for gofile in ${files[@]}
+ pkgs=$(pkgs $D/$F.dir/*.go)
+ for pkg in $pkgs.last
do
zero="-0"
- if [ ${files[${#files[@]}-1]} = $gofile ]; then
+ case $pkg in
+ *.last)
+ pkg=$(echo $pkg |sed 's/\.last$//')
zero=$lastzero
- fi
- errchk $zero $G -D. -I. -e $gofile
+ esac
+ errchk $zero $G -D . -I . -e $(echo $pkg | tr , ' ')
done
}
rundir() {
lastfile=""
- for gofile in $D/$F.dir/*.go
+ for pkg in $(pkgs $D/$F.dir/*.go)
do
- name=$(basename ${gofile/\.go/} )
- $G -D. -I. -e "$gofile" || return 1
+ name=$(echo $pkg | sed 's/\.go.*//; s/.*\///')
+ $G -D . -I . -e $(echo $pkg | tr , ' ') || return 1
lastfile=$name
done
- $L -o $A.out -L. $lastfile.$A
+ $L -o $A.out -L . $lastfile.$A
./$A.out
}
rundircmpout() {
lastfile=""
- for gofile in $D/$F.dir/*.go
+ for pkg in $(pkgs $D/$F.dir/*.go)
do
- name=$(basename ${gofile/\.go/} )
- $G -D. -I. -e "$gofile" || return 1
+ name=$(echo $pkg | sed 's/\.go.*//; s/.*\///')
+ $G -D . -I . -e $(echo $pkg | tr , ' ') || return 1
lastfile=$name
done
- $L -o $A.out -L. $lastfile.$A
+ $L -o $A.out -L . $lastfile.$A
./$A.out 2>&1 | cmp - $D/$F.out
}