2023-09-02 10:47:42 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
2023-07-22 15:10:27 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2023-09-02 10:47:42 +00:00
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
2023-10-13 08:09:35 +00:00
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
2023-10-22 13:50:27 +00:00
|
|
|
{-# LANGUAGE DuplicateRecordFields #-}
|
|
|
|
{-# LANGUAGE RecordWildCards #-}
|
|
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
2023-07-22 15:10:27 +00:00
|
|
|
|
|
|
|
module InstallTest where
|
|
|
|
|
|
|
|
import Test.Tasty
|
|
|
|
import GHCup.OptParse hiding (HLSCompileOptions(isolateDir))
|
|
|
|
import Utils
|
|
|
|
import GHCup.Types
|
|
|
|
import Data.Versions
|
|
|
|
import Data.List.NonEmpty (NonEmpty ((:|)))
|
|
|
|
import GHCup.OptParse.Install as Install
|
|
|
|
import URI.ByteString.QQ
|
2023-10-22 13:50:27 +00:00
|
|
|
import URI.ByteString
|
|
|
|
import Data.Text (Text)
|
2023-07-22 15:10:27 +00:00
|
|
|
|
|
|
|
-- Some interests:
|
|
|
|
-- install ghc *won't* select `set as activate version` as default
|
|
|
|
-- install cabal *will* select `set as activate version` as default
|
|
|
|
-- install hls *will* select `set as activate version` as default
|
|
|
|
-- install stack *will* select `set as activate version` as default
|
|
|
|
|
|
|
|
installTests :: TestTree
|
|
|
|
installTests = testGroup "install"
|
|
|
|
$ map
|
|
|
|
(buildTestTree installParseWith)
|
|
|
|
[ ("old-style", oldStyleCheckList)
|
|
|
|
, ("ghc", installGhcCheckList)
|
2023-10-22 13:50:27 +00:00
|
|
|
, ("cabal", (fmap . fmap . fmap) toGHCOptions installCabalCheckList)
|
|
|
|
, ("hls", (fmap . fmap . fmap) toGHCOptions installHlsCheckList)
|
|
|
|
, ("stack", (fmap . fmap . fmap) toGHCOptions installStackCheckList)
|
2023-07-22 15:10:27 +00:00
|
|
|
]
|
|
|
|
|
2023-10-22 13:50:27 +00:00
|
|
|
toGHCOptions :: InstallOptions -> InstallGHCOptions
|
|
|
|
toGHCOptions InstallOptions{..}
|
|
|
|
= InstallGHCOptions instVer
|
|
|
|
instBindist
|
|
|
|
instSet
|
|
|
|
isolateDir
|
|
|
|
forceInstall
|
|
|
|
addConfArgs
|
|
|
|
Nothing
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-22 15:10:27 +00:00
|
|
|
defaultOptions :: InstallOptions
|
|
|
|
defaultOptions = InstallOptions Nothing Nothing False Nothing False []
|
|
|
|
|
2023-10-22 13:50:27 +00:00
|
|
|
defaultGHCOptions :: InstallGHCOptions
|
|
|
|
defaultGHCOptions = InstallGHCOptions Nothing Nothing False Nothing False [] Nothing
|
|
|
|
|
2023-07-22 15:10:27 +00:00
|
|
|
-- | Don't set as active version
|
2023-10-22 13:50:27 +00:00
|
|
|
mkInstallOptions :: ToolVersion -> InstallGHCOptions
|
|
|
|
mkInstallOptions ver = InstallGHCOptions (Just ver) Nothing False Nothing False [] Nothing
|
2023-07-22 15:10:27 +00:00
|
|
|
|
|
|
|
-- | Set as active version
|
|
|
|
mkInstallOptions' :: ToolVersion -> InstallOptions
|
|
|
|
mkInstallOptions' ver = InstallOptions (Just ver) Nothing True Nothing False []
|
|
|
|
|
2023-10-22 13:50:27 +00:00
|
|
|
oldStyleCheckList :: [(String, Either InstallCommand InstallGHCOptions)]
|
2023-07-22 15:10:27 +00:00
|
|
|
oldStyleCheckList =
|
2023-10-22 13:50:27 +00:00
|
|
|
("install", Right defaultGHCOptions)
|
|
|
|
: ("install --set", Right (defaultGHCOptions{instSet = True} :: InstallGHCOptions))
|
|
|
|
: ("install --force", Right (defaultGHCOptions{forceInstall = True} :: InstallGHCOptions))
|
2023-09-02 10:47:42 +00:00
|
|
|
#ifdef IS_WINDOWS
|
2023-10-22 13:50:27 +00:00
|
|
|
: ("install -i C:\\\\", Right (defaultGHCOptions{Install.isolateDir = Just "C:\\\\"} :: InstallGHCOptions))
|
2023-09-02 10:47:42 +00:00
|
|
|
#else
|
2023-10-22 13:50:27 +00:00
|
|
|
: ("install -i /", Right (defaultGHCOptions{Install.isolateDir = Just "/"} :: InstallGHCOptions))
|
2023-09-02 10:47:42 +00:00
|
|
|
#endif
|
2023-07-22 15:10:27 +00:00
|
|
|
: ("install -u https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz head"
|
2023-10-22 13:50:27 +00:00
|
|
|
, Right (defaultGHCOptions
|
2023-07-22 15:10:27 +00:00
|
|
|
{ instBindist = Just [uri|https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz|]
|
2023-10-13 08:35:39 +00:00
|
|
|
, instVer = Just $ GHCVersion $ GHCTargetVersion Nothing $(versionQ "head")
|
2023-10-22 13:50:27 +00:00
|
|
|
} :: InstallGHCOptions)
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
: mapSecond
|
|
|
|
(Right . mkInstallOptions)
|
|
|
|
[ ("install ghc-9.2", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
(Just "ghc")
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "9.2")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
-- invalid
|
|
|
|
, ("install next", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
Nothing
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "next")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install latest", ToolTag Latest)
|
|
|
|
, ("install nightly", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
Nothing
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "nightly")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install recommended", ToolTag Recommended)
|
|
|
|
, ("install prerelease", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
Nothing
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "prerelease")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install latest-prerelease", ToolTag LatestPrerelease)
|
|
|
|
, ("install latest-nightly", ToolTag LatestNightly)
|
|
|
|
, ("install ghc-javascript-unknown-ghcjs-9.6", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
(Just "ghc-javascript-unknown-ghcjs")
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "9.6")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]})))
|
|
|
|
, ("install cabal-3.10", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
(Just "cabal")
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "3.10")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install hls-2.0.0.0", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
(Just "hls")
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "2.0.0.0")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install stack-2.9.3", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
(Just "stack")
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "2.9.3")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
]
|
|
|
|
|
2023-10-22 13:50:27 +00:00
|
|
|
installGhcCheckList :: [(String, Either InstallCommand InstallGHCOptions)]
|
2023-07-22 15:10:27 +00:00
|
|
|
installGhcCheckList =
|
2023-10-22 13:50:27 +00:00
|
|
|
("install ghc", Left $ InstallGHC defaultGHCOptions)
|
2023-07-22 15:10:27 +00:00
|
|
|
: mapSecond (Left . InstallGHC . mkInstallOptions)
|
|
|
|
[ ("install ghc 9.2", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
Nothing
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "9.2")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install ghc next", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
Nothing
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "next")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install ghc latest", ToolTag Latest)
|
|
|
|
, ("install ghc nightly", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
Nothing
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "nightly")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install ghc recommended", ToolTag Recommended)
|
|
|
|
, ("install ghc prerelease", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
Nothing
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "prerelease")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install ghc latest-prerelease", ToolTag LatestPrerelease)
|
|
|
|
, ("install ghc latest-nightly", ToolTag LatestNightly)
|
|
|
|
, ("install ghc javascript-unknown-ghcjs-9.6", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
(Just "javascript-unknown-ghcjs")
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "9.6")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
, ("install ghc base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]})))
|
|
|
|
, ("install ghc ghc-9.2", GHCVersion
|
|
|
|
$ GHCTargetVersion
|
|
|
|
(Just "ghc")
|
2023-10-13 08:35:39 +00:00
|
|
|
$(versionQ "9.2")
|
2023-07-22 15:10:27 +00:00
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
installCabalCheckList :: [(String, Either InstallCommand InstallOptions)]
|
|
|
|
installCabalCheckList =
|
2023-10-22 13:50:27 +00:00
|
|
|
("install cabal", Left $ InstallCabal (defaultOptions{instSet = True} :: InstallOptions))
|
2023-07-22 15:10:27 +00:00
|
|
|
: mapSecond (Left . InstallCabal . mkInstallOptions')
|
2023-10-13 08:35:39 +00:00
|
|
|
[ ("install cabal 3.10", ToolVersion $(versionQ "3.10"))
|
|
|
|
, ("install cabal next", ToolVersion $(versionQ "next"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install cabal latest", ToolTag Latest)
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install cabal nightly", ToolVersion $(versionQ "nightly"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install cabal recommended", ToolTag Recommended)
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install cabal prerelease", ToolVersion $(versionQ "prerelease"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install cabal latest-prerelease", ToolTag LatestPrerelease)
|
|
|
|
, ("install cabal latest-nightly", ToolTag LatestNightly)
|
|
|
|
, ("install cabal base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]})))
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install cabal cabal-3.10", ToolVersion $(versionQ "cabal-3.10"))
|
2023-07-22 15:10:27 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
installHlsCheckList :: [(String, Either InstallCommand InstallOptions)]
|
|
|
|
installHlsCheckList =
|
|
|
|
("install hls", Left $ InstallHLS defaultOptions{instSet = True})
|
|
|
|
: mapSecond (Left . InstallHLS . mkInstallOptions')
|
2023-10-13 08:35:39 +00:00
|
|
|
[ ("install hls 3.10", ToolVersion $(versionQ "3.10"))
|
|
|
|
, ("install hls next", ToolVersion $(versionQ "next"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install hls latest", ToolTag Latest)
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install hls nightly", ToolVersion $(versionQ "nightly"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install hls recommended", ToolTag Recommended)
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install hls prerelease", ToolVersion $(versionQ "prerelease"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install hls latest-prerelease", ToolTag LatestPrerelease)
|
|
|
|
, ("install hls latest-nightly", ToolTag LatestNightly)
|
|
|
|
, ("install hls base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]})))
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install hls hls-2.0", ToolVersion $(versionQ "hls-2.0"))
|
2023-07-22 15:10:27 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
installStackCheckList :: [(String, Either InstallCommand InstallOptions)]
|
|
|
|
installStackCheckList =
|
|
|
|
("install stack", Left $ InstallStack defaultOptions{instSet = True})
|
|
|
|
: mapSecond (Left . InstallStack . mkInstallOptions')
|
2023-10-13 08:35:39 +00:00
|
|
|
[ ("install stack 3.10", ToolVersion $(versionQ "3.10"))
|
|
|
|
, ("install stack next", ToolVersion $(versionQ "next"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install stack latest", ToolTag Latest)
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install stack nightly", ToolVersion $(versionQ "nightly"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install stack recommended", ToolTag Recommended)
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install stack prerelease", ToolVersion $(versionQ "prerelease"))
|
2023-07-22 15:10:27 +00:00
|
|
|
, ("install stack latest-prerelease", ToolTag LatestPrerelease)
|
|
|
|
, ("install stack latest-nightly", ToolTag LatestNightly)
|
|
|
|
, ("install stack base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]})))
|
2023-10-13 08:35:39 +00:00
|
|
|
, ("install stack stack-2.9", ToolVersion $(versionQ "stack-2.9"))
|
2023-07-22 15:10:27 +00:00
|
|
|
]
|
|
|
|
|
2023-10-22 13:50:27 +00:00
|
|
|
installParseWith :: [String] -> IO (Either InstallCommand InstallGHCOptions)
|
2023-07-22 15:10:27 +00:00
|
|
|
installParseWith args = do
|
|
|
|
Install a <- parseWith args
|
|
|
|
pure a
|