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

Port 'TestFlags' to 'new-test' #5455

Merged
merged 7 commits into from
Nov 12, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 59 additions & 54 deletions Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module Distribution.Simple.Setup (
defaultBenchmarkFlags, benchmarkCommand,
CopyDest(..),
configureArgs, configureOptions, configureCCompiler, configureLinker,
buildOptions, haddockOptions, installDirsOptions,
buildOptions, haddockOptions, installDirsOptions, testOptions',
programDbOptions, programDbPaths',
programConfigurationOptions, programConfigurationPaths',
programFlagsDescription,
Expand Down Expand Up @@ -1830,7 +1830,9 @@ replOptions _ = [ option [] ["repl-options"] "use this option for the repl" id
-- ------------------------------------------------------------

data TestShowDetails = Never | Failures | Always | Streaming | Direct
deriving (Eq, Ord, Enum, Bounded, Show)
deriving (Eq, Ord, Enum, Bounded, Generic, Show)

instance Binary TestShowDetails

knownTestShowDetails :: [TestShowDetails]
knownTestShowDetails = [minBound..maxBound]
Expand Down Expand Up @@ -1898,60 +1900,63 @@ testCommand = CommandUI
, "TESTCOMPONENTS [FLAGS]"
]
, commandDefaultFlags = defaultTestFlags
, commandOptions = \showOrParseArgs ->
[ optionVerbosity testVerbosity (\v flags -> flags { testVerbosity = v })
, optionDistPref
testDistPref (\d flags -> flags { testDistPref = d })
showOrParseArgs
, option [] ["log"]
("Log all test suite results to file (name template can use "
++ "$pkgid, $compiler, $os, $arch, $test-suite, $result)")
testHumanLog (\v flags -> flags { testHumanLog = v })
(reqArg' "TEMPLATE"
(toFlag . toPathTemplate)
(flagToList . fmap fromPathTemplate))
, option [] ["machine-log"]
("Produce a machine-readable log file (name template can use "
++ "$pkgid, $compiler, $os, $arch, $result)")
testMachineLog (\v flags -> flags { testMachineLog = v })
(reqArg' "TEMPLATE"
(toFlag . toPathTemplate)
(flagToList . fmap fromPathTemplate))
, option [] ["show-details"]
("'always': always show results of individual test cases. "
++ "'never': never show results of individual test cases. "
++ "'failures': show results of failing test cases. "
++ "'streaming': show results of test cases in real time."
++ "'direct': send results of test cases in real time; no log file.")
testShowDetails (\v flags -> flags { testShowDetails = v })
(reqArg "FILTER"
(parsecToReadE (\_ -> "--show-details flag expects one of "
++ intercalate ", "
(map prettyShow knownTestShowDetails))
(fmap toFlag parsec))
(flagToList . fmap prettyShow))
, option [] ["keep-tix-files"]
"keep .tix files for HPC between test runs"
testKeepTix (\v flags -> flags { testKeepTix = v})
trueArg
, option [] ["test-options"]
("give extra options to test executables "
++ "(name templates can use $pkgid, $compiler, "
++ "$os, $arch, $test-suite)")
testOptions (\v flags -> flags { testOptions = v })
(reqArg' "TEMPLATES" (map toPathTemplate . splitArgs)
(const []))
, option [] ["test-option"]
("give extra option to test executables "
++ "(no need to quote options containing spaces, "
++ "name template can use $pkgid, $compiler, "
++ "$os, $arch, $test-suite)")
testOptions (\v flags -> flags { testOptions = v })
(reqArg' "TEMPLATE" (\x -> [toPathTemplate x])
(map fromPathTemplate))
]
, commandOptions = testOptions'
}

testOptions' :: ShowOrParseArgs -> [OptionField TestFlags]
testOptions' showOrParseArgs =
[ optionVerbosity testVerbosity (\v flags -> flags { testVerbosity = v })
, optionDistPref
testDistPref (\d flags -> flags { testDistPref = d })
showOrParseArgs
, option [] ["log"]
("Log all test suite results to file (name template can use "
++ "$pkgid, $compiler, $os, $arch, $test-suite, $result)")
testHumanLog (\v flags -> flags { testHumanLog = v })
(reqArg' "TEMPLATE"
(toFlag . toPathTemplate)
(flagToList . fmap fromPathTemplate))
, option [] ["machine-log"]
("Produce a machine-readable log file (name template can use "
++ "$pkgid, $compiler, $os, $arch, $result)")
testMachineLog (\v flags -> flags { testMachineLog = v })
(reqArg' "TEMPLATE"
(toFlag . toPathTemplate)
(flagToList . fmap fromPathTemplate))
, option [] ["show-details"]
("'always': always show results of individual test cases. "
++ "'never': never show results of individual test cases. "
++ "'failures': show results of failing test cases. "
++ "'streaming': show results of test cases in real time."
++ "'direct': send results of test cases in real time; no log file.")
testShowDetails (\v flags -> flags { testShowDetails = v })
(reqArg "FILTER"
(parsecToReadE (\_ -> "--show-details flag expects one of "
++ intercalate ", "
(map prettyShow knownTestShowDetails))
(fmap toFlag parsec))
(flagToList . fmap prettyShow))
, option [] ["keep-tix-files"]
"keep .tix files for HPC between test runs"
testKeepTix (\v flags -> flags { testKeepTix = v})
trueArg
, option [] ["test-options"]
("give extra options to test executables "
++ "(name templates can use $pkgid, $compiler, "
++ "$os, $arch, $test-suite)")
testOptions (\v flags -> flags { testOptions = v })
(reqArg' "TEMPLATES" (map toPathTemplate . splitArgs)
(const []))
, option [] ["test-option"]
("give extra option to test executables "
++ "(no need to quote options containing spaces, "
++ "name template can use $pkgid, $compiler, "
++ "$os, $arch, $test-suite)")
testOptions (\v flags -> flags { testOptions = v })
(reqArg' "TEMPLATE" (\x -> [toPathTemplate x])
(map fromPathTemplate))
]

