ghcup-hs/test/optparse-test/RunTest.hs

69 lines
2.2 KiB
Haskell
Raw Permalink Normal View History

2023-07-28 15:39:21 +00:00
{-# LANGUAGE OverloadedStrings #-}
2023-09-02 10:47:42 +00:00
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
2023-07-28 15:39:21 +00:00
2023-07-28 15:26:19 +00:00
module RunTest where
import Test.Tasty
import GHCup.OptParse
import Utils
2023-07-28 15:39:21 +00:00
import GHCup.Types
2023-10-13 08:35:39 +00:00
import Data.Versions (versionQ)
2023-07-28 15:26:19 +00:00
runTests :: TestTree
runTests = buildTestTree runParseWith ("run", runCheckList)
defaultOptions :: RunOptions
defaultOptions =
RunOptions
False
False
False
Nothing
Nothing
Nothing
Nothing
Nothing
False
[]
runCheckList :: [(String, RunOptions)]
2023-07-28 15:39:21 +00:00
runCheckList =
[ ("run", defaultOptions)
, ("run -a", defaultOptions{runAppendPATH = True})
, ("run --append", defaultOptions{runAppendPATH = True})
, ("run -i", defaultOptions{runInstTool' = True})
, ("run --install", defaultOptions{runInstTool' = True})
, ("run -m", defaultOptions{runMinGWPath = True})
, ("run --mingw-path", defaultOptions{runMinGWPath = True})
2023-10-13 08:35:39 +00:00
, ("run --ghc 9.2.8", defaultOptions{runGHCVer = Just $ GHCVersion $ mkTVer $(versionQ "9.2.8")})
2023-07-28 15:39:21 +00:00
, ("run --ghc latest", defaultOptions{runGHCVer = Just $ ToolTag Latest})
2023-10-13 08:35:39 +00:00
, ("run --cabal 3.10", defaultOptions{runCabalVer = Just $ ToolVersion $(versionQ "3.10")})
, ("run --hls 2.0", defaultOptions{runHLSVer = Just $ ToolVersion $(versionQ "2.0")})
, ("run --stack 2.9", defaultOptions{runStackVer = Just $ ToolVersion $(versionQ "2.9") })
2023-09-02 10:47:42 +00:00
#ifdef IS_WINDOWS
2024-02-18 12:11:56 +00:00
, ("run -b C:\\\\tmp\\dir", defaultOptions{runBinDir = Just "C:\\tmp\\dir"})
, ("run --bindir C:\\\\tmp\\dir", defaultOptions{runBinDir = Just "C:\\tmp\\dir"})
2023-09-02 10:47:42 +00:00
#else
2023-07-28 15:39:21 +00:00
, ("run -b /tmp/dir", defaultOptions{runBinDir = Just "/tmp/dir"})
, ("run --bindir /tmp/dir", defaultOptions{runBinDir = Just "/tmp/dir"})
2023-09-02 10:47:42 +00:00
#endif
2023-07-28 15:39:21 +00:00
, ("run -q", defaultOptions{runQuick = True})
, ("run --quick", defaultOptions{runQuick = True})
, ("run --ghc latest --cabal 3.10 --stack 2.9 --hls 2.0 --install",
defaultOptions
{ runGHCVer = Just $ ToolTag Latest
2023-10-13 08:35:39 +00:00
, runCabalVer = Just $ ToolVersion $(versionQ "3.10")
, runHLSVer = Just $ ToolVersion $(versionQ "2.0")
, runStackVer = Just $ ToolVersion $(versionQ "2.9")
2023-07-28 15:39:21 +00:00
, runInstTool' = True
}
)
]
2023-07-28 15:26:19 +00:00
runParseWith :: [String] -> IO RunOptions
runParseWith args = do
Run a <- parseWith args
pure a