[commit: packages/stm] ghc-7.8: Tweak tests/runtests.sh to make it pass for older GHCs (85108e2)

git at git.haskell.org git at git.haskell.org
Tue Mar 25 19:12:29 UTC 2014


Repository : ssh://git@git.haskell.org/stm

On branch  : ghc-7.8
Link       : http://git.haskell.org/packages/stm.git/commitdiff/85108e21d0a6359fc1f3f29f365c05c59278db30

>---------------------------------------------------------------

commit 85108e21d0a6359fc1f3f29f365c05c59278db30
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Tue Mar 25 20:11:08 2014 +0100

    Tweak tests/runtests.sh to make it pass for older GHCs
    
    Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>


>---------------------------------------------------------------

85108e21d0a6359fc1f3f29f365c05c59278db30
 tests/runtests.sh |   30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/tests/runtests.sh b/tests/runtests.sh
index 4124fdc..2111c9a 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -4,9 +4,28 @@
 
 set -e
 
+GHCVER=$(ghc --numeric-version)
+
+echo "using GHC version: $GHCVER"
+
+# checks if GHC version >= $1
+ghc_minver () {
+    [ "$1" = "$(echo -e "$1\n${GHCVER}" | sort -V | head -n1)" ]
+}
+
+# hard-coded exceptions
+may_fail () {
+    if [ "$1" = "stm064" ] && ! ghc_minver "7.6"; then
+        echo "EXPECTED FAIL: '$1' may fail for GHC < 7.6"
+        return 0
+    fi
+
+    return 1
+}
+
 die () {
-    echo "ERROR: $1" >&2;
-    exit 1;
+    echo "ERROR: $1" >&2
+    exit 1
 }
 
 [ -f tests/runtests.sh ] && cd tests/
@@ -30,9 +49,14 @@ for T in *.hs;do
             echo "ignoring ${FD} output"
             continue
         fi
+
+        # fixup typo in exception message for older GHCs
+        sed -i 's,Transacional invariant,Transactional invariant,g' "${T}.${FD}.run"
+
         echo "validate ${FD} output..."
         if [ -f "${T}.${FD}" ]; then REF="${T}.${FD}"; else REF=/dev/null; fi
-        diff -w -u ${REF} ${T}.${FD}.run
+
+        diff -w -u "${REF}" "${T}.${FD}.run" || may_fail "${T}"
     done
 
     echo "> '${T}' PASSED"



More information about the ghc-commits mailing list