compile test
This commit is contained in:
parent
dfebfc9504
commit
6f07b6a343
@ -57,6 +57,7 @@ import Text.Read (readEither)
|
|||||||
|
|
||||||
data CompileCommand = CompileGHC GHCCompileOptions
|
data CompileCommand = CompileGHC GHCCompileOptions
|
||||||
| CompileHLS HLSCompileOptions
|
| CompileHLS HLSCompileOptions
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ data GHCCompileOptions = GHCCompileOptions
|
|||||||
, buildFlavour :: Maybe String
|
, buildFlavour :: Maybe String
|
||||||
, hadrian :: Bool
|
, hadrian :: Bool
|
||||||
, isolateDir :: Maybe FilePath
|
, isolateDir :: Maybe FilePath
|
||||||
}
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
|
|
||||||
data HLSCompileOptions = HLSCompileOptions
|
data HLSCompileOptions = HLSCompileOptions
|
||||||
@ -93,7 +94,7 @@ data HLSCompileOptions = HLSCompileOptions
|
|||||||
, patches :: Maybe (Either FilePath [URI])
|
, patches :: Maybe (Either FilePath [URI])
|
||||||
, targetGHCs :: [ToolVersion]
|
, targetGHCs :: [ToolVersion]
|
||||||
, cabalArgs :: [Text]
|
, cabalArgs :: [Text]
|
||||||
}
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,6 +426,7 @@ test-suite ghcup-optparse-test
|
|||||||
RmTest
|
RmTest
|
||||||
ListTest
|
ListTest
|
||||||
UpgradeTest
|
UpgradeTest
|
||||||
|
CompileTest
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring
|
build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring
|
||||||
|
@ -83,6 +83,7 @@ import qualified Text.Megaparsec as MP
|
|||||||
data GHCVer = SourceDist Version
|
data GHCVer = SourceDist Version
|
||||||
| GitDist GitBranch
|
| GitDist GitBranch
|
||||||
| RemoteDist URI
|
| RemoteDist URI
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ data HLSVer = SourceDist Version
|
|||||||
| GitDist GitBranch
|
| GitDist GitBranch
|
||||||
| HackageDist Version
|
| HackageDist Version
|
||||||
| RemoteDist URI
|
| RemoteDist URI
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
64
test/optparse-test/CompileTest.hs
Normal file
64
test/optparse-test/CompileTest.hs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module CompileTest where
|
||||||
|
|
||||||
|
import Test.Tasty
|
||||||
|
import GHCup.OptParse
|
||||||
|
import Utils
|
||||||
|
import GHCup.GHC
|
||||||
|
import Data.Versions
|
||||||
|
import GHCup.Types
|
||||||
|
|
||||||
|
|
||||||
|
compileTests :: TestTree
|
||||||
|
compileTests = testGroup "compile"
|
||||||
|
$ map (buildTestTree compileParseWith)
|
||||||
|
[ ("ghc", compileGhcCheckList)
|
||||||
|
, ("hls", compileHlsCheckList)
|
||||||
|
]
|
||||||
|
|
||||||
|
mkDefaultGHCCompileOptions :: GHCVer -> Either Version FilePath -> GHCCompileOptions
|
||||||
|
mkDefaultGHCCompileOptions target boot =
|
||||||
|
GHCCompileOptions
|
||||||
|
target
|
||||||
|
boot
|
||||||
|
Nothing
|
||||||
|
Nothing
|
||||||
|
(Just $ Right [])
|
||||||
|
Nothing
|
||||||
|
[]
|
||||||
|
False
|
||||||
|
Nothing
|
||||||
|
Nothing
|
||||||
|
False
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
compileGhcCheckList :: [(String, CompileCommand)]
|
||||||
|
compileGhcCheckList = mapSecond CompileGHC
|
||||||
|
[ ("compile ghc -v 9.4.5 -b 9.2.8", mkDefaultGHCCompileOptions
|
||||||
|
(SourceDist $ mkVersion' "9.4.5")
|
||||||
|
(Left $ mkVersion' "9.2.8")
|
||||||
|
)
|
||||||
|
, ("compile ghc -g a32db0b -b 9.2.8", mkDefaultGHCCompileOptions
|
||||||
|
(GitDist $ GitBranch "a32db0b" Nothing)
|
||||||
|
(Left $ mkVersion' "9.2.8")
|
||||||
|
)
|
||||||
|
, ("compile ghc -g a32db0b -b 9.2.8 -r https://gitlab.haskell.org/ghc/ghc.git",
|
||||||
|
mkDefaultGHCCompileOptions
|
||||||
|
(GitDist $ GitBranch "a32db0b" (Just "https://gitlab.haskell.org/ghc/ghc.git"))
|
||||||
|
(Left $ mkVersion' "9.2.8")
|
||||||
|
)
|
||||||
|
, ("compile ghc -g a32db0b -r https://gitlab.haskell.org/ghc/ghc.git -b /usr/bin/ghc-9.2.2",
|
||||||
|
mkDefaultGHCCompileOptions
|
||||||
|
(GitDist $ GitBranch "a32db0b" (Just "https://gitlab.haskell.org/ghc/ghc.git"))
|
||||||
|
(Right "/usr/bin/ghc-9.2.2")
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
compileHlsCheckList :: [(String, CompileCommand)]
|
||||||
|
compileHlsCheckList = []
|
||||||
|
|
||||||
|
compileParseWith :: [String] -> IO CompileCommand
|
||||||
|
compileParseWith args = do
|
||||||
|
Compile a <- parseWith args
|
||||||
|
pure a
|
@ -10,6 +10,7 @@ import qualified UnsetTest
|
|||||||
import qualified RmTest
|
import qualified RmTest
|
||||||
import qualified ListTest
|
import qualified ListTest
|
||||||
import qualified UpgradeTest
|
import qualified UpgradeTest
|
||||||
|
import qualified CompileTest
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain $ testGroup "ghcup"
|
main = defaultMain $ testGroup "ghcup"
|
||||||
@ -22,4 +23,5 @@ main = defaultMain $ testGroup "ghcup"
|
|||||||
, RmTest.rmTests
|
, RmTest.rmTests
|
||||||
, ListTest.listTests
|
, ListTest.listTests
|
||||||
, UpgradeTest.upgradeTests
|
, UpgradeTest.upgradeTests
|
||||||
|
, CompileTest.compileTests
|
||||||
]
|
]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
|
||||||
module Utils where
|
module Utils where
|
||||||
|
|
||||||
import GHCup.OptParse as GHCup
|
import GHCup.OptParse as GHCup
|
||||||
@ -8,6 +9,7 @@ import Data.List.NonEmpty (NonEmpty)
|
|||||||
import Test.Tasty
|
import Test.Tasty
|
||||||
import Test.Tasty.HUnit
|
import Test.Tasty.HUnit
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
|
import qualified Data.Text as T
|
||||||
|
|
||||||
parseWith :: [String] -> IO Command
|
parseWith :: [String] -> IO Command
|
||||||
parseWith args =
|
parseWith args =
|
||||||
@ -24,6 +26,11 @@ mapSecond = map . second
|
|||||||
mkVersion :: NonEmpty VChunk -> Version
|
mkVersion :: NonEmpty VChunk -> Version
|
||||||
mkVersion chunks = Version Nothing chunks [] Nothing
|
mkVersion chunks = Version Nothing chunks [] Nothing
|
||||||
|
|
||||||
|
mkVersion' :: T.Text -> Version
|
||||||
|
mkVersion' txt =
|
||||||
|
let Right ver = version txt
|
||||||
|
in ver
|
||||||
|
|
||||||
buildTestTree
|
buildTestTree
|
||||||
:: (Eq a, Show a)
|
:: (Eq a, Show a)
|
||||||
=> ([String] -> IO a) -- ^ The parse function
|
=> ([String] -> IO a) -- ^ The parse function
|
||||||
|
Loading…
Reference in New Issue
Block a user