Add a CPP macro for checking the version of QuickCheck
authorPetr Pudlak <pudlak@google.com>
Mon, 22 Jun 2015 12:41:07 +0000 (14:41 +0200)
committerPetr Pudlak <pudlak@google.com>
Mon, 22 Jun 2015 16:14:28 +0000 (18:14 +0200)
.. to TestCommon as a preparation for cherry-picking changes that
need it.

The macro and the version detection will be removed in 2.14 where the
functionality is replaced with cabal.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

Makefile.am
test/hs/Test/Ganeti/TestCommon.hs

index 29c06d8..c9fd066 100644 (file)
@@ -1211,6 +1211,13 @@ hs-pkg-versions:
           -DMONAD_CONTROL_MAJOR=\1 -DMONAD_CONTROL_MINOR=\2 -DMONAD_CONTROL_REV=\3/'\
          -e 's/^\s*//' \
        >> $@
+       ghc-pkg list --simple-output QuickCheck \
+       | sed -r -e '$$!d' \
+         -e 's/^QuickCheck-([0-9]+(\.[0-9]+)*)/\1 0 0 0/' \
+         -e 's/\./ /g' -e 's/([0-9]+) *([0-9]+) *([0-9]+) .*/\
+          -DQUICKCHECK_MAJOR=\1 -DQUICKCHECK_MINOR=\2 -DQUICKCHECK_REV=\3/'\
+         -e 's/^\s*//' \
+       >> $@
 
 HS_MAKEFILE_GHC_SRCS = $(HS_SRC_PROGS:%=%.hs)
 if WANT_HSTESTS
index 015601f..0b8e83e 100644 (file)
@@ -83,6 +83,14 @@ module Test.Ganeti.TestCommon
   , getTempFileName
   ) where
 
+-- The following macro is just a temporary solution for 2.12 and 2.13.
+-- Since 2.14 cabal creates proper macros for all dependencies.
+#define MIN_VERSION_QuickCheck(maj,min,rev) \
+  (((maj)<QUICKCHECK_MAJOR)|| \
+   (((maj)==QUICKCHECK_MAJOR)&&((min)<=QUICKCHECK_MINOR))|| \
+   (((maj)==QUICKCHECK_MAJOR)&&((min)==QUICKCHECK_MINOR)&& \
+    ((rev)<=QUICKCHECK_REV)))
+
 import Control.Applicative
 import Control.Exception (catchJust)
 import Control.Monad