From 5de35550e6be0c6a6f362ef2d5b1d0cd540f700e Mon Sep 17 00:00:00 2001 From: John Shahid Date: Wed, 9 Oct 2013 12:08:30 -0400 Subject: [PATCH] able to run tests in one package only. --- test.sh | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 32e2d407e6..1a9af8210e 100755 --- a/test.sh +++ b/test.sh @@ -5,6 +5,31 @@ set -e cd `dirname $0` . exports.sh +function print_usage { + echo "$0 [-o] [-p]" + echo " -o|--only: Run the test that matches the given regex" + echo " -p|--packages: Run the test in the given packages only" + echo " -h|--help: Prints this help message" +} + +TEMP=`getopt -o hp:o: --long help,only:,packages: \ + -n $0 -- "$@"` + +if [ $? != 0 ] ; then print_usage ; exit 1 ; fi + +# Note the quotes around `$TEMP': they are essential! +eval set -- "$TEMP" + +while true ; do + case "$1" in + -h|--help) print_usage; exit 1; shift;; + -o|--only) regex=$2; shift 2;; + -p|--packages) test_packages="$test_packages $2"; shift 2;; + --) shift ; break ;; + *) echo "Internal error!" ; exit 1 ;; + esac +done + pushd src/parser ./build_parser.sh if [ "x`uname`" == "xLinux" ]; then @@ -21,6 +46,9 @@ go fmt $packages ./build.sh -echo "Running tests for packages: $packages" +[ "x$test_packages" == "x" ] && test_packages="$packages" +echo "Running tests for packages: $test_packages" -go test $packages -v -gocheck.v +[ "x$regex" != "x" ] && gocheck_args="-gocheck.f $regex" + +go test $test_packages -v -gocheck.v $gocheck_args