emptyTestFlags :: TestFlags
emptyTestFlags = mempty

Expand Down
10 changes: 5 additions & 5 deletions cabal-install/Distribution/Client/CmdBench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags )
import qualified Distribution.Client.Setup as Client
import Distribution.Simple.Setup
( HaddockFlags, fromFlagOrDefault )
( HaddockFlags, TestFlags, fromFlagOrDefault )
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
import Distribution.Text
Expand All @@ -33,7 +33,7 @@ import Distribution.Simple.Utils
import Control.Monad (when)


benchCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
benchCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
benchCommand = Client.installCommand {
commandName = "new-bench",
commandSynopsis = "Run benchmarks",
Expand Down Expand Up @@ -73,9 +73,9 @@ benchCommand = Client.installCommand {
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
benchAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
benchAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
-> [String] -> GlobalFlags -> IO ()
benchAction (configFlags, configExFlags, installFlags, haddockFlags)
benchAction (configFlags, configExFlags, installFlags, haddockFlags, testFlags)
targetStrings globalFlags = do

baseCtx <- establishProjectBaseContext verbosity cliConfig
Expand Down Expand Up @@ -117,7 +117,7 @@ benchAction (configFlags, configExFlags, installFlags, haddockFlags)
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags haddockFlags
installFlags haddockFlags testFlags

-- | This defines what a 'TargetSelector' means for the @bench@ command.
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
Expand Down
11 changes: 6 additions & 5 deletions cabal-install/Distribution/Client/CmdBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import Distribution.Client.Setup
, liftOptions, yesNoOpt )
import qualified Distribution.Client.Setup as Client
import Distribution.Simple.Setup
( HaddockFlags, Flag(..), toFlag, fromFlag, fromFlagOrDefault )
( HaddockFlags, TestFlags
, Flag(..), toFlag, fromFlag, fromFlagOrDefault )
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives, option )
import Distribution.Verbosity
Expand All @@ -31,7 +32,7 @@ import Distribution.Simple.Utils
import qualified Data.Map as Map


