Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite for ghcup optparse #862

Merged
merged 25 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions .github/workflows/optparse-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Optparse Test

on:
- push
- pull_request

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
2 changes: 1 addition & 1 deletion app/ghcup/GHCup/OptParse/ChangeLog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ data ChangeLogOptions = ChangeLogOptions
{ clOpen :: Bool
, clTool :: Maybe Tool
, clToolVer :: Maybe ToolVersion
}
} deriving (Eq, Show)



Expand Down
1 change: 1 addition & 0 deletions app/ghcup/GHCup/OptParse/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 3 additions & 2 deletions app/ghcup/GHCup/OptParse/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

data CompileCommand = CompileGHC GHCCompileOptions
| CompileHLS HLSCompileOptions
deriving (Eq, Show)



Expand All @@ -78,7 +79,7 @@
, buildFlavour :: Maybe String
, buildSystem :: Maybe BuildSystem
, isolateDir :: Maybe FilePath
}
} deriving (Eq, Show)


data HLSCompileOptions = HLSCompileOptions
Expand All @@ -93,7 +94,7 @@
, patches :: Maybe (Either FilePath [URI])
, targetGHCs :: [ToolVersion]
, cabalArgs :: [Text]
}
} deriving (Eq, Show)



Expand All @@ -111,7 +112,7 @@
<$> info
(ghcCompileOpts <**> helper)
( progDesc "Compile GHC from source"
<> footerDoc (Just $ text compileFooter)

Check warning on line 115 in app/ghcup/GHCup/OptParse/Compile.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

In the use of ‘text’
)
)
<> command
Expand All @@ -120,7 +121,7 @@
<$> info
(hlsCompileOpts <**> helper)
( progDesc "Compile HLS from source"
<> footerDoc (Just $ text compileHLSFooter)

Check warning on line 124 in app/ghcup/GHCup/OptParse/Compile.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

In the use of ‘text’
)
)
)
Expand Down
1 change: 1 addition & 0 deletions app/ghcup/GHCup/OptParse/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
| SetConfig String (Maybe String)
| InitConfig
| AddReleaseChannel Bool URI
deriving (Eq, Show)



Expand All @@ -72,7 +73,7 @@
where
initP = info (pure InitConfig) (progDesc "Write default config to ~/.ghcup/config.yaml")
showP = info (pure ShowConfig) (progDesc "Show current config (default)")
setP = info argsP (progDesc "Set config KEY to VALUE (or specify as single json value)" <> footerDoc (Just $ text configSetFooter))

Check warning on line 76 in app/ghcup/GHCup/OptParse/Config.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

In the use of ‘text’
argsP = SetConfig <$> argument str (metavar "<JSON_VALUE | YAML_KEY>") <*> optional (argument str (metavar "YAML_VALUE"))
addP = info (AddReleaseChannel <$> switch (long "force" <> help "Delete existing entry (if any) and append instead of failing") <*> argument (eitherReader uriParser) (metavar "URI" <> completer fileUri))
(progDesc "Add a release channel from a URI")
Expand Down
2 changes: 1 addition & 1 deletion app/ghcup/GHCup/OptParse/GC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ data GCOptions = GCOptions
, gcHLSNoGHC :: Bool
, gcCache :: Bool
, gcTmp :: Bool
}
} deriving (Eq, Show)



Expand Down
3 changes: 2 additions & 1 deletion app/ghcup/GHCup/OptParse/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
| InstallCabal InstallOptions
| InstallHLS InstallOptions
| InstallStack InstallOptions
deriving (Eq, Show)



Expand All @@ -70,7 +71,7 @@
, isolateDir :: Maybe FilePath
, forceInstall :: Bool
, addConfArgs :: [T.Text]
}
} deriving (Eq, Show)



Expand Down Expand Up @@ -101,7 +102,7 @@
<$> info
(installOpts (Just GHC) <**> helper)
( progDesc "Install GHC"
<> footerDoc (Just $ text installGHCFooter)

Check warning on line 105 in app/ghcup/GHCup/OptParse/Install.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

In the use of ‘text’
)
)
<> command
Expand All @@ -110,7 +111,7 @@
<$> info
(installOpts (Just Cabal) <**> helper)
( progDesc "Install Cabal"
<> footerDoc (Just $ text installCabalFooter)

Check warning on line 114 in app/ghcup/GHCup/OptParse/Install.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

In the use of ‘text’
)
)
<> command
Expand All @@ -119,7 +120,7 @@
<$> info
(installOpts (Just HLS) <**> helper)
( progDesc "Install haskell-language-server"
<> footerDoc (Just $ text installHLSFooter)

Check warning on line 123 in app/ghcup/GHCup/OptParse/Install.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

In the use of ‘text’
)
)
<> command
Expand All @@ -128,7 +129,7 @@
<$> info
(installOpts (Just Stack) <**> helper)
( progDesc "Install stack"
<> footerDoc (Just $ text installStackFooter)

Check warning on line 132 in app/ghcup/GHCup/OptParse/Install.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

In the use of ‘text’
)
)
)
Expand Down Expand Up @@ -332,7 +333,7 @@
$ when instSet $ when (isNothing isolateDir) $ liftE $ void $ setGHC v SetGHCOnly Nothing
pure vi
Just uri -> do
runInstGHC s'{ settings = settings {noVerify = True}} $ do

