THRIFT-918 : better haskell tests

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1001883 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/hs/runclient.sh b/test/hs/runclient.sh
index b93bbb1..aab9f17 100644
--- a/test/hs/runclient.sh
+++ b/test/hs/runclient.sh
@@ -19,8 +19,50 @@
 # under the License.
 #
 
+# Check some basic 
 if [ -z $BASE ]; then
     BASE=../..
 fi
 
-ghci -fglasgow-exts -i$BASE/lib/hs/src -i$BASE/test/hs/gen-hs Client.hs
+if [ -z $OUTDIR ]; then
+    OUTDIR=client-bindings
+fi
+
+if [ -z $THRIFT_BIN ]; then
+    THRIFT_BIN=$(which thrift)
+fi
+
+if [ ! -x "$THRIFT_BIN" ]; then
+    printf "Could not find thrift binary; pass it as environment variable THRIFT_BIN\n"
+    exit 1
+fi
+
+# Figure out what file to generate bindings from
+if [ -z $THRIFT_FILE ]; then
+    THRIFT_FILE=$BASE/test/$1.thrift
+fi
+
+if [ ! -e $THRIFT_FILE ]; then
+    printf "Missing thrift file $THRIFT_FILE \n"
+    exit 2
+fi
+
+# Figure out what file to run has a client
+if [ -z $CLIENT_FILE ]; then
+    CLIENT_FILE=$BASE/test/hs/$1_TestClient.hs
+fi
+
+if [ ! -e $CLIENT_FILE ]; then
+    printf "Missing client code file $CLIENT_FILE \n"
+    exit 3
+fi
+
+# Actually run the client bits
+printf "Creating directory $OUTDIR to hold generated bindings... \n"
+[ -d $OUTDIR ] || mkdir $OUTDIR
+
+printf "Generating bindings... \n"
+$THRIFT_BIN -o $OUTDIR --gen hs $THRIFT_FILE
+
+printf "Starting client... \n"
+runhaskell -Wall -Werror -i$BASE/lib/hs/src -i$OUTDIR/gen-hs $CLIENT_FILE