upgrade test
This commit is contained in:
parent
36463ebf97
commit
dfebfc9504
@ -50,7 +50,7 @@ import Data.Versions hiding (str)
|
|||||||
data UpgradeOpts = UpgradeInplace
|
data UpgradeOpts = UpgradeInplace
|
||||||
| UpgradeAt FilePath
|
| UpgradeAt FilePath
|
||||||
| UpgradeGHCupDir
|
| UpgradeGHCupDir
|
||||||
deriving Show
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -425,6 +425,7 @@ test-suite ghcup-optparse-test
|
|||||||
UnsetTest
|
UnsetTest
|
||||||
RmTest
|
RmTest
|
||||||
ListTest
|
ListTest
|
||||||
|
UpgradeTest
|
||||||
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
|
||||||
|
@ -9,6 +9,7 @@ import qualified InstallTest
|
|||||||
import qualified UnsetTest
|
import qualified UnsetTest
|
||||||
import qualified RmTest
|
import qualified RmTest
|
||||||
import qualified ListTest
|
import qualified ListTest
|
||||||
|
import qualified UpgradeTest
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain $ testGroup "ghcup"
|
main = defaultMain $ testGroup "ghcup"
|
||||||
@ -20,4 +21,5 @@ main = defaultMain $ testGroup "ghcup"
|
|||||||
, UnsetTest.unsetTests
|
, UnsetTest.unsetTests
|
||||||
, RmTest.rmTests
|
, RmTest.rmTests
|
||||||
, ListTest.listTests
|
, ListTest.listTests
|
||||||
|
, UpgradeTest.upgradeTests
|
||||||
]
|
]
|
||||||
|
38
test/optparse-test/UpgradeTest.hs
Normal file
38
test/optparse-test/UpgradeTest.hs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{-# LANGUAGE TupleSections #-}
|
||||||
|
|
||||||
|
module UpgradeTest where
|
||||||
|
|
||||||
|
import Test.Tasty
|
||||||
|
import GHCup.OptParse
|
||||||
|
import Utils
|
||||||
|
|
||||||
|
|
||||||
|
upgradeTests :: TestTree
|
||||||
|
upgradeTests = buildTestTree upgradeParseWith ("upgrade", upgradeCheckList)
|
||||||
|
|
||||||
|
type FullUpgradeOpts =
|
||||||
|
( UpgradeOpts
|
||||||
|
, Bool -- ^Force update
|
||||||
|
, Bool -- ^Fails after upgrading if the upgraded ghcup binary is shadowed by something else in PATH (useful for CI)
|
||||||
|
)
|
||||||
|
|
||||||
|
mkDefaultOptions :: UpgradeOpts -> FullUpgradeOpts
|
||||||
|
mkDefaultOptions = (, False, False)
|
||||||
|
|
||||||
|
upgradeCheckList :: [(String, FullUpgradeOpts)]
|
||||||
|
upgradeCheckList =
|
||||||
|
[ ("upgrade", mkDefaultOptions UpgradeGHCupDir)
|
||||||
|
, ("upgrade -f", (UpgradeGHCupDir, True, False))
|
||||||
|
, ("upgrade --force", (UpgradeGHCupDir, True, False))
|
||||||
|
, ("upgrade --fail-if-shadowed", (UpgradeGHCupDir, False, True))
|
||||||
|
, ("upgrade -i", mkDefaultOptions UpgradeInplace)
|
||||||
|
, ("upgrade --inplace", mkDefaultOptions UpgradeInplace)
|
||||||
|
, ("upgrade -t ~", mkDefaultOptions $ UpgradeAt "~")
|
||||||
|
, ("upgrade --target ~", mkDefaultOptions $ UpgradeAt "~")
|
||||||
|
, ("upgrade -t ~ -f", (UpgradeAt "~", True, False))
|
||||||
|
]
|
||||||
|
|
||||||
|
upgradeParseWith :: [String] -> IO FullUpgradeOpts
|
||||||
|
upgradeParseWith args = do
|
||||||
|
Upgrade a b c <- parseWith args
|
||||||
|
pure (a, b, c)
|
Loading…
Reference in New Issue
Block a user