Check warning on line 336 in app/ghcup/GHCup/OptParse/Install.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

The record update s'
(v, vi) <- liftE $ fromVersion instVer GHC
liftE $ runBothE' (installGHCBindist
(DownloadInfo uri (Just $ RegexDir "ghc-.*") "" Nothing Nothing)
Expand Down Expand Up @@ -402,7 +403,7 @@
) $ when instSet $ when (isNothing isolateDir) $ liftE $ setCabal v
pure vi
Just uri -> do
runInstTool s'{ settings = settings { noVerify = True}} $ do

Check warning on line 406 in app/ghcup/GHCup/OptParse/Install.hs

View workflow job for this annotation

GitHub Actions / ghcup-optparse-test

The record update s'
(_tvVersion -> v, vi) <- liftE $ fromVersion instVer Cabal
liftE $ runBothE' (installCabalBindist
(DownloadInfo uri Nothing "" Nothing Nothing)
Expand Down
2 changes: 1 addition & 1 deletion app/ghcup/GHCup/OptParse/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ data ListOptions = ListOptions
, lHideOld :: Bool
, lShowNightly :: Bool
, lRawFormat :: Bool
}
} deriving (Eq, Show)



Expand Down
3 changes: 2 additions & 1 deletion app/ghcup/GHCup/OptParse/Rm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ data RmCommand = RmGHC RmOptions
| RmCabal Version
| RmHLS Version
| RmStack Version
deriving (Eq, Show)



Expand All @@ -61,7 +62,7 @@ data RmCommand = RmGHC RmOptions

data RmOptions = RmOptions
{ ghcVer :: GHCTargetVersion
}
} deriving (Eq, Show)



Expand Down
2 changes: 1 addition & 1 deletion app/ghcup/GHCup/OptParse/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ data RunOptions = RunOptions
, runBinDir :: Maybe FilePath
, runQuick :: Bool
, runCOMMAND :: [String]
}
} deriving (Eq, Show)



Expand Down
3 changes: 2 additions & 1 deletion app/ghcup/GHCup/OptParse/Set.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ data SetCommand = SetGHC SetOptions
| SetCabal SetOptions
| SetHLS SetOptions
| SetStack SetOptions
deriving (Eq, Show)



Expand All @@ -64,7 +65,7 @@ data SetCommand = SetGHC SetOptions

data SetOptions = SetOptions
{ sToolVer :: SetToolVersion
}
} deriving (Eq, Show)



Expand Down
5 changes: 3 additions & 2 deletions app/ghcup/GHCup/OptParse/UnSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ data UnsetCommand = UnsetGHC UnsetOptions
| UnsetCabal UnsetOptions
| UnsetHLS UnsetOptions
| UnsetStack UnsetOptions
deriving (Eq, Show)



Expand All @@ -59,7 +60,7 @@ data UnsetCommand = UnsetGHC UnsetOptions

data UnsetOptions = UnsetOptions
{ sToolVer :: Maybe T.Text -- target platform triple
}
} deriving (Eq, Show)



Expand All @@ -68,7 +69,7 @@ data UnsetOptions = UnsetOptions
--[ Parsers ]--
---------------


unsetParser :: Parser UnsetCommand
unsetParser =
subparser
Expand Down
2 changes: 1 addition & 1 deletion app/ghcup/GHCup/OptParse/Upgrade.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import Data.Versions hiding (str)
data UpgradeOpts = UpgradeInplace
| UpgradeAt FilePath
| UpgradeGHCupDir
deriving Show
deriving (Eq, Show)



Expand Down
3 changes: 2 additions & 1 deletion app/ghcup/GHCup/OptParse/Whereis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ data WhereisCommand = WhereisTool Tool (Maybe ToolVersion)
| WhereisCacheDir
| WhereisLogsDir
| WhereisConfDir
deriving (Eq, Show)



Expand All @@ -66,7 +67,7 @@ data WhereisCommand = WhereisTool Tool (Maybe ToolVersion)

data WhereisOptions = WhereisOptions {
directory :: Bool
}
} deriving (Eq, Show)



Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ package aeson
package streamly
flags: +use-unliftio

package *
test-show-details: direct