summaryrefslogtreecommitdiff
path: root/test/testlib
diff options
context:
space:
mode:
authorAnthony Martin <ality@pbrane.org>2013-08-13 12:25:41 -0400
committerAnthony Martin <ality@pbrane.org>2013-08-13 12:25:41 -0400
commit037bc7f20827578de55a209f28398e0d710315dc (patch)
tree3881430de896b2d886307813807e0c4f09d4fb26 /test/testlib
parentefc4ea55773e70ec0d4a742500b302a17c282e7f (diff)
downloadgo-037bc7f20827578de55a209f28398e0d710315dc.tar.gz
test/run: process build tags like go/build
R=bradfitz, dave, rsc, r CC=golang-dev https://codereview.appspot.com/10001045 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'test/testlib')
-rw-r--r--test/testlib51
1 files changed, 36 insertions, 15 deletions
diff --git a/test/testlib b/test/testlib
index de138b1d1..4a17f4feb 100644
--- a/test/testlib
+++ b/test/testlib
@@ -16,29 +16,50 @@ pkgs() {
done | sort
}
+_match() {
+ case $1 in
+ *,*)
+ #echo >&2 "match comma separated $1"
+ first=$(echo $1 | sed 's/,.*//')
+ rest=$(echo $1 | sed 's/[^,]*,//')
+ if _match $first && _match $rest; then
+ return 0
+ fi
+ return 1
+ ;;
+ '!'*)
+ #echo >&2 "match negation $1"
+ neg=$(echo $1 | sed 's/^!//')
+ if _match $neg; then
+ return 1
+ fi
+ return 0
+ ;;
+ $GOARCH|$GOOS)
+ #echo >&2 "match GOARCH or GOOS $1"
+ return 0
+ ;;
+ esac
+ return 1
+}
+
# +build aborts execution if the supplied tags don't match,
# i.e. none of the tags (x or !x) matches GOARCH or GOOS.
+build() {
if (( $# == 0 )); then
return
fi
+ m=0
for tag; do
- case $tag in
- $GOARCH|$GOOS)
- #echo >&2 "match $tag in $1"
- return # don't exclude.
- ;;
- '!'$GOARCH|'!'$GOOS)
- ;;
- '!'*)
- # not x where x is neither GOOS nor GOARCH.
- #echo >&2 "match $tag in $1"
- return # don't exclude
- ;;
- esac
+ if _match $tag; then
+ m=1
+ fi
done
- # no match.
- exit 0
+ if [ $m = 0 ]; then
+ #echo >&2 no match
+ exit 0
+ fi
+ unset m
}
compile() {