From e13c5a99af0e06c4c050e7d69e2ef93f918445df Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Thu, 20 Jul 2023 23:09:14 +0800 Subject: [PATCH 01/24] Remove origin test to ghcup-test subdir --- ghcup.cabal | 2 +- test/{ => ghcup-test}/GHCup/ArbitraryTypes.hs | 0 .../GHCup/Prelude/File/Posix/TraversalsSpec.hs | 2 +- test/{ => ghcup-test}/GHCup/Types/JSONSpec.hs | 4 ++-- test/{ => ghcup-test}/GHCup/Utils/FileSpec.hs | 0 test/{ => ghcup-test}/Main.hs | 0 test/{ => ghcup-test}/Spec.hs | 0 test/{ => ghcup-test}/data/dir/.keep | 0 test/{ => ghcup-test}/data/file | 0 test/{ => ghcup-test}/golden/unix/GHCupInfo.json | 0 test/{ => ghcup-test}/golden/windows/GHCupInfo.json | 0 11 files changed, 4 insertions(+), 4 deletions(-) rename test/{ => ghcup-test}/GHCup/ArbitraryTypes.hs (100%) rename test/{ => ghcup-test}/GHCup/Prelude/File/Posix/TraversalsSpec.hs (93%) rename test/{ => ghcup-test}/GHCup/Types/JSONSpec.hs (83%) rename test/{ => ghcup-test}/GHCup/Utils/FileSpec.hs (100%) rename test/{ => ghcup-test}/Main.hs (100%) rename test/{ => ghcup-test}/Spec.hs (100%) rename test/{ => ghcup-test}/data/dir/.keep (100%) rename test/{ => ghcup-test}/data/file (100%) rename test/{ => ghcup-test}/golden/unix/GHCupInfo.json (100%) rename test/{ => ghcup-test}/golden/windows/GHCupInfo.json (100%) diff --git a/ghcup.cabal b/ghcup.cabal index 0ffcf8f..9f53bb7 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -302,7 +302,7 @@ test-suite ghcup-test type: exitcode-stdio-1.0 main-is: Main.hs build-tool-depends: hspec-discover:hspec-discover -any - hs-source-dirs: test + hs-source-dirs: test/ghcup-test other-modules: GHCup.ArbitraryTypes GHCup.Prelude.File.Posix.TraversalsSpec diff --git a/test/GHCup/ArbitraryTypes.hs b/test/ghcup-test/GHCup/ArbitraryTypes.hs similarity index 100% rename from test/GHCup/ArbitraryTypes.hs rename to test/ghcup-test/GHCup/ArbitraryTypes.hs diff --git a/test/GHCup/Prelude/File/Posix/TraversalsSpec.hs b/test/ghcup-test/GHCup/Prelude/File/Posix/TraversalsSpec.hs similarity index 93% rename from test/GHCup/Prelude/File/Posix/TraversalsSpec.hs rename to test/ghcup-test/GHCup/Prelude/File/Posix/TraversalsSpec.hs index d33c5ef..0e2023a 100644 --- a/test/GHCup/Prelude/File/Posix/TraversalsSpec.hs +++ b/test/ghcup-test/GHCup/Prelude/File/Posix/TraversalsSpec.hs @@ -24,7 +24,7 @@ spec = do -- https://github.com/haskell/ghcup-hs/issues/415 describe "GHCup.Prelude.File.Posix.Traversals" $ do it "readDirEnt" $ do - dirstream <- liftIO $ openDirStreamPortable "test/data" + dirstream <- liftIO $ openDirStreamPortable "test/ghcup-test/data" (dt1, fp1) <- readDirEntPortable dirstream (dt2, fp2) <- readDirEntPortable dirstream (dt3, fp3) <- readDirEntPortable dirstream diff --git a/test/GHCup/Types/JSONSpec.hs b/test/ghcup-test/GHCup/Types/JSONSpec.hs similarity index 83% rename from test/GHCup/Types/JSONSpec.hs rename to test/ghcup-test/GHCup/Types/JSONSpec.hs index 88fed43..852cdf9 100644 --- a/test/GHCup/Types/JSONSpec.hs +++ b/test/ghcup-test/GHCup/Types/JSONSpec.hs @@ -17,6 +17,6 @@ spec = do roundtripAndGoldenSpecsWithSettings (defaultSettings { goldenDirectoryOption = CustomDirectoryName goldenDir }) (Proxy @GHCupInfo) where goldenDir - | isWindows = "test/golden/windows" - | otherwise = "test/golden/unix" + | isWindows = "test/ghcup-test/golden/windows" + | otherwise = "test/ghcup-test/golden/unix" diff --git a/test/GHCup/Utils/FileSpec.hs b/test/ghcup-test/GHCup/Utils/FileSpec.hs similarity index 100% rename from test/GHCup/Utils/FileSpec.hs rename to test/ghcup-test/GHCup/Utils/FileSpec.hs diff --git a/test/Main.hs b/test/ghcup-test/Main.hs similarity index 100% rename from test/Main.hs rename to test/ghcup-test/Main.hs diff --git a/test/Spec.hs b/test/ghcup-test/Spec.hs similarity index 100% rename from test/Spec.hs rename to test/ghcup-test/Spec.hs diff --git a/test/data/dir/.keep b/test/ghcup-test/data/dir/.keep similarity index 100% rename from test/data/dir/.keep rename to test/ghcup-test/data/dir/.keep diff --git a/test/data/file b/test/ghcup-test/data/file similarity index 100% rename from test/data/file rename to test/ghcup-test/data/file diff --git a/test/golden/unix/GHCupInfo.json b/test/ghcup-test/golden/unix/GHCupInfo.json similarity index 100% rename from test/golden/unix/GHCupInfo.json rename to test/ghcup-test/golden/unix/GHCupInfo.json diff --git a/test/golden/windows/GHCupInfo.json b/test/ghcup-test/golden/windows/GHCupInfo.json similarity index 100% rename from test/golden/windows/GHCupInfo.json rename to test/ghcup-test/golden/windows/GHCupInfo.json From c10924274ddfc1338859748c03a03a26680383d9 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 22 Jul 2023 11:45:29 +0800 Subject: [PATCH 02/24] Set test --- app/ghcup/GHCup/OptParse/Common.hs | 1 + app/ghcup/GHCup/OptParse/Set.hs | 3 +- cabal.project | 2 + ghcup.cabal | 143 ++++++++++++++++++++++------- hie.yaml | 4 +- test/optparse-test/Main.hs | 75 +++++++++++++++ 6 files changed, 191 insertions(+), 37 deletions(-) create mode 100644 test/optparse-test/Main.hs diff --git a/app/ghcup/GHCup/OptParse/Common.hs b/app/ghcup/GHCup/OptParse/Common.hs index 37e7c6c..acc482e 100644 --- a/app/ghcup/GHCup/OptParse/Common.hs +++ b/app/ghcup/GHCup/OptParse/Common.hs @@ -83,6 +83,7 @@ data SetToolVersion = SetGHCVersion GHCTargetVersion | SetToolDay Day | SetRecommended | SetNext + deriving (Eq, Show) prettyToolVer :: ToolVersion -> String prettyToolVer (GHCVersion v') = T.unpack $ tVerToText v' diff --git a/app/ghcup/GHCup/OptParse/Set.hs b/app/ghcup/GHCup/OptParse/Set.hs index 7cca883..3ba28d2 100644 --- a/app/ghcup/GHCup/OptParse/Set.hs +++ b/app/ghcup/GHCup/OptParse/Set.hs @@ -53,6 +53,7 @@ data SetCommand = SetGHC SetOptions | SetCabal SetOptions | SetHLS SetOptions | SetStack SetOptions + deriving (Eq, Show) @@ -64,7 +65,7 @@ data SetCommand = SetGHC SetOptions data SetOptions = SetOptions { sToolVer :: SetToolVersion - } + } deriving (Eq, Show) diff --git a/cabal.project b/cabal.project index e9e9738..2a1fda2 100644 --- a/cabal.project +++ b/cabal.project @@ -23,3 +23,5 @@ package aeson package streamly flags: +use-unliftio +package * + test-show-details: direct \ No newline at end of file diff --git a/ghcup.cabal b/ghcup.cabal index 9f53bb7..2f7c2d2 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -53,6 +53,43 @@ flag no-exe default: False manual: True +common app-common-depends + build-depends: + , aeson >=1.4 + , aeson-pretty ^>=0.8.8 + , async ^>=2.2.3 + , base >=4.12 && <5 + , bytestring >=0.10 && <0.12 + , cabal-install-parsers >=0.4.5 + , cabal-plan ^>=0.7.2 + , containers ^>=0.6 + , deepseq ^>=1.4 + , directory ^>=1.3.6.0 + , filepath ^>=1.4.2.1 + , haskus-utils-types ^>=1.5 + , haskus-utils-variant ^>=3.2.1 + , libarchive ^>=3.0.3.0 + , megaparsec >=8.0.0 && <9.3 + , mtl ^>=2.2 + , optparse-applicative >=0.15.1.0 && <0.18 + , pretty ^>=1.1.3.1 + , pretty-terminal ^>=0.1.0.0 + , process ^>=1.6.11.0 + , resourcet ^>=1.2.2 + , safe ^>=0.3.18 + , safe-exceptions ^>=0.1 + , tagsoup ^>=0.14 + , template-haskell >=2.7 && <2.20 + , temporary ^>=1.3 + , text ^>=2.0 + , time ^>=1.9.3 || ^>=1.10 || ^>=1.11 + , unordered-containers ^>=0.2 + , uri-bytestring ^>=0.3.2.2 + , utf8-string ^>=1.0 + , vector ^>=0.12 + , versions >=4.0.1 && <5.1 + , yaml-streamly ^>=0.12.0 + library exposed-modules: GHCup @@ -201,7 +238,68 @@ library cpp-options: -DBRICK build-depends: vty ^>=5.37 +library ghcup-optparse + import: app-common-depends + exposed-modules: + GHCup.OptParse + GHCup.OptParse.ChangeLog + GHCup.OptParse.Common + GHCup.OptParse.Compile + GHCup.OptParse.Config + GHCup.OptParse.DInfo + GHCup.OptParse.GC + GHCup.OptParse.Install + GHCup.OptParse.List + GHCup.OptParse.Nuke + GHCup.OptParse.Prefetch + GHCup.OptParse.Rm + GHCup.OptParse.Run + GHCup.OptParse.Set + GHCup.OptParse.Test + GHCup.OptParse.ToolRequirements + GHCup.OptParse.UnSet + GHCup.OptParse.Upgrade + GHCup.OptParse.Whereis + + hs-source-dirs: app/ghcup + default-language: Haskell2010 + default-extensions: + LambdaCase + MultiWayIf + NamedFieldPuns + PackageImports + RecordWildCards + ScopedTypeVariables + StrictData + TupleSections + + ghc-options: + -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns + -fwarn-incomplete-record-updates + + build-depends: ghcup + + if flag(internal-downloader) + cpp-options: -DINTERNAL_DOWNLOADER + + if (flag(tui) && !os(windows)) + cpp-options: -DBRICK + other-modules: BrickMain + build-depends: + , brick ^>=1.5 + , transformers ^>=0.5 + , unix ^>=2.7 + , vty ^>=5.37 + + if os(windows) + cpp-options: -DIS_WINDOWS + + else + build-depends: unix ^>=2.7 + + executable ghcup + import: app-common-depends main-is: Main.hs other-modules: GHCup.OptParse @@ -223,7 +321,6 @@ executable ghcup GHCup.OptParse.UnSet GHCup.OptParse.Upgrade GHCup.OptParse.Whereis - hs-source-dirs: app/ghcup default-language: Haskell2010 default-extensions: @@ -241,41 +338,8 @@ executable ghcup -fwarn-incomplete-record-updates -threaded build-depends: - , aeson >=1.4 - , aeson-pretty ^>=0.8.8 - , async ^>=2.2.3 - , base >=4.12 && <5 - , bytestring >=0.10 && <0.12 - , cabal-install-parsers >=0.4.5 - , cabal-plan ^>=0.7.2 - , containers ^>=0.6 - , deepseq ^>=1.4 - , directory ^>=1.3.6.0 - , filepath ^>=1.4.2.1 + , ghcup-optparse , ghcup - , haskus-utils-types ^>=1.5 - , haskus-utils-variant ^>=3.2.1 - , libarchive ^>=3.0.3.0 - , megaparsec >=8.0.0 && <9.3 - , mtl ^>=2.2 - , optparse-applicative >=0.15.1.0 && <0.18 - , pretty ^>=1.1.3.1 - , pretty-terminal ^>=0.1.0.0 - , process ^>=1.6.11.0 - , resourcet ^>=1.2.2 - , safe ^>=0.3.18 - , safe-exceptions ^>=0.1 - , tagsoup ^>=0.14 - , template-haskell >=2.7 && <2.20 - , temporary ^>=1.3 - , text ^>=2.0 - , time ^>=1.9.3 || ^>=1.10 || ^>=1.11 - , unordered-containers ^>=0.2 - , uri-bytestring ^>=0.3.2.2 - , utf8-string ^>=1.0 - , vector ^>=0.12 - , versions >=4.0.1 && <5.1 - , yaml-streamly ^>=0.12.0 if flag(internal-downloader) cpp-options: -DINTERNAL_DOWNLOADER @@ -346,3 +410,12 @@ test-suite ghcup-test else build-depends: unix ^>=2.7 + +test-suite ghcup-optparse-test + type: exitcode-stdio-1.0 + hs-source-dirs: test/optparse-test + build-tool-depends: ghcup:ghcup + main-is: Main.hs + default-language: Haskell2010 + ghc-options: -Wall + build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text \ No newline at end of file diff --git a/hie.yaml b/hie.yaml index c63de90..c251155 100644 --- a/hie.yaml +++ b/hie.yaml @@ -5,4 +5,6 @@ cradle: - component: "ghcup:exe:ghcup" path: ./app/ghcup - component: "ghcup:test:ghcup-test" - path: ./test + path: ./test/ghcup-test + - component: "ghcup:test:ghcup-optparse-test" + path: ./test/optparse-test \ No newline at end of file diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs new file mode 100644 index 0000000..5958074 --- /dev/null +++ b/test/optparse-test/Main.hs @@ -0,0 +1,75 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Main where + +import GHCup.OptParse as GHCup +import Test.Tasty +import Test.Tasty.HUnit +import Options.Applicative +import Control.Monad.IO.Class (MonadIO(liftIO)) +import GHCup.Types +import Data.Versions +import Data.List.NonEmpty (NonEmpty ((:|))) + + +main :: IO () +main = defaultMain setTests + +setTests :: TestTree +setTests = + testGroup "set" + [ check "set" (Right $ SetOptions SetRecommended) + , check "set ghc" (Left $ SetGHC $ SetOptions SetRecommended) + , check "set ghc-9.2" (Right $ SetOptions + $ SetGHCVersion + (GHCTargetVersion (Just "ghc") + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]))) + , check "set next" (Right $ SetOptions SetNext) + , check "set latest" (Right $ SetOptions $ SetToolTag Latest) + , check "set ghc-javascript-unknown-ghcjs-9.6" + (Right $ SetOptions + $ SetGHCVersion + (GHCTargetVersion + (Just "ghc-javascript-unknown-ghcjs") + (mkVersion $ (Digits 9 :| []) :| [Digits 6 :| []]) + ) + ) + , check "set next" (Right $ SetOptions SetNext) + , check "set nightly" (Right $ SetOptions + $ SetGHCVersion + (GHCTargetVersion + Nothing + (mkVersion $ (Str "nightly" :| []) :| []) + ) + ) + , check "set cabal-3.10" + (Right $ SetOptions + $ SetGHCVersion + (GHCTargetVersion + (Just "cabal") + (mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + ) + ) + , check "set latest" (Right $ SetOptions $ SetToolTag Latest) + ] + where + check :: String -> Either SetCommand SetOptions -> TestTree + check args expected = testCase args $ do + res <- setParseWith (words args) + liftIO $ res @?= expected + +mkVersion :: NonEmpty VChunk -> Version +mkVersion chunks = Version Nothing chunks [] Nothing + +checkList :: [(String, Either SetCommand SetOptions)] +checkList = undefined + +setParseWith :: [String] -> IO (Either SetCommand SetOptions) +setParseWith args = do + Set a <- parseWith args + pure a + +parseWith :: [String] -> IO Command +parseWith args = + optCommand <$> handleParseResult + (execParserPure defaultPrefs (info GHCup.opts fullDesc) args) \ No newline at end of file From 83b82c328bcd315645cd23ab13f72fd23244584e Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 22 Jul 2023 15:31:37 +0800 Subject: [PATCH 03/24] Set test --- ghcup.cabal | 3 +- test/optparse-test/Main.hs | 73 +----------- test/optparse-test/SetTest.hs | 204 ++++++++++++++++++++++++++++++++++ 3 files changed, 208 insertions(+), 72 deletions(-) create mode 100644 test/optparse-test/SetTest.hs diff --git a/ghcup.cabal b/ghcup.cabal index 2f7c2d2..49b79c2 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -414,8 +414,9 @@ test-suite ghcup-test test-suite ghcup-optparse-test type: exitcode-stdio-1.0 hs-source-dirs: test/optparse-test - build-tool-depends: ghcup:ghcup main-is: Main.hs + other-modules: + SetTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text \ No newline at end of file diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index 5958074..e6059fc 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -1,75 +1,6 @@ -{-# LANGUAGE OverloadedStrings #-} - module Main where - -import GHCup.OptParse as GHCup import Test.Tasty -import Test.Tasty.HUnit -import Options.Applicative -import Control.Monad.IO.Class (MonadIO(liftIO)) -import GHCup.Types -import Data.Versions -import Data.List.NonEmpty (NonEmpty ((:|))) - +import qualified SetTest main :: IO () -main = defaultMain setTests - -setTests :: TestTree -setTests = - testGroup "set" - [ check "set" (Right $ SetOptions SetRecommended) - , check "set ghc" (Left $ SetGHC $ SetOptions SetRecommended) - , check "set ghc-9.2" (Right $ SetOptions - $ SetGHCVersion - (GHCTargetVersion (Just "ghc") - (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]))) - , check "set next" (Right $ SetOptions SetNext) - , check "set latest" (Right $ SetOptions $ SetToolTag Latest) - , check "set ghc-javascript-unknown-ghcjs-9.6" - (Right $ SetOptions - $ SetGHCVersion - (GHCTargetVersion - (Just "ghc-javascript-unknown-ghcjs") - (mkVersion $ (Digits 9 :| []) :| [Digits 6 :| []]) - ) - ) - , check "set next" (Right $ SetOptions SetNext) - , check "set nightly" (Right $ SetOptions - $ SetGHCVersion - (GHCTargetVersion - Nothing - (mkVersion $ (Str "nightly" :| []) :| []) - ) - ) - , check "set cabal-3.10" - (Right $ SetOptions - $ SetGHCVersion - (GHCTargetVersion - (Just "cabal") - (mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) - ) - ) - , check "set latest" (Right $ SetOptions $ SetToolTag Latest) - ] - where - check :: String -> Either SetCommand SetOptions -> TestTree - check args expected = testCase args $ do - res <- setParseWith (words args) - liftIO $ res @?= expected - -mkVersion :: NonEmpty VChunk -> Version -mkVersion chunks = Version Nothing chunks [] Nothing - -checkList :: [(String, Either SetCommand SetOptions)] -checkList = undefined - -setParseWith :: [String] -> IO (Either SetCommand SetOptions) -setParseWith args = do - Set a <- parseWith args - pure a - -parseWith :: [String] -> IO Command -parseWith args = - optCommand <$> handleParseResult - (execParserPure defaultPrefs (info GHCup.opts fullDesc) args) \ No newline at end of file +main = defaultMain SetTest.setTests \ No newline at end of file diff --git a/test/optparse-test/SetTest.hs b/test/optparse-test/SetTest.hs new file mode 100644 index 0000000..18d0ec3 --- /dev/null +++ b/test/optparse-test/SetTest.hs @@ -0,0 +1,204 @@ +{-# LANGUAGE OverloadedStrings #-} + +module SetTest where + +import GHCup.OptParse as GHCup +import Test.Tasty +import Test.Tasty.HUnit +import Options.Applicative +import Control.Monad.IO.Class (liftIO) +import GHCup.Types +import Data.Versions +import Data.List.NonEmpty (NonEmpty ((:|))) +import Data.Bifunctor (second) + +setTests :: TestTree +setTests = + testGroup "set" + $ map + buildTestTree + [ ("old-style", oldStyleCheckList) + , ("ghc", setGhcCheckList) + , ("cabal", setCabalCheckList) + , ("hls", setHlsCheckList) + , ("stack", setStackCheckList) + ] + where + buildTestTree :: (String, [(String, Either SetCommand SetOptions)]) -> TestTree + buildTestTree (title, checkList) = + testGroup title + $ zipWith (uncurry . check) [1 :: Int ..] checkList + + check :: Int -> String -> Either SetCommand SetOptions -> TestTree + check idx args expected = testCase (padLeft 2 (show idx) ++ "." ++ args) $ do + res <- setParseWith (words args) + liftIO $ res @?= expected + +mkVersion :: NonEmpty VChunk -> Version +mkVersion chunks = Version Nothing chunks [] Nothing + +oldStyleCheckList :: [(String, Either SetCommand SetOptions)] +oldStyleCheckList = mapSecond (Right . SetOptions) + [ ("set", SetRecommended) + , ("set ghc-9.2", SetGHCVersion + $ GHCTargetVersion + (Just "ghc") + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]) + ) + , ("set next", SetNext) + , ("set latest", SetToolTag Latest) + , ("set nightly", SetGHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "nightly" :| []) :| []) + ) + -- different from `set` + , ("set recommended", SetToolTag Recommended) + , ("set prerelease", SetGHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "prerelease" :| []) :| []) + ) + , ("set latest-prerelease", SetToolTag LatestPrerelease) + , ("set latest-nightly", SetToolTag LatestNightly) + , ("set ghc-javascript-unknown-ghcjs-9.6", SetGHCVersion + $ GHCTargetVersion + (Just "ghc-javascript-unknown-ghcjs") + (mkVersion $ (Digits 9 :| []) :| [Digits 6 :| []]) + ) + , ("set base-4.18", SetToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("set cabal-3.10", SetGHCVersion + $ GHCTargetVersion + (Just "cabal") + (mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + ) + , ("set hls-2.0.0.0", SetGHCVersion + $ GHCTargetVersion + (Just "hls") + (mkVersion $ (Digits 2 :| []) :| [Digits 0 :| [], Digits 0 :| [], Digits 0 :| []]) + ) + , ("set stack-2.9.3", SetGHCVersion + $ GHCTargetVersion + (Just "stack") + (mkVersion $ (Digits 2 :| []) :| [Digits 9 :| [], Digits 3 :| []]) + ) + ] + +setGhcCheckList :: [(String, Either SetCommand SetOptions)] +setGhcCheckList = mapSecond (Left . SetGHC . SetOptions) + [ ("set ghc", SetRecommended) + , ("set ghc 9.2", SetGHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]) + ) + , ("set ghc next", SetNext) + , ("set ghc latest", SetToolTag Latest) + , ("set ghc nightly", SetGHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "nightly" :| []) :| []) + ) + , ("set ghc recommended", SetToolTag Recommended) + , ("set ghc prerelease", SetGHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "prerelease" :| []) :| []) + ) + , ("set ghc latest-prerelease", SetToolTag LatestPrerelease) + , ("set ghc latest-nightly", SetToolTag LatestNightly) + , ("set ghc javascript-unknown-ghcjs-9.6", SetGHCVersion + $ GHCTargetVersion + (Just "javascript-unknown-ghcjs") + (mkVersion $ (Digits 9 :| []) :| [Digits 6 :| []]) + ) + , ("set ghc base-4.18", SetToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("set ghc ghc-9.2", SetGHCVersion + $ GHCTargetVersion + (Just "ghc") + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]) + ) + ] + +setCabalCheckList :: [(String, Either SetCommand SetOptions)] +setCabalCheckList = mapSecond (Left . SetCabal . SetOptions) + [ ("set cabal", SetRecommended) + , ("set cabal 3.10", SetToolVersion $ mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + , ("set cabal next", SetNext) + , ("set cabal latest", SetToolTag Latest) + , ("set cabal nightly", SetToolVersion $ mkVersion $ (Str "nightly" :| []) :| []) + , ("set cabal recommended", SetToolTag Recommended) + , ("set cabal prerelease", SetToolVersion $ mkVersion $ (Str "prerelease" :| []) :| []) + , ("set cabal latest-prerelease", SetToolTag LatestPrerelease) + , ("set cabal latest-nightly", SetToolTag LatestNightly) + , ("set cabal base-4.18", SetToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("set cabal cabal-3.10", SetToolVersion + $ Version + { _vEpoch = Nothing + , _vChunks = (Str "cabal" :| []) :| [] + , _vRel = [Digits 3 :| [], Digits 10 :| []] + , _vMeta = Nothing + } + ) + ] + +setHlsCheckList :: [(String, Either SetCommand SetOptions)] +setHlsCheckList = mapSecond (Left . SetHLS . SetOptions) + [ ("set hls", SetRecommended) + , ("set hls 2.0", SetToolVersion $ mkVersion $ (Digits 2 :| []) :| [Digits 0 :| []]) + , ("set hls next", SetNext) + , ("set hls latest", SetToolTag Latest) + , ("set hls nightly", SetToolVersion $ mkVersion $ (Str "nightly" :| []) :| []) + , ("set hls recommended", SetToolTag Recommended) + , ("set hls prerelease", SetToolVersion $ mkVersion $ (Str "prerelease" :| []) :| []) + , ("set hls latest-prerelease", SetToolTag LatestPrerelease) + , ("set hls latest-nightly", SetToolTag LatestNightly) + , ("set hls base-4.18", SetToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("set hls hls-2.0", SetToolVersion + $ Version + { _vEpoch = Nothing + , _vChunks = (Str "hls" :| []) :| [] + , _vRel = [Digits 2 :| [], Digits 0 :| []] + , _vMeta = Nothing + } + ) + ] + +setStackCheckList :: [(String, Either SetCommand SetOptions)] +setStackCheckList = mapSecond (Left . SetStack . SetOptions) + [ ("set stack", SetRecommended) + , ("set stack 2.9", SetToolVersion $ mkVersion $ (Digits 2 :| []) :| [Digits 9 :| []]) + , ("set stack next", SetNext) + , ("set stack latest", SetToolTag Latest) + , ("set stack nightly", SetToolVersion $ mkVersion $ (Str "nightly" :| []) :| []) + , ("set stack recommended", SetToolTag Recommended) + , ("set stack prerelease", SetToolVersion $ mkVersion $ (Str "prerelease" :| []) :| []) + , ("set stack latest-prerelease", SetToolTag LatestPrerelease) + , ("set stack latest-nightly", SetToolTag LatestNightly) + , ("set stack base-4.18", SetToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("set stack stack-2.9", SetToolVersion + $ Version + { _vEpoch = Nothing + , _vChunks = (Str "stack" :| []) :| [] + , _vRel = [Digits 2 :| [], Digits 9 :| []] + , _vMeta = Nothing + } + ) + ] + +setParseWith :: [String] -> IO (Either SetCommand SetOptions) +setParseWith args = do + Set a <- parseWith args + pure a + +parseWith :: [String] -> IO Command +parseWith args = + optCommand <$> handleParseResult + (execParserPure defaultPrefs (info GHCup.opts fullDesc) args) + +padLeft :: Int -> String -> String +padLeft desiredLength s = padding ++ s + where padding = replicate (desiredLength - length s) ' ' + +mapSecond :: (b -> c) -> [(a,b)] -> [(a,c)] +mapSecond = map . second From bcdf2b23f110fbe5ac502d025dc1021d86dbb4b3 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 22 Jul 2023 16:07:49 +0800 Subject: [PATCH 04/24] debug-info test --- ghcup.cabal | 2 ++ test/optparse-test/DebugInfoTest.hs | 18 ++++++++++++++++++ test/optparse-test/Main.hs | 6 +++++- test/optparse-test/SetTest.hs | 15 +-------------- test/optparse-test/Utils.hs | 17 +++++++++++++++++ 5 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 test/optparse-test/DebugInfoTest.hs create mode 100644 test/optparse-test/Utils.hs diff --git a/ghcup.cabal b/ghcup.cabal index 49b79c2..1ecfcfb 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -417,6 +417,8 @@ test-suite ghcup-optparse-test main-is: Main.hs other-modules: SetTest + Utils + DebugInfoTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text \ No newline at end of file diff --git a/test/optparse-test/DebugInfoTest.hs b/test/optparse-test/DebugInfoTest.hs new file mode 100644 index 0000000..719483e --- /dev/null +++ b/test/optparse-test/DebugInfoTest.hs @@ -0,0 +1,18 @@ +module DebugInfoTest where + +import Test.Tasty +import Test.Tasty.HUnit +import GHCup.OptParse +import Utils +import Control.Monad.IO.Class + +debugInfoTests :: TestTree +debugInfoTests = + testGroup "debug-info" $ pure + $ testCase "1. debug-info" $ do + res <- parseWith ["debug-info"] + liftIO $ assertBool "debug-info parse failed" (isDInfo res) + where + isDInfo :: Command -> Bool + isDInfo DInfo = True + isDInfo _ = False diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index e6059fc..4bc34e1 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -1,6 +1,10 @@ module Main where import Test.Tasty import qualified SetTest +import qualified DebugInfoTest main :: IO () -main = defaultMain SetTest.setTests \ No newline at end of file +main = defaultMain $ testGroup "ghcup" + [ SetTest.setTests + , DebugInfoTest.debugInfoTests + ] \ No newline at end of file diff --git a/test/optparse-test/SetTest.hs b/test/optparse-test/SetTest.hs index 18d0ec3..f39902b 100644 --- a/test/optparse-test/SetTest.hs +++ b/test/optparse-test/SetTest.hs @@ -5,12 +5,11 @@ module SetTest where import GHCup.OptParse as GHCup import Test.Tasty import Test.Tasty.HUnit -import Options.Applicative import Control.Monad.IO.Class (liftIO) import GHCup.Types import Data.Versions import Data.List.NonEmpty (NonEmpty ((:|))) -import Data.Bifunctor (second) +import Utils setTests :: TestTree setTests = @@ -190,15 +189,3 @@ setParseWith :: [String] -> IO (Either SetCommand SetOptions) setParseWith args = do Set a <- parseWith args pure a - -parseWith :: [String] -> IO Command -parseWith args = - optCommand <$> handleParseResult - (execParserPure defaultPrefs (info GHCup.opts fullDesc) args) - -padLeft :: Int -> String -> String -padLeft desiredLength s = padding ++ s - where padding = replicate (desiredLength - length s) ' ' - -mapSecond :: (b -> c) -> [(a,b)] -> [(a,c)] -mapSecond = map . second diff --git a/test/optparse-test/Utils.hs b/test/optparse-test/Utils.hs new file mode 100644 index 0000000..7874f2c --- /dev/null +++ b/test/optparse-test/Utils.hs @@ -0,0 +1,17 @@ +module Utils where + +import GHCup.OptParse as GHCup +import Options.Applicative +import Data.Bifunctor + +parseWith :: [String] -> IO Command +parseWith args = + optCommand <$> handleParseResult + (execParserPure defaultPrefs (info GHCup.opts fullDesc) args) + +padLeft :: Int -> String -> String +padLeft desiredLength s = padding ++ s + where padding = replicate (desiredLength - length s) ' ' + +mapSecond :: (b -> c) -> [(a,b)] -> [(a,c)] +mapSecond = map . second From 38db038953538f9b911d46813889650cf260a9d2 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 22 Jul 2023 17:14:49 +0800 Subject: [PATCH 05/24] changlog test --- .editorconfig | 11 ++++++ app/ghcup/GHCup/OptParse/ChangeLog.hs | 2 +- ghcup.cabal | 5 +-- lib/GHCup/Types.hs | 1 + test/optparse-test/ChangeLogTest.hs | 49 ++++++++++++++++++++++++++ test/optparse-test/DebugInfoTest.hs | 18 ---------- test/optparse-test/Main.hs | 8 +++-- test/optparse-test/OtherCommandTest.hs | 24 +++++++++++++ test/optparse-test/SetTest.hs | 3 -- test/optparse-test/Utils.hs | 5 +++ 10 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 .editorconfig create mode 100644 test/optparse-test/ChangeLogTest.hs delete mode 100644 test/optparse-test/DebugInfoTest.hs create mode 100644 test/optparse-test/OtherCommandTest.hs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..92806eb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +end_of_line = LF +trim_trailing_whitespace = true +insert_final_newline = true + +[*.hs] +indent_style = space +indent_size = 2 +max_line_length = 80 \ No newline at end of file diff --git a/app/ghcup/GHCup/OptParse/ChangeLog.hs b/app/ghcup/GHCup/OptParse/ChangeLog.hs index f209a74..7734d70 100644 --- a/app/ghcup/GHCup/OptParse/ChangeLog.hs +++ b/app/ghcup/GHCup/OptParse/ChangeLog.hs @@ -49,7 +49,7 @@ data ChangeLogOptions = ChangeLogOptions { clOpen :: Bool , clTool :: Maybe Tool , clToolVer :: Maybe ToolVersion - } + } deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index 1ecfcfb..bb8bcc4 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -418,7 +418,8 @@ test-suite ghcup-optparse-test other-modules: SetTest Utils - DebugInfoTest + OtherCommandTest + ChangeLogTest default-language: Haskell2010 ghc-options: -Wall - build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text \ No newline at end of file + build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index e67e720..eff9d0d 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -710,6 +710,7 @@ data ToolVersion = GHCVersion GHCTargetVersion | ToolVersion Version | ToolTag Tag | ToolDay Day + deriving (Eq, Show) instance Pretty ToolVersion where pPrint (GHCVersion v) = pPrint v diff --git a/test/optparse-test/ChangeLogTest.hs b/test/optparse-test/ChangeLogTest.hs new file mode 100644 index 0000000..5179cad --- /dev/null +++ b/test/optparse-test/ChangeLogTest.hs @@ -0,0 +1,49 @@ +module ChangeLogTest where + +import Test.Tasty +import GHCup.OptParse +import Utils +import Test.Tasty.HUnit +import Control.Monad.IO.Class +import GHCup.Types +import Data.Versions +import Data.List.NonEmpty (NonEmpty ((:|))) + +changeLogTests :: TestTree +changeLogTests = testGroup "changelog" $ map (uncurry check) checkList + where + check :: String -> ChangeLogOptions -> TestTree + check args expected = testCase args $ do + res <- changeLogParseWith (words args) + liftIO $ res @?= expected + +checkList :: [(String, ChangeLogOptions)] +checkList = + [ ("changelog", ChangeLogOptions False Nothing Nothing) + , ("changelog -o", ChangeLogOptions True Nothing Nothing) + , ("changelog -t ghc", ChangeLogOptions False (Just GHC) Nothing) + , ("changelog -t cabal", ChangeLogOptions False (Just Cabal) Nothing) + , ("changelog -t hls", ChangeLogOptions False (Just HLS) Nothing) + , ("changelog -t stack", ChangeLogOptions False (Just Stack) Nothing) + , ("changelog -t ghcup", ChangeLogOptions False (Just GHCup) Nothing) + , ("changelog 9.2", ChangeLogOptions False Nothing + (Just $ GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []])) + ) + , ("changelog recommended", ChangeLogOptions False Nothing (Just $ ToolTag Recommended)) + , ("changelog -t cabal recommended", ChangeLogOptions False (Just Cabal) (Just $ ToolTag Recommended)) + , ("changelog -t cabal 3.10.1.0", ChangeLogOptions False (Just Cabal) + (Just $ GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Digits 3 :| []) :| [Digits 10 :| [],Digits 1 :| [],Digits 0 :| []])) + ) + , ("changelog 2023-07-22", ChangeLogOptions False Nothing (Just (ToolDay (read "2023-07-22")))) + ] + +changeLogParseWith :: [String] -> IO ChangeLogOptions +changeLogParseWith args = do + ChangeLog a <- parseWith args + pure a diff --git a/test/optparse-test/DebugInfoTest.hs b/test/optparse-test/DebugInfoTest.hs deleted file mode 100644 index 719483e..0000000 --- a/test/optparse-test/DebugInfoTest.hs +++ /dev/null @@ -1,18 +0,0 @@ -module DebugInfoTest where - -import Test.Tasty -import Test.Tasty.HUnit -import GHCup.OptParse -import Utils -import Control.Monad.IO.Class - -debugInfoTests :: TestTree -debugInfoTests = - testGroup "debug-info" $ pure - $ testCase "1. debug-info" $ do - res <- parseWith ["debug-info"] - liftIO $ assertBool "debug-info parse failed" (isDInfo res) - where - isDInfo :: Command -> Bool - isDInfo DInfo = True - isDInfo _ = False diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index 4bc34e1..a84fa0d 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -1,10 +1,12 @@ module Main where import Test.Tasty import qualified SetTest -import qualified DebugInfoTest +import qualified OtherCommandTest +import qualified ChangeLogTest main :: IO () main = defaultMain $ testGroup "ghcup" [ SetTest.setTests - , DebugInfoTest.debugInfoTests - ] \ No newline at end of file + , OtherCommandTest.otherCommandTests + , ChangeLogTest.changeLogTests + ] diff --git a/test/optparse-test/OtherCommandTest.hs b/test/optparse-test/OtherCommandTest.hs new file mode 100644 index 0000000..5b1c3af --- /dev/null +++ b/test/optparse-test/OtherCommandTest.hs @@ -0,0 +1,24 @@ +module OtherCommandTest where + +import Test.Tasty +import Test.Tasty.HUnit +import GHCup.OptParse +import Utils +import Control.Monad.IO.Class + +otherCommandTests :: TestTree +otherCommandTests = testGroup "other command" + [ testCase "debug-info" $ do + res <- parseWith ["debug-info"] + liftIO $ assertBool "debug-info parse failed" (isDInfo res) + , testCase "tool-requirements" $ do + ToolRequirements opt <- parseWith ["tool-requirements"] + liftIO $ tlrRaw opt @?= False + , testCase "tool-requirements -r" $ do + ToolRequirements opt <- parseWith ["tool-requirements", "--raw-format"] + liftIO $ tlrRaw opt @?= True + ] + +isDInfo :: Command -> Bool +isDInfo DInfo = True +isDInfo _ = False diff --git a/test/optparse-test/SetTest.hs b/test/optparse-test/SetTest.hs index f39902b..767797a 100644 --- a/test/optparse-test/SetTest.hs +++ b/test/optparse-test/SetTest.hs @@ -33,9 +33,6 @@ setTests = res <- setParseWith (words args) liftIO $ res @?= expected -mkVersion :: NonEmpty VChunk -> Version -mkVersion chunks = Version Nothing chunks [] Nothing - oldStyleCheckList :: [(String, Either SetCommand SetOptions)] oldStyleCheckList = mapSecond (Right . SetOptions) [ ("set", SetRecommended) diff --git a/test/optparse-test/Utils.hs b/test/optparse-test/Utils.hs index 7874f2c..01bd76f 100644 --- a/test/optparse-test/Utils.hs +++ b/test/optparse-test/Utils.hs @@ -3,6 +3,8 @@ module Utils where import GHCup.OptParse as GHCup import Options.Applicative import Data.Bifunctor +import Data.Versions +import Data.List.NonEmpty (NonEmpty) parseWith :: [String] -> IO Command parseWith args = @@ -15,3 +17,6 @@ padLeft desiredLength s = padding ++ s mapSecond :: (b -> c) -> [(a,b)] -> [(a,c)] mapSecond = map . second + +mkVersion :: NonEmpty VChunk -> Version +mkVersion chunks = Version Nothing chunks [] Nothing From 16c7ecabe2b82cb42180b104f30df51f0efbe5bc Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 22 Jul 2023 17:20:42 +0800 Subject: [PATCH 06/24] nuke test --- test/optparse-test/OtherCommandTest.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/optparse-test/OtherCommandTest.hs b/test/optparse-test/OtherCommandTest.hs index 5b1c3af..2d82698 100644 --- a/test/optparse-test/OtherCommandTest.hs +++ b/test/optparse-test/OtherCommandTest.hs @@ -17,8 +17,15 @@ otherCommandTests = testGroup "other command" , testCase "tool-requirements -r" $ do ToolRequirements opt <- parseWith ["tool-requirements", "--raw-format"] liftIO $ tlrRaw opt @?= True + , testCase "nuke" $ do + res <- parseWith ["nuke"] + liftIO $ assertBool "nuke parse failed" (isNuke res) ] isDInfo :: Command -> Bool isDInfo DInfo = True isDInfo _ = False + +isNuke :: Command -> Bool +isNuke Nuke = True +isNuke _ = False From dc1a813305b11a085f4bc3b1db585e01be36ea35 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 22 Jul 2023 17:46:23 +0800 Subject: [PATCH 07/24] config test --- app/ghcup/GHCup/OptParse/Config.hs | 1 + ghcup.cabal | 3 ++- test/optparse-test/ConfigTest.hs | 34 ++++++++++++++++++++++++++++++ test/optparse-test/Main.hs | 3 +++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/optparse-test/ConfigTest.hs diff --git a/app/ghcup/GHCup/OptParse/Config.hs b/app/ghcup/GHCup/OptParse/Config.hs index 07a3f76..6e71cd4 100644 --- a/app/ghcup/GHCup/OptParse/Config.hs +++ b/app/ghcup/GHCup/OptParse/Config.hs @@ -52,6 +52,7 @@ data ConfigCommand | SetConfig String (Maybe String) | InitConfig | AddReleaseChannel Bool URI + deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index bb8bcc4..cf7b086 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -420,6 +420,7 @@ test-suite ghcup-optparse-test Utils OtherCommandTest ChangeLogTest + ConfigTest default-language: Haskell2010 ghc-options: -Wall - build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text + build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/test/optparse-test/ConfigTest.hs b/test/optparse-test/ConfigTest.hs new file mode 100644 index 0000000..6f8f658 --- /dev/null +++ b/test/optparse-test/ConfigTest.hs @@ -0,0 +1,34 @@ +{-# LANGUAGE QuasiQuotes #-} + +module ConfigTest where + +import Test.Tasty +import Test.Tasty.HUnit +import GHCup.OptParse +import Utils +import Control.Monad.IO.Class +import URI.ByteString.QQ + +configTests :: TestTree +configTests = testGroup "config" $ map (uncurry check) checkList + where + check :: String -> ConfigCommand -> TestTree + check args expected = testCase args $ do + res <- configParseWith (words args) + liftIO $ res @?= expected + +checkList :: [(String, ConfigCommand)] +checkList = + [ ("config", ShowConfig) + , ("config init", InitConfig) + , ("config show", ShowConfig) + , ("config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml" + , AddReleaseChannel False [uri|https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml|] + ) + , ("config set cache true", SetConfig "cache" (Just "true")) + ] + +configParseWith :: [String] -> IO ConfigCommand +configParseWith args = do + Config a <- parseWith args + pure a diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index a84fa0d..d75eb12 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -1,12 +1,15 @@ module Main where + import Test.Tasty import qualified SetTest import qualified OtherCommandTest import qualified ChangeLogTest +import qualified ConfigTest main :: IO () main = defaultMain $ testGroup "ghcup" [ SetTest.setTests , OtherCommandTest.otherCommandTests , ChangeLogTest.changeLogTests + , ConfigTest.configTests ] From aafb77df7c1ff1ad28483c999967be84522a7cb3 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 22 Jul 2023 23:10:27 +0800 Subject: [PATCH 08/24] install test --- app/ghcup/GHCup/OptParse/Install.hs | 3 +- ghcup.cabal | 1 + test/optparse-test/InstallTest.hs | 218 ++++++++++++++++++++++++++++ test/optparse-test/Main.hs | 2 + test/optparse-test/SetTest.hs | 16 +- test/optparse-test/Utils.hs | 16 ++ 6 files changed, 241 insertions(+), 15 deletions(-) create mode 100644 test/optparse-test/InstallTest.hs diff --git a/app/ghcup/GHCup/OptParse/Install.hs b/app/ghcup/GHCup/OptParse/Install.hs index e13f740..9cf68ba 100644 --- a/app/ghcup/GHCup/OptParse/Install.hs +++ b/app/ghcup/GHCup/OptParse/Install.hs @@ -54,6 +54,7 @@ data InstallCommand = InstallGHC InstallOptions | InstallCabal InstallOptions | InstallHLS InstallOptions | InstallStack InstallOptions + deriving (Eq, Show) @@ -70,7 +71,7 @@ data InstallOptions = InstallOptions , isolateDir :: Maybe FilePath , forceInstall :: Bool , addConfArgs :: [T.Text] - } + } deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index cf7b086..5bc4b80 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -421,6 +421,7 @@ test-suite ghcup-optparse-test OtherCommandTest ChangeLogTest ConfigTest + InstallTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/test/optparse-test/InstallTest.hs b/test/optparse-test/InstallTest.hs new file mode 100644 index 0000000..5dcfe35 --- /dev/null +++ b/test/optparse-test/InstallTest.hs @@ -0,0 +1,218 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} + +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 + +-- 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) + , ("cabal", installCabalCheckList) + , ("hls", installHlsCheckList) + , ("stack", installStackCheckList) + ] + +defaultOptions :: InstallOptions +defaultOptions = InstallOptions Nothing Nothing False Nothing False [] + +-- | Don't set as active version +mkInstallOptions :: ToolVersion -> InstallOptions +mkInstallOptions ver = InstallOptions (Just ver) Nothing False Nothing False [] + +-- | Set as active version +mkInstallOptions' :: ToolVersion -> InstallOptions +mkInstallOptions' ver = InstallOptions (Just ver) Nothing True Nothing False [] + +oldStyleCheckList :: [(String, Either InstallCommand InstallOptions)] +oldStyleCheckList = + ("install", Right defaultOptions) + : ("install --set", Right defaultOptions{instSet = True}) + : ("install --force", Right defaultOptions{forceInstall = True}) + : ("install -i /", Right defaultOptions{Install.isolateDir = Just "/"}) + : ("install -u https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz head" + , Right defaultOptions + { 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 (mkVersion $ (Str "head" :| []) :| []) + } + ) + : mapSecond + (Right . mkInstallOptions) + [ ("install ghc-9.2", GHCVersion + $ GHCTargetVersion + (Just "ghc") + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]) + ) + -- invalid + , ("install next", GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "next" :| []) :| []) + ) + , ("install latest", ToolTag Latest) + , ("install nightly", GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "nightly" :| []) :| []) + ) + , ("install recommended", ToolTag Recommended) + , ("install prerelease", GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "prerelease" :| []) :| []) + ) + , ("install latest-prerelease", ToolTag LatestPrerelease) + , ("install latest-nightly", ToolTag LatestNightly) + , ("install ghc-javascript-unknown-ghcjs-9.6", GHCVersion + $ GHCTargetVersion + (Just "ghc-javascript-unknown-ghcjs") + (mkVersion $ (Digits 9 :| []) :| [Digits 6 :| []]) + ) + , ("install base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("install cabal-3.10", GHCVersion + $ GHCTargetVersion + (Just "cabal") + (mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + ) + , ("install hls-2.0.0.0", GHCVersion + $ GHCTargetVersion + (Just "hls") + (mkVersion $ (Digits 2 :| []) :| [Digits 0 :| [], Digits 0 :| [], Digits 0 :| []]) + ) + , ("install stack-2.9.3", GHCVersion + $ GHCTargetVersion + (Just "stack") + (mkVersion $ (Digits 2 :| []) :| [Digits 9 :| [], Digits 3 :| []]) + ) + ] + +installGhcCheckList :: [(String, Either InstallCommand InstallOptions)] +installGhcCheckList = + ("install ghc", Left $ InstallGHC defaultOptions) + : mapSecond (Left . InstallGHC . mkInstallOptions) + [ ("install ghc 9.2", GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]) + ) + , ("install ghc next", GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "next" :| []) :| []) + ) + , ("install ghc latest", ToolTag Latest) + , ("install ghc nightly", GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "nightly" :| []) :| []) + ) + , ("install ghc recommended", ToolTag Recommended) + , ("install ghc prerelease", GHCVersion + $ GHCTargetVersion + Nothing + (mkVersion $ (Str "prerelease" :| []) :| []) + ) + , ("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") + (mkVersion $ (Digits 9 :| []) :| [Digits 6 :| []]) + ) + , ("install ghc base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("install ghc ghc-9.2", GHCVersion + $ GHCTargetVersion + (Just "ghc") + (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| []]) + ) + ] + +installCabalCheckList :: [(String, Either InstallCommand InstallOptions)] +installCabalCheckList = + ("install cabal", Left $ InstallCabal defaultOptions{instSet = True}) + : mapSecond (Left . InstallCabal . mkInstallOptions') + [ ("install cabal 3.10", ToolVersion $ mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + , ("install cabal next", ToolVersion $ mkVersion $ (Str "next" :| []) :| []) + , ("install cabal latest", ToolTag Latest) + , ("install cabal nightly", ToolVersion $ mkVersion $ (Str "nightly" :| []) :| []) + , ("install cabal recommended", ToolTag Recommended) + , ("install cabal prerelease", ToolVersion $ mkVersion $ (Str "prerelease" :| []) :| []) + , ("install cabal latest-prerelease", ToolTag LatestPrerelease) + , ("install cabal latest-nightly", ToolTag LatestNightly) + , ("install cabal base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("install cabal cabal-3.10", ToolVersion + $ Version + { _vEpoch = Nothing + , _vChunks = (Str "cabal" :| []) :| [] + , _vRel = [Digits 3 :| [], Digits 10 :| []] + , _vMeta = Nothing + } + ) + ] + +installHlsCheckList :: [(String, Either InstallCommand InstallOptions)] +installHlsCheckList = + ("install hls", Left $ InstallHLS defaultOptions{instSet = True}) + : mapSecond (Left . InstallHLS . mkInstallOptions') + [ ("install hls 3.10", ToolVersion $ mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + , ("install hls next", ToolVersion $ mkVersion $ (Str "next" :| []) :| []) + , ("install hls latest", ToolTag Latest) + , ("install hls nightly", ToolVersion $ mkVersion $ (Str "nightly" :| []) :| []) + , ("install hls recommended", ToolTag Recommended) + , ("install hls prerelease", ToolVersion $ mkVersion $ (Str "prerelease" :| []) :| []) + , ("install hls latest-prerelease", ToolTag LatestPrerelease) + , ("install hls latest-nightly", ToolTag LatestNightly) + , ("install hls base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("install hls hls-2.0", ToolVersion + $ Version + { _vEpoch = Nothing + , _vChunks = (Str "hls" :| []) :| [] + , _vRel = [Digits 2 :| [], Digits 0 :| []] + , _vMeta = Nothing + } + ) + ] + +installStackCheckList :: [(String, Either InstallCommand InstallOptions)] +installStackCheckList = + ("install stack", Left $ InstallStack defaultOptions{instSet = True}) + : mapSecond (Left . InstallStack . mkInstallOptions') + [ ("install stack 3.10", ToolVersion $ mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + , ("install stack next", ToolVersion $ mkVersion $ (Str "next" :| []) :| []) + , ("install stack latest", ToolTag Latest) + , ("install stack nightly", ToolVersion $ mkVersion $ (Str "nightly" :| []) :| []) + , ("install stack recommended", ToolTag Recommended) + , ("install stack prerelease", ToolVersion $ mkVersion $ (Str "prerelease" :| []) :| []) + , ("install stack latest-prerelease", ToolTag LatestPrerelease) + , ("install stack latest-nightly", ToolTag LatestNightly) + , ("install stack base-4.18", ToolTag (Base (PVP {_pComponents = 4 :| [18]}))) + , ("install stack stack-2.9", ToolVersion + $ Version + { _vEpoch = Nothing + , _vChunks = (Str "stack" :| []) :| [] + , _vRel = [Digits 2 :| [], Digits 9 :| []] + , _vMeta = Nothing + } + ) + ] + +installParseWith :: [String] -> IO (Either InstallCommand InstallOptions) +installParseWith args = do + Install a <- parseWith args + pure a diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index d75eb12..ca877b6 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -5,6 +5,7 @@ import qualified SetTest import qualified OtherCommandTest import qualified ChangeLogTest import qualified ConfigTest +import qualified InstallTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -12,4 +13,5 @@ main = defaultMain $ testGroup "ghcup" , OtherCommandTest.otherCommandTests , ChangeLogTest.changeLogTests , ConfigTest.configTests + , InstallTest.installTests ] diff --git a/test/optparse-test/SetTest.hs b/test/optparse-test/SetTest.hs index 767797a..cb0cd63 100644 --- a/test/optparse-test/SetTest.hs +++ b/test/optparse-test/SetTest.hs @@ -2,10 +2,8 @@ module SetTest where -import GHCup.OptParse as GHCup +import GHCup.OptParse import Test.Tasty -import Test.Tasty.HUnit -import Control.Monad.IO.Class (liftIO) import GHCup.Types import Data.Versions import Data.List.NonEmpty (NonEmpty ((:|))) @@ -15,23 +13,13 @@ setTests :: TestTree setTests = testGroup "set" $ map - buildTestTree + (buildTestTree setParseWith) [ ("old-style", oldStyleCheckList) , ("ghc", setGhcCheckList) , ("cabal", setCabalCheckList) , ("hls", setHlsCheckList) , ("stack", setStackCheckList) ] - where - buildTestTree :: (String, [(String, Either SetCommand SetOptions)]) -> TestTree - buildTestTree (title, checkList) = - testGroup title - $ zipWith (uncurry . check) [1 :: Int ..] checkList - - check :: Int -> String -> Either SetCommand SetOptions -> TestTree - check idx args expected = testCase (padLeft 2 (show idx) ++ "." ++ args) $ do - res <- setParseWith (words args) - liftIO $ res @?= expected oldStyleCheckList :: [(String, Either SetCommand SetOptions)] oldStyleCheckList = mapSecond (Right . SetOptions) diff --git a/test/optparse-test/Utils.hs b/test/optparse-test/Utils.hs index 01bd76f..6f56ec8 100644 --- a/test/optparse-test/Utils.hs +++ b/test/optparse-test/Utils.hs @@ -5,6 +5,9 @@ import Options.Applicative import Data.Bifunctor import Data.Versions import Data.List.NonEmpty (NonEmpty) +import Test.Tasty +import Test.Tasty.HUnit +import Control.Monad.IO.Class parseWith :: [String] -> IO Command parseWith args = @@ -20,3 +23,16 @@ mapSecond = map . second mkVersion :: NonEmpty VChunk -> Version mkVersion chunks = Version Nothing chunks [] Nothing + +buildTestTree + :: (Eq a, Show a) + => ([String] -> IO a) -- ^ The parse function + -> (String, [(String, a)]) -- ^ The check list @(test group, [(cli command, expected value)])@ + -> TestTree +buildTestTree parse (title, checkList) = + testGroup title + $ zipWith (uncurry . check) [1 :: Int ..] checkList + where + check idx args expected = testCase (padLeft 2 (show idx) ++ "." ++ args) $ do + res <- parse (words args) + liftIO $ res @?= expected From fb2e3f27406f72e3ea89a163cb7db429d77706fa Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sun, 23 Jul 2023 15:19:13 +0800 Subject: [PATCH 09/24] test test --- test/optparse-test/OtherCommandTest.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/optparse-test/OtherCommandTest.hs b/test/optparse-test/OtherCommandTest.hs index 2d82698..1a87488 100644 --- a/test/optparse-test/OtherCommandTest.hs +++ b/test/optparse-test/OtherCommandTest.hs @@ -20,6 +20,9 @@ otherCommandTests = testGroup "other command" , testCase "nuke" $ do res <- parseWith ["nuke"] liftIO $ assertBool "nuke parse failed" (isNuke res) + , testCase "test ghc" $ do + res <- parseWith ["test", "ghc"] + liftIO $ assertBool "test parse failed" (isTest res) ] isDInfo :: Command -> Bool @@ -29,3 +32,7 @@ isDInfo _ = False isNuke :: Command -> Bool isNuke Nuke = True isNuke _ = False + +isTest :: Command -> Bool +isTest (Test _) = True +isTest _ = False From cf1e8659b076942b9cb12b76367fa54fbfde05b7 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sun, 23 Jul 2023 15:41:27 +0800 Subject: [PATCH 10/24] unset test --- app/ghcup/GHCup/OptParse/UnSet.hs | 5 ++-- ghcup.cabal | 1 + test/optparse-test/Main.hs | 2 ++ test/optparse-test/UnsetTest.hs | 50 +++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 test/optparse-test/UnsetTest.hs diff --git a/app/ghcup/GHCup/OptParse/UnSet.hs b/app/ghcup/GHCup/OptParse/UnSet.hs index a3b33b7..313fcc9 100644 --- a/app/ghcup/GHCup/OptParse/UnSet.hs +++ b/app/ghcup/GHCup/OptParse/UnSet.hs @@ -48,6 +48,7 @@ data UnsetCommand = UnsetGHC UnsetOptions | UnsetCabal UnsetOptions | UnsetHLS UnsetOptions | UnsetStack UnsetOptions + deriving (Eq, Show) @@ -59,7 +60,7 @@ data UnsetCommand = UnsetGHC UnsetOptions data UnsetOptions = UnsetOptions { sToolVer :: Maybe T.Text -- target platform triple - } + } deriving (Eq, Show) @@ -68,7 +69,7 @@ data UnsetOptions = UnsetOptions --[ Parsers ]-- --------------- - + unsetParser :: Parser UnsetCommand unsetParser = subparser diff --git a/ghcup.cabal b/ghcup.cabal index 5bc4b80..04a4d9b 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -422,6 +422,7 @@ test-suite ghcup-optparse-test ChangeLogTest ConfigTest InstallTest + UnsetTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index ca877b6..51eb318 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -6,6 +6,7 @@ import qualified OtherCommandTest import qualified ChangeLogTest import qualified ConfigTest import qualified InstallTest +import qualified UnsetTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -14,4 +15,5 @@ main = defaultMain $ testGroup "ghcup" , ChangeLogTest.changeLogTests , ConfigTest.configTests , InstallTest.installTests + , UnsetTest.unsetTests ] diff --git a/test/optparse-test/UnsetTest.hs b/test/optparse-test/UnsetTest.hs new file mode 100644 index 0000000..be49fba --- /dev/null +++ b/test/optparse-test/UnsetTest.hs @@ -0,0 +1,50 @@ +{-# LANGUAGE OverloadedStrings #-} + +module UnsetTest where + +import Test.Tasty +import GHCup.OptParse +import Utils + + +unsetTests :: TestTree +unsetTests = + testGroup "unset" + $ map (buildTestTree unsetParseWith) + [ ("ghc", unsetGhcCheckList) + , ("cabal", unsetCabalCheckList) + , ("hls", unsetHlsCheckList) + , ("stack", unsetStackCheckList) + ] + +unsetGhcCheckList :: [(String, UnsetCommand)] +unsetGhcCheckList = mapSecond (UnsetGHC . UnsetOptions) + [ ("unset ghc", Nothing) + , ("unset ghc armv7-unknown-linux-gnueabihf", Just "armv7-unknown-linux-gnueabihf") + ] + +unsetCabalCheckList :: [(String, UnsetCommand)] +unsetCabalCheckList = mapSecond (UnsetCabal . UnsetOptions) + [ ("unset cabal", Nothing) + -- This never used + , ("unset cabal armv7-unknown-linux-gnueabihf", Just "armv7-unknown-linux-gnueabihf") + ] + +unsetHlsCheckList :: [(String, UnsetCommand)] +unsetHlsCheckList = mapSecond (UnsetHLS . UnsetOptions) + [ ("unset hls", Nothing) + -- This never used + , ("unset hls armv7-unknown-linux-gnueabihf", Just "armv7-unknown-linux-gnueabihf") + ] + +unsetStackCheckList :: [(String, UnsetCommand)] +unsetStackCheckList = mapSecond (UnsetStack . UnsetOptions) + [ ("unset stack", Nothing) + -- This never used + , ("unset stack armv7-unknown-linux-gnueabihf", Just "armv7-unknown-linux-gnueabihf") + ] + +unsetParseWith :: [String] -> IO UnsetCommand +unsetParseWith args = do + UnSet a <- parseWith args + pure a From c92875882ae86e409c32460c90c2fa39df45de6b Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sun, 23 Jul 2023 16:30:25 +0800 Subject: [PATCH 11/24] rm test --- app/ghcup/GHCup/OptParse/Rm.hs | 3 +- ghcup.cabal | 1 + test/optparse-test/Main.hs | 2 + test/optparse-test/RmTest.hs | 80 ++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 test/optparse-test/RmTest.hs diff --git a/app/ghcup/GHCup/OptParse/Rm.hs b/app/ghcup/GHCup/OptParse/Rm.hs index bfacb40..39344ba 100644 --- a/app/ghcup/GHCup/OptParse/Rm.hs +++ b/app/ghcup/GHCup/OptParse/Rm.hs @@ -50,6 +50,7 @@ data RmCommand = RmGHC RmOptions | RmCabal Version | RmHLS Version | RmStack Version + deriving (Eq, Show) @@ -61,7 +62,7 @@ data RmCommand = RmGHC RmOptions data RmOptions = RmOptions { ghcVer :: GHCTargetVersion - } + } deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index 04a4d9b..03d0b47 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -423,6 +423,7 @@ test-suite ghcup-optparse-test ConfigTest InstallTest UnsetTest + RmTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index 51eb318..9e26b0d 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -7,6 +7,7 @@ import qualified ChangeLogTest import qualified ConfigTest import qualified InstallTest import qualified UnsetTest +import qualified RmTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -16,4 +17,5 @@ main = defaultMain $ testGroup "ghcup" , ConfigTest.configTests , InstallTest.installTests , UnsetTest.unsetTests + , RmTest.rmTests ] diff --git a/test/optparse-test/RmTest.hs b/test/optparse-test/RmTest.hs new file mode 100644 index 0000000..4ef25e2 --- /dev/null +++ b/test/optparse-test/RmTest.hs @@ -0,0 +1,80 @@ +{-# LANGUAGE OverloadedStrings #-} + +module RmTest where + +import Test.Tasty +import GHCup.OptParse +import Utils +import GHCup.Types +import Data.List.NonEmpty (NonEmpty ((:|))) +import Data.Versions + + +rmTests :: TestTree +rmTests = + testGroup "rm" + $ map (buildTestTree rmParseWith) + [ ("old-style", oldStyleCheckList) + , ("ghc", rmGhcCheckList) + , ("cabal", rmCabalCheckList) + , ("hls", rmHlsCheckList) + , ("stack", rmStackCheckList) + ] + +oldStyleCheckList :: [(String, Either RmCommand RmOptions)] +oldStyleCheckList = mapSecond (Right . RmOptions) + [ -- failed with ("rm", xxx) + ("rm 9.2.8", mkTVer (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| [], Digits 8 :| []])) + , ("rm ghc-9.2.8", GHCTargetVersion (Just "ghc") (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| [], Digits 8 :| []])) + ] + +rmGhcCheckList :: [(String, Either RmCommand RmOptions)] +rmGhcCheckList = mapSecond (Left . RmGHC . RmOptions) + [ -- failed with ("rm ghc", xxx) + ("rm ghc 9.2.8", mkTVer (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| [], Digits 8 :| []])) + , ("rm ghc ghc-9.2.8", GHCTargetVersion (Just "ghc") (mkVersion $ (Digits 9 :| []) :| [Digits 2 :| [], Digits 8 :| []])) + ] + +rmCabalCheckList :: [(String, Either RmCommand RmOptions)] +rmCabalCheckList = mapSecond (Left . RmCabal) + [ -- failed with ("rm cabal", xxx) + ("rm cabal 3.10", mkVersion $ (Digits 3 :| []) :| [Digits 10 :| []]) + , ("rm cabal cabal-3.10", Version + { _vEpoch = Nothing + , _vChunks = (Str "cabal" :| []) :| [] + , _vRel = [Digits 3 :| [], Digits 10 :| []] + , _vMeta = Nothing + } + ) + ] + +rmHlsCheckList :: [(String, Either RmCommand RmOptions)] +rmHlsCheckList = mapSecond (Left . RmHLS) + [ -- failed with ("rm hls", xxx) + ("rm hls 2.0", mkVersion $ (Digits 2 :| []) :| [Digits 0 :| []]) + , ("rm hls hls-2.0", Version + { _vEpoch = Nothing + , _vChunks = (Str "hls" :| []) :| [] + , _vRel = [Digits 2 :| [], Digits 0 :| []] + , _vMeta = Nothing + } + ) + ] + +rmStackCheckList :: [(String, Either RmCommand RmOptions)] +rmStackCheckList = mapSecond (Left . RmStack) + [ -- failed with ("rm stack", xxx) + ("rm stack 2.9.1", mkVersion $ (Digits 2 :| []) :| [Digits 9 :| [], Digits 1 :| []]) + , ("rm stack stack-2.9.1", Version + { _vEpoch = Nothing + , _vChunks = (Str "stack" :| []) :| [] + , _vRel = [Digits 2 :| [], Digits 9 :| [], Digits 1 :| []] + , _vMeta = Nothing + } + ) + ] + +rmParseWith :: [String] -> IO (Either RmCommand RmOptions) +rmParseWith args = do + Rm a <- parseWith args + pure a From f400f43b8c86aee156dfae569a27643e0a245671 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sun, 23 Jul 2023 23:51:03 +0800 Subject: [PATCH 12/24] list test --- app/ghcup/GHCup/OptParse/List.hs | 2 +- ghcup.cabal | 1 + lib/GHCup/List.hs | 2 +- test/optparse-test/ListTest.hs | 36 ++++++++++++++++++++++++++++++++ test/optparse-test/Main.hs | 2 ++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/optparse-test/ListTest.hs diff --git a/app/ghcup/GHCup/OptParse/List.hs b/app/ghcup/GHCup/OptParse/List.hs index 56a6c0f..3989adc 100644 --- a/app/ghcup/GHCup/OptParse/List.hs +++ b/app/ghcup/GHCup/OptParse/List.hs @@ -58,7 +58,7 @@ data ListOptions = ListOptions , lHideOld :: Bool , lShowNightly :: Bool , lRawFormat :: Bool - } + } deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index 03d0b47..c9672a4 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -424,6 +424,7 @@ test-suite ghcup-optparse-test InstallTest UnsetTest RmTest + ListTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/lib/GHCup/List.hs b/lib/GHCup/List.hs index 3d38880..afe1d6d 100644 --- a/lib/GHCup/List.hs +++ b/lib/GHCup/List.hs @@ -65,7 +65,7 @@ import qualified Data.Text as T data ListCriteria = ListInstalled Bool | ListSet Bool | ListAvailable Bool - deriving Show + deriving (Eq, Show) -- | A list result describes a single tool version -- and various of its properties. diff --git a/test/optparse-test/ListTest.hs b/test/optparse-test/ListTest.hs new file mode 100644 index 0000000..670426d --- /dev/null +++ b/test/optparse-test/ListTest.hs @@ -0,0 +1,36 @@ +module ListTest where +import Test.Tasty +import GHCup.OptParse +import Utils +import GHCup.List +import GHCup.Types + + +listTests :: TestTree +listTests = buildTestTree listParseWith ("list", listCheckList) + +defaultOptions :: ListOptions +defaultOptions = ListOptions Nothing Nothing Nothing Nothing False False False + +listCheckList :: [(String, ListOptions)] +listCheckList = + [ ("list", defaultOptions) + , ("list -t ghc", defaultOptions{loTool = Just GHC}) + , ("list -t cabal", defaultOptions{loTool = Just Cabal}) + , ("list -t hls", defaultOptions{loTool = Just HLS}) + , ("list -t stack", defaultOptions{loTool = Just Stack}) + , ("list -c installed", defaultOptions{lCriteria = Just $ ListInstalled True}) + , ("list -c +installed", defaultOptions{lCriteria = Just $ ListInstalled True}) + , ("list -c -installed", defaultOptions{lCriteria = Just $ ListInstalled False}) + , ("list -c set", defaultOptions{lCriteria = Just $ ListSet True}) + , ("list -c +set", defaultOptions{lCriteria = Just $ ListSet True}) + , ("list -c -set", defaultOptions{lCriteria = Just $ ListSet False}) + , ("list -c available", defaultOptions{lCriteria = Just $ ListAvailable True}) + , ("list -c +available", defaultOptions{lCriteria = Just $ ListAvailable True}) + , ("list -c -available", defaultOptions{lCriteria = Just $ ListAvailable False}) + ] + +listParseWith :: [String] -> IO ListOptions +listParseWith args = do + List a <- parseWith args + pure a diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index 9e26b0d..8bacfb2 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -8,6 +8,7 @@ import qualified ConfigTest import qualified InstallTest import qualified UnsetTest import qualified RmTest +import qualified ListTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -18,4 +19,5 @@ main = defaultMain $ testGroup "ghcup" , InstallTest.installTests , UnsetTest.unsetTests , RmTest.rmTests + , ListTest.listTests ] From 36463ebf97cc5138c78d9a3de54f11c6ed4091ec Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Mon, 24 Jul 2023 22:09:03 +0800 Subject: [PATCH 13/24] list test --- test/optparse-test/ListTest.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/optparse-test/ListTest.hs b/test/optparse-test/ListTest.hs index 670426d..722e53b 100644 --- a/test/optparse-test/ListTest.hs +++ b/test/optparse-test/ListTest.hs @@ -1,4 +1,5 @@ module ListTest where + import Test.Tasty import GHCup.OptParse import Utils @@ -28,6 +29,15 @@ listCheckList = , ("list -c available", defaultOptions{lCriteria = Just $ ListAvailable True}) , ("list -c +available", defaultOptions{lCriteria = Just $ ListAvailable True}) , ("list -c -available", defaultOptions{lCriteria = Just $ ListAvailable False}) + , ("list -s 2023-07-22", defaultOptions{lFrom = Just $ read "2023-07-22"}) + , ("list -u 2023-07-22", defaultOptions{lTo = Just $ read "2023-07-22"}) + , ("list --since 2023-07-22 --until 2023-07-22", defaultOptions{lFrom = Just $ read "2023-07-22", lTo = Just $ read "2023-07-22"}) + , ("list -o", defaultOptions{lHideOld = True}) + , ("list --hide-old", defaultOptions{lHideOld = True}) + , ("list -n", defaultOptions{lShowNightly = True}) + , ("list --show-nightly", defaultOptions{lShowNightly = True}) + , ("list -r", defaultOptions{lRawFormat = True}) + , ("list --raw-format", defaultOptions{lRawFormat = True}) ] listParseWith :: [String] -> IO ListOptions From dfebfc95048d875ac12fcda785df47700093c873 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Mon, 24 Jul 2023 22:26:33 +0800 Subject: [PATCH 14/24] upgrade test --- app/ghcup/GHCup/OptParse/Upgrade.hs | 2 +- ghcup.cabal | 1 + test/optparse-test/Main.hs | 2 ++ test/optparse-test/UpgradeTest.hs | 38 +++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/optparse-test/UpgradeTest.hs diff --git a/app/ghcup/GHCup/OptParse/Upgrade.hs b/app/ghcup/GHCup/OptParse/Upgrade.hs index 8849700..1b71c78 100644 --- a/app/ghcup/GHCup/OptParse/Upgrade.hs +++ b/app/ghcup/GHCup/OptParse/Upgrade.hs @@ -50,7 +50,7 @@ import Data.Versions hiding (str) data UpgradeOpts = UpgradeInplace | UpgradeAt FilePath | UpgradeGHCupDir - deriving Show + deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index c9672a4..c7b9d8b 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -425,6 +425,7 @@ test-suite ghcup-optparse-test UnsetTest RmTest ListTest + UpgradeTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index 8bacfb2..c15743a 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -9,6 +9,7 @@ import qualified InstallTest import qualified UnsetTest import qualified RmTest import qualified ListTest +import qualified UpgradeTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -20,4 +21,5 @@ main = defaultMain $ testGroup "ghcup" , UnsetTest.unsetTests , RmTest.rmTests , ListTest.listTests + , UpgradeTest.upgradeTests ] diff --git a/test/optparse-test/UpgradeTest.hs b/test/optparse-test/UpgradeTest.hs new file mode 100644 index 0000000..f54d2be --- /dev/null +++ b/test/optparse-test/UpgradeTest.hs @@ -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) From 6f07b6a343fe0b6974f88ae6c21b3b5f5ed8d93c Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Mon, 24 Jul 2023 23:04:18 +0800 Subject: [PATCH 15/24] compile test --- app/ghcup/GHCup/OptParse/Compile.hs | 5 ++- ghcup.cabal | 1 + lib/GHCup/GHC.hs | 1 + lib/GHCup/HLS.hs | 1 + test/optparse-test/CompileTest.hs | 64 +++++++++++++++++++++++++++++ test/optparse-test/Main.hs | 2 + test/optparse-test/Utils.hs | 7 ++++ 7 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 test/optparse-test/CompileTest.hs diff --git a/app/ghcup/GHCup/OptParse/Compile.hs b/app/ghcup/GHCup/OptParse/Compile.hs index f50fb9d..5d4a957 100644 --- a/app/ghcup/GHCup/OptParse/Compile.hs +++ b/app/ghcup/GHCup/OptParse/Compile.hs @@ -57,6 +57,7 @@ import Text.Read (readEither) data CompileCommand = CompileGHC GHCCompileOptions | CompileHLS HLSCompileOptions + deriving (Eq, Show) @@ -78,7 +79,7 @@ data GHCCompileOptions = GHCCompileOptions , buildFlavour :: Maybe String , hadrian :: Bool , isolateDir :: Maybe FilePath - } + } deriving (Eq, Show) data HLSCompileOptions = HLSCompileOptions @@ -93,7 +94,7 @@ data HLSCompileOptions = HLSCompileOptions , patches :: Maybe (Either FilePath [URI]) , targetGHCs :: [ToolVersion] , cabalArgs :: [Text] - } + } deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index c7b9d8b..3dd02c7 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -426,6 +426,7 @@ test-suite ghcup-optparse-test RmTest ListTest UpgradeTest + CompileTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/lib/GHCup/GHC.hs b/lib/GHCup/GHC.hs index df59031..764a4aa 100644 --- a/lib/GHCup/GHC.hs +++ b/lib/GHCup/GHC.hs @@ -83,6 +83,7 @@ import qualified Text.Megaparsec as MP data GHCVer = SourceDist Version | GitDist GitBranch | RemoteDist URI + deriving (Eq, Show) diff --git a/lib/GHCup/HLS.hs b/lib/GHCup/HLS.hs index 744ba54..da451ef 100644 --- a/lib/GHCup/HLS.hs +++ b/lib/GHCup/HLS.hs @@ -75,6 +75,7 @@ data HLSVer = SourceDist Version | GitDist GitBranch | HackageDist Version | RemoteDist URI + deriving (Eq, Show) diff --git a/test/optparse-test/CompileTest.hs b/test/optparse-test/CompileTest.hs new file mode 100644 index 0000000..5880831 --- /dev/null +++ b/test/optparse-test/CompileTest.hs @@ -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 diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index c15743a..be1776a 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -10,6 +10,7 @@ import qualified UnsetTest import qualified RmTest import qualified ListTest import qualified UpgradeTest +import qualified CompileTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -22,4 +23,5 @@ main = defaultMain $ testGroup "ghcup" , RmTest.rmTests , ListTest.listTests , UpgradeTest.upgradeTests + , CompileTest.compileTests ] diff --git a/test/optparse-test/Utils.hs b/test/optparse-test/Utils.hs index 6f56ec8..2c99166 100644 --- a/test/optparse-test/Utils.hs +++ b/test/optparse-test/Utils.hs @@ -1,3 +1,4 @@ +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} module Utils where import GHCup.OptParse as GHCup @@ -8,6 +9,7 @@ import Data.List.NonEmpty (NonEmpty) import Test.Tasty import Test.Tasty.HUnit import Control.Monad.IO.Class +import qualified Data.Text as T parseWith :: [String] -> IO Command parseWith args = @@ -24,6 +26,11 @@ mapSecond = map . second mkVersion :: NonEmpty VChunk -> Version mkVersion chunks = Version Nothing chunks [] Nothing +mkVersion' :: T.Text -> Version +mkVersion' txt = + let Right ver = version txt + in ver + buildTestTree :: (Eq a, Show a) => ([String] -> IO a) -- ^ The parse function From 7076472bde7914fba9f3c66150bb325ec6658368 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Tue, 25 Jul 2023 22:58:01 +0800 Subject: [PATCH 16/24] compile test --- test/optparse-test/CompileTest.hs | 38 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/test/optparse-test/CompileTest.hs b/test/optparse-test/CompileTest.hs index 5880831..13c70a9 100644 --- a/test/optparse-test/CompileTest.hs +++ b/test/optparse-test/CompileTest.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} module CompileTest where @@ -8,6 +9,9 @@ import Utils import GHCup.GHC import Data.Versions import GHCup.Types +import URI.ByteString.QQ +import qualified GHCup.OptParse.Compile as GHC (GHCCompileOptions(..)) +import qualified GHCup.OptParse.Compile as HLS (HLSCompileOptions(..)) compileTests :: TestTree @@ -35,10 +39,7 @@ mkDefaultGHCCompileOptions target boot = 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 -v 9.4.5 -b 9.2.8", baseOptions) , ("compile ghc -g a32db0b -b 9.2.8", mkDefaultGHCCompileOptions (GitDist $ GitBranch "a32db0b" Nothing) (Left $ mkVersion' "9.2.8") @@ -53,7 +54,36 @@ compileGhcCheckList = mapSecond CompileGHC (GitDist $ GitBranch "a32db0b" (Just "https://gitlab.haskell.org/ghc/ghc.git")) (Right "/usr/bin/ghc-9.2.2") ) + , ("compile ghc --remote-source-dist https://gitlab.haskell.org/ghc/ghc.git -b 9.2.8", mkDefaultGHCCompileOptions + (RemoteDist [uri|https://gitlab.haskell.org/ghc/ghc.git|]) + (Left $ mkVersion' "9.2.8") + ) + , (baseCmd <> "-j20", baseOptions{GHC.jobs = Just 20}) + , (baseCmd <> "--jobs 10", baseOptions{GHC.jobs = Just 10}) + , (baseCmd <> "-c build.mk", baseOptions{GHC.buildConfig = Just "build.mk"}) + , (baseCmd <> "--config build.mk", baseOptions{GHC.buildConfig = Just "build.mk"}) + , (baseCmd <> "--patch file:///example.patch", baseOptions{GHC.patches = Just $ Right [[uri|file:///example.patch|]]}) + , (baseCmd <> "-p patch_dir", baseOptions{GHC.patches = Just (Left "patch_dir")}) + , (baseCmd <> "--patchdir patch_dir", baseOptions{GHC.patches = Just (Left "patch_dir")}) + , (baseCmd <> "-x armv7-unknown-linux-gnueabihf", baseOptions{GHC.crossTarget = Just "armv7-unknown-linux-gnueabihf"}) + , (baseCmd <> "--cross-target armv7-unknown-linux-gnueabihf", baseOptions{GHC.crossTarget = Just "armv7-unknown-linux-gnueabihf"}) + , (baseCmd <> "-- --enable-unregisterised", baseOptions{GHC.addConfArgs = ["--enable-unregisterised"]}) + , (baseCmd <> "--set", baseOptions{GHC.setCompile = True}) + , (baseCmd <> "-o 9.4.5-p1", baseOptions{GHC.ovewrwiteVer = Just $ mkVersion' "9.4.5-p1"}) + , (baseCmd <> "--overwrite-version 9.4.5-p1", baseOptions{GHC.ovewrwiteVer = Just $ mkVersion' "9.4.5-p1"}) + , (baseCmd <> "-f make", baseOptions{GHC.buildFlavour = Just "make"}) + , (baseCmd <> "--flavour make", baseOptions{GHC.buildFlavour = Just "make"}) + , (baseCmd <> "--hadrian", baseOptions{GHC.hadrian = True}) + , (baseCmd <> "-i /tmp/out_dir", baseOptions{GHC.isolateDir = Just "/tmp/out_dir"}) + , (baseCmd <> "--isolate /tmp/out_dir", baseOptions{GHC.isolateDir = Just "/tmp/out_dir"}) ] + where + baseCmd = "compile ghc -v 9.4.5 -b 9.2.8 " + baseOptions :: GHCCompileOptions + baseOptions = + mkDefaultGHCCompileOptions + (SourceDist $ mkVersion' "9.4.5") + (Left $ mkVersion' "9.2.8") compileHlsCheckList :: [(String, CompileCommand)] compileHlsCheckList = [] From f23631054ac793374aeca6f65628aaa846322b62 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 28 Jul 2023 22:06:16 +0800 Subject: [PATCH 17/24] compile test --- test/optparse-test/CompileTest.hs | 98 ++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 7 deletions(-) diff --git a/test/optparse-test/CompileTest.hs b/test/optparse-test/CompileTest.hs index 13c70a9..907e25c 100644 --- a/test/optparse-test/CompileTest.hs +++ b/test/optparse-test/CompileTest.hs @@ -6,12 +6,13 @@ module CompileTest where import Test.Tasty import GHCup.OptParse import Utils -import GHCup.GHC import Data.Versions import GHCup.Types import URI.ByteString.QQ import qualified GHCup.OptParse.Compile as GHC (GHCCompileOptions(..)) import qualified GHCup.OptParse.Compile as HLS (HLSCompileOptions(..)) +import GHCup.GHC as GHC +import GHCup.HLS as HLS compileTests :: TestTree @@ -37,25 +38,40 @@ mkDefaultGHCCompileOptions target boot = False Nothing +mkDefaultHLSCompileOptions :: HLSVer -> [ToolVersion] -> HLSCompileOptions +mkDefaultHLSCompileOptions target ghcs = + HLSCompileOptions + target + Nothing + True + False + (Left False) + Nothing + Nothing + Nothing + (Just $ Right []) + ghcs + [] + compileGhcCheckList :: [(String, CompileCommand)] compileGhcCheckList = mapSecond CompileGHC [ ("compile ghc -v 9.4.5 -b 9.2.8", baseOptions) , ("compile ghc -g a32db0b -b 9.2.8", mkDefaultGHCCompileOptions - (GitDist $ GitBranch "a32db0b" Nothing) + (GHC.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")) + (GHC.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")) + (GHC.GitDist $ GitBranch "a32db0b" (Just "https://gitlab.haskell.org/ghc/ghc.git")) (Right "/usr/bin/ghc-9.2.2") ) , ("compile ghc --remote-source-dist https://gitlab.haskell.org/ghc/ghc.git -b 9.2.8", mkDefaultGHCCompileOptions - (RemoteDist [uri|https://gitlab.haskell.org/ghc/ghc.git|]) + (GHC.RemoteDist [uri|https://gitlab.haskell.org/ghc/ghc.git|]) (Left $ mkVersion' "9.2.8") ) , (baseCmd <> "-j20", baseOptions{GHC.jobs = Just 20}) @@ -78,15 +94,83 @@ compileGhcCheckList = mapSecond CompileGHC , (baseCmd <> "--isolate /tmp/out_dir", baseOptions{GHC.isolateDir = Just "/tmp/out_dir"}) ] where + baseCmd :: String baseCmd = "compile ghc -v 9.4.5 -b 9.2.8 " + baseOptions :: GHCCompileOptions baseOptions = mkDefaultGHCCompileOptions - (SourceDist $ mkVersion' "9.4.5") + (GHC.SourceDist $ mkVersion' "9.4.5") (Left $ mkVersion' "9.2.8") compileHlsCheckList :: [(String, CompileCommand)] -compileHlsCheckList = [] +compileHlsCheckList = mapSecond CompileHLS + [ ("compile hls -v 2.0.0.0 --ghc 9.2.8", baseOptions) + , ("compile hls --version 2.0.0.0 --ghc 9.2.8", baseOptions) + , ("compile hls -g a32db0b --ghc 9.2.8", + mkDefaultHLSCompileOptions + (HLS.GitDist $ GitBranch {ref = "a32db0b", repo = Nothing}) + [ghc928] + ) + , ("compile hls --git-ref a32db0b --ghc 9.2.8", + mkDefaultHLSCompileOptions + (HLS.GitDist $ GitBranch {ref = "a32db0b", repo = Nothing}) + [ghc928] + ) + , ("compile hls -g a32db0b -r https://github.com/haskell/haskell-language-server.git --ghc 9.2.8", + mkDefaultHLSCompileOptions + (HLS.GitDist $ GitBranch {ref = "a32db0b", repo = Just "https://github.com/haskell/haskell-language-server.git"}) + [ghc928] + ) + , ("compile hls -g a32db0b --repository https://github.com/haskell/haskell-language-server.git --ghc 9.2.8", + mkDefaultHLSCompileOptions + (HLS.GitDist $ GitBranch {ref = "a32db0b", repo = Just "https://github.com/haskell/haskell-language-server.git"}) + [ghc928] + ) + , ("compile hls --source-dist 2.0.0.0 --ghc 9.2.8", + mkDefaultHLSCompileOptions + (HLS.SourceDist $ mkVersion' "2.0.0.0") + [ghc928] + ) + , ("compile hls --remote-source-dist https://github.com/haskell/haskell-language-server/archive/refs/tags/2.0.0.1.tar.gz --ghc 9.2.8", + mkDefaultHLSCompileOptions + (HLS.RemoteDist [uri|https://github.com/haskell/haskell-language-server/archive/refs/tags/2.0.0.1.tar.gz|]) + [ghc928] + ) + , ("compile hls -v 2.0.0.0 --ghc latest", + mkDefaultHLSCompileOptions + (HLS.HackageDist $ mkVersion' "2.0.0.0") + [ToolTag Latest] + ) + , (baseCmd <> "-j20", baseOptions{HLS.jobs = Just 20}) + , (baseCmd <> "--jobs 10", baseOptions{HLS.jobs = Just 10}) + , (baseCmd <> "--no-set", baseOptions{HLS.setCompile = False}) + , (baseCmd <> "--cabal-update", baseOptions{HLS.updateCabal = True}) + , (baseCmd <> "-o 2.0.0.0-p1", baseOptions{HLS.ovewrwiteVer = Right $ mkVersion' "2.0.0.0-p1"}) + , (baseCmd <> "--overwrite-version 2.0.0.0-p1", baseOptions{HLS.ovewrwiteVer = Right $ mkVersion' "2.0.0.0-p1"}) + , (baseCmd <> "--git-describe-version", baseOptions{HLS.ovewrwiteVer = Left True}) + , (baseCmd <> "-i /tmp/out_dir", baseOptions{HLS.isolateDir = Just "/tmp/out_dir"}) + , (baseCmd <> "--isolate /tmp/out_dir", baseOptions{HLS.isolateDir = Just "/tmp/out_dir"}) + , (baseCmd <> "--cabal-project file:///tmp/cabal.project", baseOptions{HLS.cabalProject = Just $ Right [uri|file:///tmp/cabal.project|]}) + , (baseCmd <> "--cabal-project cabal.ghc8107.project", baseOptions{HLS.cabalProject = Just $ Left "cabal.ghc8107.project"}) + , (baseCmd <> "--cabal-project-local file:///tmp/cabal.project.local", baseOptions{HLS.cabalProjectLocal = Just [uri|file:///tmp/cabal.project.local|]}) + , (baseCmd <> "--patch file:///example.patch", baseOptions{HLS.patches = Just $ Right [[uri|file:///example.patch|]]}) + , (baseCmd <> "-p patch_dir", baseOptions{HLS.patches = Just (Left "patch_dir")}) + , (baseCmd <> "--patchdir patch_dir", baseOptions{HLS.patches = Just (Left "patch_dir")}) + , (baseCmd <> "-- --enable-tests", baseOptions{HLS.cabalArgs = ["--enable-tests"]}) + ] + where + baseCmd :: String + baseCmd = "compile hls -v 2.0.0.0 --ghc 9.2.8 " + + baseOptions :: HLSCompileOptions + baseOptions = + mkDefaultHLSCompileOptions + (HLS.HackageDist $ mkVersion' "2.0.0.0") + [ghc928] + + ghc928 :: ToolVersion + ghc928 = GHCVersion $ GHCTargetVersion Nothing (mkVersion' "9.2.8") compileParseWith :: [String] -> IO CompileCommand compileParseWith args = do From 2726e832355ea0074b8df84dbad4c56915bb0ad1 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 28 Jul 2023 23:00:15 +0800 Subject: [PATCH 18/24] whereis test --- app/ghcup/GHCup/OptParse/Whereis.hs | 3 ++- ghcup.cabal | 1 + test/optparse-test/Main.hs | 2 ++ test/optparse-test/WhereisTest.hs | 40 +++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 test/optparse-test/WhereisTest.hs diff --git a/app/ghcup/GHCup/OptParse/Whereis.hs b/app/ghcup/GHCup/OptParse/Whereis.hs index 497520a..d6b269f 100644 --- a/app/ghcup/GHCup/OptParse/Whereis.hs +++ b/app/ghcup/GHCup/OptParse/Whereis.hs @@ -54,6 +54,7 @@ data WhereisCommand = WhereisTool Tool (Maybe ToolVersion) | WhereisCacheDir | WhereisLogsDir | WhereisConfDir + deriving (Eq, Show) @@ -66,7 +67,7 @@ data WhereisCommand = WhereisTool Tool (Maybe ToolVersion) data WhereisOptions = WhereisOptions { directory :: Bool -} +} deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index 3dd02c7..26bee16 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -427,6 +427,7 @@ test-suite ghcup-optparse-test ListTest UpgradeTest CompileTest + WhereisTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index be1776a..1091c84 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -11,6 +11,7 @@ import qualified RmTest import qualified ListTest import qualified UpgradeTest import qualified CompileTest +import qualified WhereisTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -24,4 +25,5 @@ main = defaultMain $ testGroup "ghcup" , ListTest.listTests , UpgradeTest.upgradeTests , CompileTest.compileTests + , WhereisTest.whereisTests ] diff --git a/test/optparse-test/WhereisTest.hs b/test/optparse-test/WhereisTest.hs new file mode 100644 index 0000000..92fe79f --- /dev/null +++ b/test/optparse-test/WhereisTest.hs @@ -0,0 +1,40 @@ +{-# LANGUAGE OverloadedStrings #-} + +module WhereisTest where + +import Test.Tasty +import GHCup.OptParse +import Utils +import GHCup.Types + +whereisTests :: TestTree +whereisTests = buildTestTree whereisParseWith ("whereis", whereisCheckList) + +whereisCheckList :: [(String, (WhereisOptions, WhereisCommand))] +whereisCheckList = concatMap mk + [ ("whereis ghc", WhereisTool GHC Nothing) + , ("whereis ghc 9.2.8", WhereisTool GHC (Just $ GHCVersion $ mkTVer $ mkVersion' "9.2.8")) + , ("whereis ghc ghc-9.2.8", WhereisTool GHC (Just $ GHCVersion $ GHCTargetVersion (Just "ghc") (mkVersion' "9.2.8"))) + , ("whereis ghc latest", WhereisTool GHC (Just $ ToolTag Latest)) + , ("whereis cabal", WhereisTool Cabal Nothing) + , ("whereis hls", WhereisTool HLS Nothing) + , ("whereis stack", WhereisTool Stack Nothing) + , ("whereis ghcup", WhereisTool GHCup Nothing) + , ("whereis basedir", WhereisBaseDir) + , ("whereis bindir", WhereisBinDir) + , ("whereis cachedir", WhereisCacheDir) + , ("whereis logsdir", WhereisLogsDir) + , ("whereis confdir", WhereisConfDir) + ] + where + mk :: (String, WhereisCommand) -> [(String, (WhereisOptions, WhereisCommand))] + mk (cmd, res) = + [ (cmd, (WhereisOptions False, res)) + , (cmd <> " -d", (WhereisOptions True, res)) + , (cmd <> " --directory", (WhereisOptions True, res)) + ] + +whereisParseWith :: [String] -> IO (WhereisOptions, WhereisCommand) +whereisParseWith args = do + Whereis a b <- parseWith args + pure (a, b) From f1f4d5e8368d4c4d88445d11827a3e16c76ec2a0 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 28 Jul 2023 23:26:19 +0800 Subject: [PATCH 19/24] gc test --- app/ghcup/GHCup/OptParse/GC.hs | 2 +- app/ghcup/GHCup/OptParse/Run.hs | 2 +- ghcup.cabal | 2 ++ test/optparse-test/GCTest.hs | 42 +++++++++++++++++++++++++++++++++ test/optparse-test/Main.hs | 2 ++ test/optparse-test/RunTest.hs | 31 ++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 test/optparse-test/GCTest.hs create mode 100644 test/optparse-test/RunTest.hs diff --git a/app/ghcup/GHCup/OptParse/GC.hs b/app/ghcup/GHCup/OptParse/GC.hs index 78ea706..2072287 100644 --- a/app/ghcup/GHCup/OptParse/GC.hs +++ b/app/ghcup/GHCup/OptParse/GC.hs @@ -47,7 +47,7 @@ data GCOptions = GCOptions , gcHLSNoGHC :: Bool , gcCache :: Bool , gcTmp :: Bool - } + } deriving (Eq, Show) diff --git a/app/ghcup/GHCup/OptParse/Run.hs b/app/ghcup/GHCup/OptParse/Run.hs index 0d9ad03..b46e058 100644 --- a/app/ghcup/GHCup/OptParse/Run.hs +++ b/app/ghcup/GHCup/OptParse/Run.hs @@ -68,7 +68,7 @@ data RunOptions = RunOptions , runBinDir :: Maybe FilePath , runQuick :: Bool , runCOMMAND :: [String] - } + } deriving (Eq, Show) diff --git a/ghcup.cabal b/ghcup.cabal index 26bee16..51fce99 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -428,6 +428,8 @@ test-suite ghcup-optparse-test UpgradeTest CompileTest WhereisTest + GCTest + RunTest default-language: Haskell2010 ghc-options: -Wall build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring diff --git a/test/optparse-test/GCTest.hs b/test/optparse-test/GCTest.hs new file mode 100644 index 0000000..aea524e --- /dev/null +++ b/test/optparse-test/GCTest.hs @@ -0,0 +1,42 @@ +module GCTest where + +import Test.Tasty +import GHCup.OptParse +import Utils + + +gcTests :: TestTree +gcTests = buildTestTree gcParseWith ("gc", gcCheckList) + +defaultOptions :: GCOptions +defaultOptions = + GCOptions + False + False + False + False + False + False + +gcCheckList :: [(String, GCOptions)] +gcCheckList = + [ ("gc", defaultOptions) + , ("gc -o", defaultOptions{gcOldGHC = True}) + , ("gc --ghc-old", defaultOptions{gcOldGHC = True}) + , ("gc -p", defaultOptions{gcProfilingLibs = True}) + , ("gc --profiling-libs", defaultOptions{gcProfilingLibs = True}) + , ("gc -s", defaultOptions{gcShareDir = True}) + , ("gc --share-dir", defaultOptions{gcShareDir = True}) + , ("gc -h", defaultOptions{gcHLSNoGHC = True}) + , ("gc --hls-no-ghc", defaultOptions{gcHLSNoGHC = True}) + , ("gc -c", defaultOptions{gcCache = True}) + , ("gc --cache", defaultOptions{gcCache = True}) + , ("gc -t", defaultOptions{gcTmp = True}) + , ("gc --tmpdirs", defaultOptions{gcTmp = True}) + , ("gc -o -p -s -h -c -t", GCOptions True True True True True True) + ] + +gcParseWith :: [String] -> IO GCOptions +gcParseWith args = do + GC a <- parseWith args + pure a diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index 1091c84..0430e36 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -12,6 +12,7 @@ import qualified ListTest import qualified UpgradeTest import qualified CompileTest import qualified WhereisTest +import qualified GCTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -26,4 +27,5 @@ main = defaultMain $ testGroup "ghcup" , UpgradeTest.upgradeTests , CompileTest.compileTests , WhereisTest.whereisTests + , GCTest.gcTests ] diff --git a/test/optparse-test/RunTest.hs b/test/optparse-test/RunTest.hs new file mode 100644 index 0000000..8655e3d --- /dev/null +++ b/test/optparse-test/RunTest.hs @@ -0,0 +1,31 @@ +module RunTest where + +import Test.Tasty +import GHCup.OptParse +import Utils + + +runTests :: TestTree +runTests = buildTestTree runParseWith ("run", runCheckList) + +defaultOptions :: RunOptions +defaultOptions = + RunOptions + False + False + False + Nothing + Nothing + Nothing + Nothing + Nothing + False + [] + +runCheckList :: [(String, RunOptions)] +runCheckList = [] + +runParseWith :: [String] -> IO RunOptions +runParseWith args = do + Run a <- parseWith args + pure a From 78df858ba1999c7a06dddac5fc3c15f8f56aff9f Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 28 Jul 2023 23:39:21 +0800 Subject: [PATCH 20/24] run test --- test/optparse-test/Main.hs | 2 ++ test/optparse-test/RunTest.hs | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/optparse-test/Main.hs b/test/optparse-test/Main.hs index 0430e36..213774d 100644 --- a/test/optparse-test/Main.hs +++ b/test/optparse-test/Main.hs @@ -13,6 +13,7 @@ import qualified UpgradeTest import qualified CompileTest import qualified WhereisTest import qualified GCTest +import qualified RunTest main :: IO () main = defaultMain $ testGroup "ghcup" @@ -28,4 +29,5 @@ main = defaultMain $ testGroup "ghcup" , CompileTest.compileTests , WhereisTest.whereisTests , GCTest.gcTests + , RunTest.runTests ] diff --git a/test/optparse-test/RunTest.hs b/test/optparse-test/RunTest.hs index 8655e3d..f32f25e 100644 --- a/test/optparse-test/RunTest.hs +++ b/test/optparse-test/RunTest.hs @@ -1,8 +1,11 @@ +{-# LANGUAGE OverloadedStrings #-} + module RunTest where import Test.Tasty import GHCup.OptParse import Utils +import GHCup.Types runTests :: TestTree @@ -23,7 +26,33 @@ defaultOptions = [] runCheckList :: [(String, RunOptions)] -runCheckList = [] +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}) + , ("run --ghc 9.2.8", defaultOptions{runGHCVer = Just $ GHCVersion $ mkTVer $ mkVersion' "9.2.8"}) + , ("run --ghc latest", defaultOptions{runGHCVer = Just $ ToolTag Latest}) + , ("run --cabal 3.10", defaultOptions{runCabalVer = Just $ ToolVersion $ mkVersion' "3.10"}) + , ("run --hls 2.0", defaultOptions{runHLSVer = Just $ ToolVersion $ mkVersion' "2.0"}) + , ("run --stack 2.9", defaultOptions{runStackVer = Just $ ToolVersion $ mkVersion' "2.9"}) + , ("run -b /tmp/dir", defaultOptions{runBinDir = Just "/tmp/dir"}) + , ("run --bindir /tmp/dir", defaultOptions{runBinDir = Just "/tmp/dir"}) + , ("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 + , runCabalVer = Just $ ToolVersion $ mkVersion' "3.10" + , runHLSVer = Just $ ToolVersion $ mkVersion' "2.0" + , runStackVer = Just $ ToolVersion $ mkVersion' "2.9" + , runInstTool' = True + } + ) + ] runParseWith :: [String] -> IO RunOptions runParseWith args = do From c60aa767ca070f718471fecef4a9e2cbb4388d80 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 28 Jul 2023 23:48:03 +0800 Subject: [PATCH 21/24] format --- ghcup.cabal | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/ghcup.cabal b/ghcup.cabal index 51fce99..66ec634 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -416,20 +416,29 @@ test-suite ghcup-optparse-test hs-source-dirs: test/optparse-test main-is: Main.hs other-modules: - SetTest - Utils - OtherCommandTest ChangeLogTest - ConfigTest - InstallTest - UnsetTest - RmTest - ListTest - UpgradeTest CompileTest - WhereisTest + ConfigTest GCTest + InstallTest + ListTest + OtherCommandTest + RmTest RunTest + SetTest + UnsetTest + UpgradeTest + Utils + WhereisTest default-language: Haskell2010 ghc-options: -Wall - build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring + build-depends: + , base + , ghcup + , ghcup-optparse + , optparse-applicative + , tasty + , tasty-hunit + , text + , uri-bytestring + , versions From fde0e712acf61a0e45d56d465606a8bc73c50c54 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 28 Jul 2023 23:57:59 +0800 Subject: [PATCH 22/24] add ci --- .github/workflows/optparse-test.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/optparse-test.yaml diff --git a/.github/workflows/optparse-test.yaml b/.github/workflows/optparse-test.yaml new file mode 100644 index 0000000..fe89364 --- /dev/null +++ b/.github/workflows/optparse-test.yaml @@ -0,0 +1,23 @@ +name: Optparse Test + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + +jobs: + ghcup-optparse-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: haskell/actions/setup@v2 + id: setup-haskell + with: + ghc-version: 9.2.8 + cabal-version: 3.10.1.0 + - run: + cabal test ghcup-optparse-test From 69d311f0b42b12a786d113da3ce0ded0bdb461d6 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 29 Jul 2023 00:43:33 +0800 Subject: [PATCH 23/24] ci --- .github/workflows/optparse-test.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/optparse-test.yaml b/.github/workflows/optparse-test.yaml index fe89364..7320b42 100644 --- a/.github/workflows/optparse-test.yaml +++ b/.github/workflows/optparse-test.yaml @@ -1,12 +1,8 @@ name: Optparse Test on: - push: - branches: - - '**' - pull_request: - branches: - - '**' + - push + - pull_request jobs: ghcup-optparse-test: From 5f361e1e0b81bca985204c50fefa2a3973ac3c47 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Sat, 5 Aug 2023 13:47:51 +0800 Subject: [PATCH 24/24] Fix compile test --- test/optparse-test/CompileTest.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/optparse-test/CompileTest.hs b/test/optparse-test/CompileTest.hs index 907e25c..9979a9e 100644 --- a/test/optparse-test/CompileTest.hs +++ b/test/optparse-test/CompileTest.hs @@ -35,7 +35,7 @@ mkDefaultGHCCompileOptions target boot = False Nothing Nothing - False + Nothing Nothing mkDefaultHLSCompileOptions :: HLSVer -> [ToolVersion] -> HLSCompileOptions @@ -89,7 +89,8 @@ compileGhcCheckList = mapSecond CompileGHC , (baseCmd <> "--overwrite-version 9.4.5-p1", baseOptions{GHC.ovewrwiteVer = Just $ mkVersion' "9.4.5-p1"}) , (baseCmd <> "-f make", baseOptions{GHC.buildFlavour = Just "make"}) , (baseCmd <> "--flavour make", baseOptions{GHC.buildFlavour = Just "make"}) - , (baseCmd <> "--hadrian", baseOptions{GHC.hadrian = True}) + , (baseCmd <> "--hadrian", baseOptions{GHC.buildSystem = Just Hadrian}) + , (baseCmd <> "--make", baseOptions{GHC.buildSystem = Just Make}) , (baseCmd <> "-i /tmp/out_dir", baseOptions{GHC.isolateDir = Just "/tmp/out_dir"}) , (baseCmd <> "--isolate /tmp/out_dir", baseOptions{GHC.isolateDir = Just "/tmp/out_dir"}) ]