aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2018-05-31 23:54:01 +0200
committerDaniel Gröber <dxld@darkboxed.org>2018-06-17 00:37:57 +0200
commitc98dfac009da30feaefb0b992177d03594b11019 (patch)
tree17bff61a3d5bb6747ac8a3048af48a0459a3527f /tests
parent173b9acc2b05e36615fa9dd9398ff21c3ae52419 (diff)
compile-test: Add list-version command to list Cabal versions
Diffstat (limited to 'tests')
-rw-r--r--tests/CompileTest.hs152
1 files changed, 80 insertions, 72 deletions
diff --git a/tests/CompileTest.hs b/tests/CompileTest.hs
index 6560954..4c1f752 100644
--- a/tests/CompileTest.hs
+++ b/tests/CompileTest.hs
@@ -30,11 +30,9 @@ runReadP'Dist p i = case filter ((=="") . snd) $ Dist.readP_to_S p i of
(a,""):[] -> a
_ -> error $ "Error parsing: " ++ show i
-withinRange'CH :: Either HEAD Version -> VersionRange -> Bool
+withinRange'CH :: Version -> VersionRange -> Bool
withinRange'CH v r =
- withinRange (fromDataVersion v') r
- where
- v' = either (const $ parseVer "1000000000") id v
+ withinRange (fromDataVersion v) r
setupHOME :: IO ()
setupHOME = do
@@ -47,7 +45,15 @@ setupHOME = do
main :: IO ()
main = do
args <- getArgs
-
+ case args of
+ "list-versions":[] -> do
+ mapM_ print =<< (allCabalVersions <$> ghcVersion defaultOptions)
+ "list-versions":ghc_ver_str:[] ->
+ mapM_ print $ allCabalVersions (parseVer ghc_ver_str)
+ _ ->
+ test args
+
+test args = do
let action
| null args = testAllCabalVersions
| otherwise = testCabalVersions $ map parseVer' args
@@ -62,76 +68,78 @@ parseVer' :: String -> Either HEAD Version
parseVer' "HEAD" = Left HEAD
parseVer' v = Right $ parseVer v
+allCabalVersions :: Version -> [Version]
+allCabalVersions ghc_ver = let
+ cabal_versions :: [Version]
+ cabal_versions = map parseVer
+ -- "1.14.0" -- not supported at runtime
+ [ "1.16.0"
+ , "1.16.0.1"
+ , "1.16.0.2"
+ , "1.16.0.3"
+ , "1.18.0"
+ , "1.18.1"
+ , "1.18.1.1"
+ , "1.18.1.2"
+ , "1.18.1.3"
+ , "1.18.1.4"
+ , "1.18.1.5"
+ , "1.18.1.6"
+ , "1.18.1.7"
+ , "1.20.0.0"
+ , "1.20.0.1"
+ , "1.20.0.2"
+ , "1.20.0.3"
+ , "1.20.0.4"
+ , "1.22.0.0"
+ , "1.22.1.0"
+ , "1.22.1.1"
+ , "1.22.2.0"
+ , "1.22.3.0"
+ , "1.22.4.0"
+ , "1.22.5.0"
+ , "1.22.6.0"
+ , "1.22.7.0"
+ , "1.22.8.0"
+ , "1.24.0.0"
+ , "1.24.1.0"
+ , "1.24.2.0"
+ , "2.0.0.2"
+ , "2.0.1.0"
+ , "2.0.1.1"
+ , "2.2.0.0"
+ , "2.2.0.1"
+ ]
+
+ constraint :: VersionRange
+ constraint =
+ fromMaybe (snd $ last constraint_table) $
+ fmap snd $
+ find (and . (zipWith (==) `on` versionBranch) ghc_ver . fst) $
+ constraint_table
+
+ constraint_table =
+ map (parseVer *** runReadP'Dist parse) $
+ [ ("7.4" , ">= 1.14 && < 2")
+ , ("7.6" , ">= 1.16 && < 2")
+ , ("7.8" , ">= 1.18 && < 2")
+ , ("7.10" , ">= 1.22.2 && < 2")
+ , ("8.0.1", ">= 1.24 ")
+ , ("8.0.2", ">= 1.24.2 ")
+ , ("8.2.1", ">= 2.0.0.2 ")
+ , ("8.2.2", ">= 2.0.0.2 ")
+ , ("8.4.1", ">= 2.0.0.2 ")
+ , ("8.4.2", ">= 2.2.0.1 ")
+ ]
+ in
+ reverse $ filter (flip withinRange'CH constraint) cabal_versions
+
+
testAllCabalVersions :: IO ()
testAllCabalVersions = do
- let cabal_versions :: [Either HEAD Version]
- cabal_versions = map parseVer'
- -- "1.14.0" -- not supported at runtime
- [ "1.16.0"
- , "1.16.0.1"
- , "1.16.0.2"
- , "1.16.0.3"
- , "1.18.0"
- , "1.18.1"
- , "1.18.1.1"
- , "1.18.1.2"
- , "1.18.1.3"
- , "1.18.1.4"
- , "1.18.1.5"
- , "1.18.1.6"
- , "1.18.1.7"
- , "1.20.0.0"
- , "1.20.0.1"
- , "1.20.0.2"
- , "1.20.0.3"
- , "1.20.0.4"
- , "1.22.0.0"
- , "1.22.1.0"
- , "1.22.1.1"
- , "1.22.2.0"
- , "1.22.3.0"
- , "1.22.4.0"
- , "1.22.5.0"
- , "1.22.6.0"
- , "1.22.7.0"
- , "1.22.8.0"
- , "1.24.0.0"
- , "1.24.1.0"
- , "1.24.2.0"
- , "2.0.0.2"
- , "2.0.1.0"
- , "2.0.1.1"
- , "2.2.0.0"
- , "2.2.0.1"
- , "HEAD"
- ]
-
ghc_ver <- ghcVersion defaultOptions
-
- let constraint :: VersionRange
- constraint =
- fromMaybe (snd $ last constraint_table) $
- fmap snd $
- find (and . (zipWith (==) `on` versionBranch) ghc_ver . fst) $
- constraint_table
-
- constraint_table =
- map (parseVer *** runReadP'Dist parse) $
- [ ("7.4" , ">= 1.14 && < 2")
- , ("7.6" , ">= 1.16 && < 2")
- , ("7.8" , ">= 1.18 && < 2")
- , ("7.10" , ">= 1.22.2 && < 2")
- , ("8.0.1", ">= 1.24 ")
- , ("8.0.2", ">= 1.24.2 ")
- , ("8.2.1", ">= 2.0.0.2 ")
- , ("8.2.2", ">= 2.0.0.2 ")
- , ("8.4.1", ">= 2.0.0.2 ")
- ]
-
- relevant_cabal_versions =
- reverse $ filter (flip withinRange'CH constraint) cabal_versions
-
- testCabalVersions relevant_cabal_versions
+ let relevant_cabal_versions = allCabalVersions ghc_ver
+ testCabalVersions $ map Right relevant_cabal_versions ++ [Left HEAD]
testCabalVersions :: [Either HEAD Version] -> IO ()
testCabalVersions versions = do