buildCommand :: CommandUI (BuildFlags, (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags))
buildCommand :: CommandUI (BuildFlags, (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags))
buildCommand = CommandUI {
commandName = "new-build",
commandSynopsis = "Compile targets within the project.",
Expand Down Expand Up @@ -95,10 +96,10 @@ defaultBuildFlags = BuildFlags
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
buildAction :: (BuildFlags, (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags))
buildAction :: (BuildFlags, (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags))
-> [String] -> GlobalFlags -> IO ()
buildAction (buildFlags,
(configFlags, configExFlags, installFlags, haddockFlags))
(configFlags, configExFlags, installFlags, haddockFlags, testFlags))
targetStrings globalFlags = do
-- TODO: This flags defaults business is ugly
let onlyConfigure = fromFlag (buildOnlyConfigure defaultBuildFlags
Expand Down Expand Up @@ -147,7 +148,7 @@ buildAction (buildFlags,
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags haddockFlags
installFlags haddockFlags testFlags

-- | This defines what a 'TargetSelector' means for the @bench@ command.
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
Expand Down
10 changes: 5 additions & 5 deletions cabal-install/Distribution/Client/CmdConfigure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Distribution.Client.ProjectConfig
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags )
import Distribution.Simple.Setup
( HaddockFlags, fromFlagOrDefault )
( HaddockFlags, TestFlags, fromFlagOrDefault )
import Distribution.Verbosity
( normal )

Expand All @@ -27,7 +27,7 @@ import Distribution.Simple.Utils
import qualified Distribution.Client.Setup as Client

configureCommand :: CommandUI (ConfigFlags, ConfigExFlags
,InstallFlags, HaddockFlags)
,InstallFlags, HaddockFlags, TestFlags)
configureCommand = Client.installCommand {
commandName = "new-configure",
commandSynopsis = "Add extra project configuration",
Expand Down Expand Up @@ -78,9 +78,9 @@ configureCommand = Client.installCommand {
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
configureAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
configureAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
-> [String] -> GlobalFlags -> IO ()
configureAction (configFlags, configExFlags, installFlags, haddockFlags)
configureAction (configFlags, configExFlags, installFlags, haddockFlags, testFlags)
_extraArgs globalFlags = do
--TODO: deal with _extraArgs, since flags with wrong syntax end up there

Expand Down Expand Up @@ -121,5 +121,5 @@ configureAction (configFlags, configExFlags, installFlags, haddockFlags)
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags haddockFlags
installFlags haddockFlags testFlags

9 changes: 5 additions & 4 deletions cabal-install/Distribution/Client/CmdExec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import Distribution.Simple.GHC
, GhcImplInfo(supportsPkgEnvFiles) )
import Distribution.Simple.Setup
( HaddockFlags
, TestFlags
, fromFlagOrDefault
)
import Distribution.Simple.Utils
Expand All @@ -94,7 +95,7 @@ import Data.Set (Set)
import qualified Data.Set as S
import qualified Data.Map as M

execCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
execCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
execCommand = CommandUI
{ commandName = "new-exec"
, commandSynopsis = "Give a command access to the store."
Expand All @@ -119,9 +120,9 @@ execCommand = CommandUI
, commandDefaultFlags = commandDefaultFlags Client.installCommand
}

execAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
execAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
-> [String] -> GlobalFlags -> IO ()
execAction (configFlags, configExFlags, installFlags, haddockFlags)
execAction (configFlags, configExFlags, installFlags, haddockFlags, testFlags)
extraArgs globalFlags = do

baseCtx <- establishProjectBaseContext verbosity cliConfig
Expand Down Expand Up @@ -193,7 +194,7 @@ execAction (configFlags, configExFlags, installFlags, haddockFlags)
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags haddockFlags
installFlags haddockFlags testFlags
withOverrides env args program = program
{ programOverrideEnv = programOverrideEnv program ++ env
, programDefaultArgs = programDefaultArgs program ++ args}
Expand Down
10 changes: 5 additions & 5 deletions cabal-install/Distribution/Client/CmdFreeze.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Distribution.PackageDescription
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags )
import Distribution.Simple.Setup
( HaddockFlags, fromFlagOrDefault )
( HaddockFlags, TestFlags, fromFlagOrDefault )
import Distribution.Simple.Utils
( die', notice, wrapText )
import Distribution.Verbosity
Expand All @@ -49,7 +49,7 @@ import Distribution.Simple.Command
import qualified Distribution.Client.Setup as Client


freezeCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
freezeCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
freezeCommand = Client.installCommand {
commandName = "new-freeze",
commandSynopsis = "Freeze dependencies.",
Expand Down Expand Up @@ -99,9 +99,9 @@ freezeCommand = Client.installCommand {
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
freezeAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
freezeAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
-> [String] -> GlobalFlags -> IO ()
freezeAction (configFlags, configExFlags, installFlags, haddockFlags)
freezeAction (configFlags, configExFlags, installFlags, haddockFlags, testFlags)
extraArgs globalFlags = do

unless (null extraArgs) $
Expand Down Expand Up @@ -130,7 +130,7 @@ freezeAction (configFlags, configExFlags, installFlags, haddockFlags)
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags haddockFlags
installFlags haddockFlags testFlags



Expand Down
10 changes: 5 additions & 5 deletions cabal-install/Distribution/Client/CmdHaddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags )
import qualified Distribution.Client.Setup as Client
import Distribution.Simple.Setup
( HaddockFlags(..), fromFlagOrDefault )
( HaddockFlags(..), TestFlags, fromFlagOrDefault )
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
import Distribution.Verbosity
Expand All @@ -32,7 +32,7 @@ import Control.Monad (when)


haddockCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags
,HaddockFlags)
,HaddockFlags, TestFlags)
haddockCommand = Client.installCommand {
commandName = "new-haddock",
commandSynopsis = "Build Haddock documentation",
Expand Down Expand Up @@ -69,9 +69,9 @@ haddockCommand = Client.installCommand {
-- For more details on how this works, see the module
-- "Distribution.Client.ProjectOrchestration"
--
haddockAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
haddockAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags)
-> [String] -> GlobalFlags -> IO ()
haddockAction (configFlags, configExFlags, installFlags, haddockFlags)
haddockAction (configFlags, configExFlags, installFlags, haddockFlags, testFlags)
targetStrings globalFlags = do

baseCtx <- establishProjectBaseContext verbosity cliConfig
Expand Down Expand Up @@ -111,7 +111,7 @@ haddockAction (configFlags, configExFlags, installFlags, haddockFlags)
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig
globalFlags configFlags configExFlags
installFlags haddockFlags
installFlags haddockFlags testFlags

-- | This defines what a 'TargetSelector' means for the @haddock@ command.
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
Expand Down
Loading