install test

This commit is contained in:
Lei Zhu
2023-07-22 23:10:27 +08:00
parent dc1a813305
commit aafb77df7c
6 changed files with 241 additions and 15 deletions

View File

@@ -2,10 +2,8 @@
module SetTest where
import GHCup.OptParse as GHCup
import GHCup.OptParse
import Test.Tasty
import Test.Tasty.HUnit
import Control.Monad.IO.Class (liftIO)
import GHCup.Types
import Data.Versions
import Data.List.NonEmpty (NonEmpty ((:|)))
@@ -15,23 +13,13 @@ setTests :: TestTree
setTests =
testGroup "set"
$ map
buildTestTree
(buildTestTree setParseWith)
[ ("old-style", oldStyleCheckList)
, ("ghc", setGhcCheckList)
, ("cabal", setCabalCheckList)
, ("hls", setHlsCheckList)
, ("stack", setStackCheckList)
]
where
buildTestTree :: (String, [(String, Either SetCommand SetOptions)]) -> TestTree
buildTestTree (title, checkList) =
testGroup title
$ zipWith (uncurry . check) [1 :: Int ..] checkList
check :: Int -> String -> Either SetCommand SetOptions -> TestTree
check idx args expected = testCase (padLeft 2 (show idx) ++ "." ++ args) $ do
res <- setParseWith (words args)
liftIO $ res @?= expected
oldStyleCheckList :: [(String, Either SetCommand SetOptions)]
oldStyleCheckList = mapSecond (Right . SetOptions)