Support stacks installation strategy and metadata wrt #892
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
|
||||
module InstallTest where
|
||||
|
||||
@@ -13,6 +16,8 @@ import Data.Versions
|
||||
import Data.List.NonEmpty (NonEmpty ((:|)))
|
||||
import GHCup.OptParse.Install as Install
|
||||
import URI.ByteString.QQ
|
||||
import URI.ByteString
|
||||
import Data.Text (Text)
|
||||
|
||||
-- Some interests:
|
||||
-- install ghc *won't* select `set as activate version` as default
|
||||
@@ -26,37 +31,52 @@ installTests = testGroup "install"
|
||||
(buildTestTree installParseWith)
|
||||
[ ("old-style", oldStyleCheckList)
|
||||
, ("ghc", installGhcCheckList)
|
||||
, ("cabal", installCabalCheckList)
|
||||
, ("hls", installHlsCheckList)
|
||||
, ("stack", installStackCheckList)
|
||||
, ("cabal", (fmap . fmap . fmap) toGHCOptions installCabalCheckList)
|
||||
, ("hls", (fmap . fmap . fmap) toGHCOptions installHlsCheckList)
|
||||
, ("stack", (fmap . fmap . fmap) toGHCOptions installStackCheckList)
|
||||
]
|
||||
|
||||
toGHCOptions :: InstallOptions -> InstallGHCOptions
|
||||
toGHCOptions InstallOptions{..}
|
||||
= InstallGHCOptions instVer
|
||||
instBindist
|
||||
instSet
|
||||
isolateDir
|
||||
forceInstall
|
||||
addConfArgs
|
||||
Nothing
|
||||
|
||||
|
||||
|
||||
defaultOptions :: InstallOptions
|
||||
defaultOptions = InstallOptions Nothing Nothing False Nothing False []
|
||||
|
||||
defaultGHCOptions :: InstallGHCOptions
|
||||
defaultGHCOptions = InstallGHCOptions Nothing Nothing False Nothing False [] Nothing
|
||||
|
||||
-- | Don't set as active version
|
||||
mkInstallOptions :: ToolVersion -> InstallOptions
|
||||
mkInstallOptions ver = InstallOptions (Just ver) Nothing False Nothing False []
|
||||
mkInstallOptions :: ToolVersion -> InstallGHCOptions
|
||||
mkInstallOptions ver = InstallGHCOptions (Just ver) Nothing False Nothing False [] Nothing
|
||||
|
||||
-- | Set as active version
|
||||
mkInstallOptions' :: ToolVersion -> InstallOptions
|
||||
mkInstallOptions' ver = InstallOptions (Just ver) Nothing True Nothing False []
|
||||
|
||||
oldStyleCheckList :: [(String, Either InstallCommand InstallOptions)]
|
||||
oldStyleCheckList :: [(String, Either InstallCommand InstallGHCOptions)]
|
||||
oldStyleCheckList =
|
||||
("install", Right defaultOptions)
|
||||
: ("install --set", Right defaultOptions{instSet = True})
|
||||
: ("install --force", Right defaultOptions{forceInstall = True})
|
||||
("install", Right defaultGHCOptions)
|
||||
: ("install --set", Right (defaultGHCOptions{instSet = True} :: InstallGHCOptions))
|
||||
: ("install --force", Right (defaultGHCOptions{forceInstall = True} :: InstallGHCOptions))
|
||||
#ifdef IS_WINDOWS
|
||||
: ("install -i C:\\\\", Right defaultOptions{Install.isolateDir = Just "C:\\\\"})
|
||||
: ("install -i C:\\\\", Right (defaultGHCOptions{Install.isolateDir = Just "C:\\\\"} :: InstallGHCOptions))
|
||||
#else
|
||||
: ("install -i /", Right defaultOptions{Install.isolateDir = Just "/"})
|
||||
: ("install -i /", Right (defaultGHCOptions{Install.isolateDir = Just "/"} :: InstallGHCOptions))
|
||||
#endif
|
||||
: ("install -u https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz head"
|
||||
, Right defaultOptions
|
||||
, Right (defaultGHCOptions
|
||||
{ instBindist = Just [uri|https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz|]
|
||||
, instVer = Just $ GHCVersion $ GHCTargetVersion Nothing $(versionQ "head")
|
||||
}
|
||||
} :: InstallGHCOptions)
|
||||
)
|
||||
: mapSecond
|
||||
(Right . mkInstallOptions)
|
||||
@@ -108,9 +128,9 @@ oldStyleCheckList =
|
||||
)
|
||||
]
|
||||
|
||||
installGhcCheckList :: [(String, Either InstallCommand InstallOptions)]
|
||||
installGhcCheckList :: [(String, Either InstallCommand InstallGHCOptions)]
|
||||
installGhcCheckList =
|
||||
("install ghc", Left $ InstallGHC defaultOptions)
|
||||
("install ghc", Left $ InstallGHC defaultGHCOptions)
|
||||
: mapSecond (Left . InstallGHC . mkInstallOptions)
|
||||
[ ("install ghc 9.2", GHCVersion
|
||||
$ GHCTargetVersion
|
||||
@@ -151,7 +171,7 @@ installGhcCheckList =
|
||||
|
||||
installCabalCheckList :: [(String, Either InstallCommand InstallOptions)]
|
||||
installCabalCheckList =
|
||||
("install cabal", Left $ InstallCabal defaultOptions{instSet = True})
|
||||
("install cabal", Left $ InstallCabal (defaultOptions{instSet = True} :: InstallOptions))
|
||||
: mapSecond (Left . InstallCabal . mkInstallOptions')
|
||||
[ ("install cabal 3.10", ToolVersion $(versionQ "3.10"))
|
||||
, ("install cabal next", ToolVersion $(versionQ "next"))
|
||||
@@ -197,7 +217,7 @@ installStackCheckList =
|
||||
, ("install stack stack-2.9", ToolVersion $(versionQ "stack-2.9"))
|
||||
]
|
||||
|
||||
installParseWith :: [String] -> IO (Either InstallCommand InstallOptions)
|
||||
installParseWith :: [String] -> IO (Either InstallCommand InstallGHCOptions)
|
||||
installParseWith args = do
|
||||
Install a <- parseWith args
|
||||
pure a
|
||||
|
||||
Reference in New Issue
Block a user