aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-08-06 19:39:23 +0200
committerDaniel Gröber <dxld@darkboxed.org>2020-05-10 21:50:44 +0200
commitbda559bf059ee42e3e01c1280f7a64dd2673d725 (patch)
treebdfe97db7a53bd68638a6a7f102cd0942456e948 /tests
parentf606584fd104f864694e4fb9b943ef13904cdc96 (diff)
Refactor Program versions handling
This mainly renames the program version getters to get* and make them consistenly return Version directly. Such that wrappers like GhcVersion have to be added at the callsites of the relevant functions.
Diffstat (limited to 'tests')
-rw-r--r--tests/CompileTest.hs4
-rw-r--r--tests/GhcSession.hs32
2 files changed, 14 insertions, 22 deletions
diff --git a/tests/CompileTest.hs b/tests/CompileTest.hs
index c0280bf..8af7335 100644
--- a/tests/CompileTest.hs
+++ b/tests/CompileTest.hs
@@ -72,7 +72,7 @@ main = do
case args of
"list-versions":[] -> do
- mapM_ print =<< relevantCabalVersions =<< ghcVersion
+ mapM_ print =<< relevantCabalVersions =<< (GhcVersion <$> getGhcVersion)
"list-versions":ghc_ver_str:[] ->
mapM_ print =<< relevantCabalVersions (GhcVersion (parseVer ghc_ver_str))
_ ->
@@ -125,7 +125,7 @@ allCabalVersions (GhcVersion ghc_ver) = do
testRelevantCabalVersions :: Env => IO ()
testRelevantCabalVersions = do
- ghc_ver <- ghcVersion
+ ghc_ver <- GhcVersion <$> getGhcVersion
relevant_cabal_versions <- relevantCabalVersions ghc_ver
testCabalVersions $ map CabalVersion relevant_cabal_versions ++ [CabalHEAD ()]
diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs
index c776164..c5047ea 100644
--- a/tests/GhcSession.hs
+++ b/tests/GhcSession.hs
@@ -34,12 +34,13 @@ import Text.Show.Pretty (pPrint)
import Distribution.Helper
import CabalHelper.Shared.Common
-import CabalHelper.Compiletime.Types (Env)
+import CabalHelper.Compiletime.Types (Env, Verbose, Progs)
import CabalHelper.Compiletime.Process (readProcess, callProcessStderr)
import CabalHelper.Compiletime.Program.GHC
- (GhcVersion(..), ghcVersion, ghcLibdir)
+ (GhcVersion(..), getGhcVersion, ghcLibdir)
import CabalHelper.Compiletime.Program.CabalInstall
- (CabalInstallVersion(..), cabalInstallVersion)
+ (getCabalInstallVersion, getCabalInstallBuiltinCabalVersion)
+import CabalHelper.Compiletime.Program.Stack (getStackVersion)
import TestOptions
@@ -71,16 +72,16 @@ main = do
?progs = modProgs defaultPrograms
in action
- GhcVersion g_ver <- withEnv ghcVersion
- CabalInstallVersion ci_ver <- withEnv cabalInstallVersion
- s_ver <- withEnv stackVersion
+ g_ver <- withEnv getGhcVersion
+ ci_ver <- withEnv getCabalInstallVersion
+ s_ver <- withEnv getStackVersion
`E.catch` \(_ :: IOError) -> return (makeVersion [0])
-- Cabal lib version
f_c_ver :: ProjType -> Either SkipReason Version <- do
- ci_c_ver <- Right <$> withEnv cabalInstallBuiltinCabalVersion
+ ci_c_ver <- Right <$> withEnv getCabalInstallBuiltinCabalVersion
s_c_ver :: Either SkipReason Version
- <- sequence $ withEnv stackBuiltinCabalVersion s_ver g_ver
+ <- sequence $ withEnv getStackBuiltinCabalVersion s_ver g_ver
return $ \pt -> case pt of
Cabal CV1 -> ci_c_ver
Cabal CV2 -> ci_c_ver
@@ -518,14 +519,10 @@ copyMuliPackageProject progs srcdir destdir copyPkgExtra = do
, "--output-directory="++destdir </> pkgdir ]
copyPkgExtra (srcdir </> pkgdir) (destdir </> pkgdir)
-stackVersion :: (?progs :: Programs) => IO Version
-stackVersion =
- parseVer . trim <$> readProcess (stackProgram ?progs) [ "--numeric-version" ] ""
-
-stackBuiltinCabalVersion
- :: (?progs :: Programs)
+getStackBuiltinCabalVersion
+ :: (Verbose, Progs)
=> Version -> Version -> Either SkipReason (IO Version)
-stackBuiltinCabalVersion s_ver g_ver = do
+getStackBuiltinCabalVersion s_ver g_ver = do
_ <- stackCheckCompat s_ver
res <- lookupStackResolver g_ver
return $ parseVer . trim <$> readProcess (stackProgram ?progs)
@@ -540,11 +537,6 @@ stackCheckCompat s_ver =
| otherwise ->
Right ()
-cabalInstallBuiltinCabalVersion :: (?progs :: Programs) => IO Version
-cabalInstallBuiltinCabalVersion =
- parseVer . trim <$> readProcess (cabalProgram ?progs)
- ["act-as-setup", "--", "--numeric-version"] ""
-
normalizeOutputWithVars = replaceStrings
replaceStrings :: [(String, String)] -> String -> String
replaceStrings ts str =