Integrate tests with TravisCI job
authorHerbert Valerio Riedel <hvr@gnu.org>
Tue, 25 Mar 2014 13:05:47 +0000 (14:05 +0100)
committerHerbert Valerio Riedel <hvr@gnu.org>
Tue, 25 Mar 2014 13:07:48 +0000 (14:07 +0100)
A simple bash runner-script is included as the GHC testsuite runner
isn't available for the Travis-CI job

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
.travis.yml
tests/T2411.stdout.ignore [new file with mode: 0644]
tests/runtests.sh [new file with mode: 0755]
tests/stm050.hs

index 034a8cc..4d77888 100644 (file)
@@ -1,5 +1,5 @@
 env:
- - GHCVER=6.12.3
+# - GHCVER=6.12.3
  - GHCVER=7.0.1
  - GHCVER=7.0.2
  - GHCVER=7.0.3
@@ -11,6 +11,7 @@ env:
  - GHCVER=7.6.1
  - GHCVER=7.6.2
  - GHCVER=7.6.3
+ - GHCVER=7.8.1
  - GHCVER=head
 
 matrix:
@@ -27,6 +28,7 @@ install:
  - cabal-1.18 update
 
 script:
+ - cabal-1.18 install random
  - cabal-1.18 configure -v2
  - cabal-1.18 build
  - cabal-1.18 check
@@ -39,3 +41,5 @@ script:
       echo "expected '$SRC_TGZ' not found";
       exit 1;
    fi
+ - cabal-1.18 install random
+ - tests/runtests.sh
\ No newline at end of file
diff --git a/tests/T2411.stdout.ignore b/tests/T2411.stdout.ignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/runtests.sh b/tests/runtests.sh
new file mode 100755 (executable)
index 0000000..4124fdc
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Simple runner script used for TravisCI (where GHC's testsuite runner isn't available)
+
+set -e
+
+die () {
+    echo "ERROR: $1" >&2;
+    exit 1;
+}
+
+[ -f tests/runtests.sh ] && cd tests/
+
+[ -f runtests.sh ] || die "must be called from inside tests folder"
+
+for T in *.hs;do
+    T=${T%.hs}
+
+    echo "== running test '$T'"
+
+    ghc --make -threaded -O2 --make ${T}.hs
+
+    if ./${T} > ${T}.stdout.run 2> ${T}.stderr.run
+    then
+        echo "${T} exited with code $?"
+    fi
+
+    for FD in stdout stderr; do
+        if [ -f "${T}.${FD}.ignore" ]; then
+            echo "ignoring ${FD} output"
+            continue
+        fi
+        echo "validate ${FD} output..."
+        if [ -f "${T}.${FD}" ]; then REF="${T}.${FD}"; else REF=/dev/null; fi
+        diff -w -u ${REF} ${T}.${FD}.run
+    done
+
+    echo "> '${T}' PASSED"
+
+    rm ${T}.hi ${T}.o ${T} ${T}.stdout.run ${T}.stderr.run
+done
+
+echo "----------------------------------------------------------------------------"
+echo "all tests PASSED!"
index ebb8209..cefeb3d 100644 (file)
@@ -200,8 +200,10 @@ directoryPoster2 n state
   The DirectoryService main process.
 -}
 directoryService
- = do [s] <- getArgs
-      let n = read s :: Int
+ = do args <- getArgs
+      n <- case args of
+        []  -> return 10000
+        [s] -> return (read s :: Int)
 
       c <- atomically (newTChan)
       t <- atomically (newTVar [])