aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2018-04-24 00:31:17 +0200
committerDaniel Gröber <dxld@darkboxed.org>2018-06-16 04:13:13 +0200
commit7fc3b9d468a4a2997a7fed63e378567f2ef3a401 (patch)
tree115244f1ea5dcd988ceac1f0e9203af493c410bc /tests
parent8648be0324c8f9e5f2904907ae5da3f867ea9f5a (diff)
Drop Cabal<2.0 compiletime support
We still support <2.0 at runtime this only concerns the Cabal version used at cabal-install time.
Diffstat (limited to 'tests')
-rw-r--r--tests/GhcSession.hs47
1 files changed, 20 insertions, 27 deletions
diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs
index 4845565..6e71075 100644
--- a/tests/GhcSession.hs
+++ b/tests/GhcSession.hs
@@ -1,10 +1,7 @@
-{-# LANGUAGE TupleSections, ScopedTypeVariables, CPP #-}
+{-# LANGUAGE TupleSections, ScopedTypeVariables #-}
module Main where
import GHC
-#if __GLASGOW_HASKELL__ <= 706
-import GhcMonad
-#endif
import GHC.Paths (libdir)
import DynFlags
@@ -19,7 +16,7 @@ import System.FilePath ((</>))
import System.Directory
import System.IO
import System.IO.Temp
-import System.Process (readProcess)
+import System.Process (rawSystem, readProcess)
import Distribution.Helper
@@ -31,12 +28,13 @@ main = do
args <- getArgs
topdir <- getCurrentDirectory
res <- mapM (setup topdir test) $ case args of
- [] -> [ ("tests/exelib" , parseVer "1.10")
- , ("tests/exeintlib", parseVer "2.0")
- , ("tests/fliblib" , parseVer "2.0")
- , ("tests/bkpregex" , parseVer "2.0")
+ [] -> [ ("tests/exelib" , parseVer "1.10", parseVer "0")
+ , ("tests/exeintlib", parseVer "2.0", parseVer "0")
+ , ("tests/fliblib" , parseVer "2.0", parseVer "0")
+ , ("tests/bkpregex" , parseVer "2.0", parseVer "8.1")
+ -- min Cabal lib ver -^ min GHC ver -^
]
- xs -> map (,parseVer "0") xs
+ xs -> map (, parseVer "0", parseVer "0") xs
if any (==False) $ concat res
then exitFailure
@@ -46,21 +44,29 @@ cabalInstallVersion :: IO Version
cabalInstallVersion =
parseVer . trim <$> readProcess "cabal" ["--numeric-version"] ""
+ghcVersion :: IO Version
+ghcVersion =
+ parseVer . trim <$> readProcess "ghc" ["--numeric-version"] ""
+
cabalInstallBuiltinCabalVersion :: IO Version
cabalInstallBuiltinCabalVersion =
parseVer . trim <$> readProcess "cabal"
["act-as-setup", "--", "--numeric-version"] ""
-setup :: FilePath -> (FilePath -> IO [Bool]) -> (FilePath, Version) -> IO [Bool]
-setup topdir act (srcdir, min_cabal_ver) = do
+setup :: FilePath -> (FilePath -> IO [Bool]) -> (FilePath, Version, Version) -> IO [Bool]
+setup topdir act (srcdir, min_cabal_ver, min_ghc_ver) = do
ci_ver <- cabalInstallVersion
c_ver <- cabalInstallBuiltinCabalVersion
+ g_ver <- ghcVersion
let mreason
| (ci_ver < parseVer "1.24") =
Just $ "cabal-install-" ++ showVersion ci_ver ++ " is too old"
| c_ver < min_cabal_ver =
Just $ "Cabal-" ++ showVersion c_ver
++ " < " ++ showVersion min_cabal_ver
+ | g_ver < min_ghc_ver =
+ Just $ "ghc-" ++ showVersion g_ver
+ ++ " < " ++ showVersion min_ghc_ver
| otherwise =
Nothing
@@ -82,8 +88,7 @@ setup topdir act (srcdir, min_cabal_ver) = do
run :: String -> [String] -> IO ()
run x xs = do
print $ x:xs
- o <- readProcess x xs ""
- putStrLn o
+ ExitSuccess <- rawSystem x xs
return ()
test :: FilePath -> IO [Bool]
@@ -116,11 +121,7 @@ compileModule nb ep opts = do
E.handle (\(ec :: ExitCode) -> print ec >> return False) $ do
-#if __GLASGOW_HASKELL__ <= 704
- defaultErrorHandler defaultLogAction $ do
-#else
defaultErrorHandler defaultFatalMessager defaultFlushOut $ do
-#endif
runGhc (Just libdir) $ do
@@ -165,7 +166,6 @@ compileModule nb ep opts = do
setTargets ts'
_ <- load LoadAllTargets
-#if __GLASGOW_HASKELL__ >= 706
when (nb == NoBuildOutput) $ do
setContext $ case ep of
ChLibEntrypoint ms ms' ss ->
@@ -174,16 +174,9 @@ compileModule nb ep opts = do
map (IIModule . mkModuleName . unChModuleName) $ ChModuleName "Main" : ms
ChSetupEntrypoint ->
map (IIModule . mkModuleName) ["Main"]
-#endif
- liftIO'CH $ print ExitSuccess
+ liftIO $ print ExitSuccess
return True
unChModuleName :: ChModuleName -> String
unChModuleName (ChModuleName mn) = mn
-
-#if __GLASGOW_HASKELL__ <= 706
-liftIO'CH = GhcMonad.liftIO
-#else
-liftIO'CH = liftIO
-#endif