-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4244 from haskell/new-test
WIP: new-test
- Loading branch information
Showing
8 changed files
with
165 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
|
||
-- | cabal-install CLI command: new-test | ||
-- | ||
module Distribution.Client.CmdTest ( | ||
testCommand, | ||
testAction, | ||
) where | ||
|
||
import Distribution.Client.ProjectOrchestration | ||
import Distribution.Client.ProjectPlanning | ||
( PackageTarget(..) ) | ||
import Distribution.Client.BuildTarget | ||
( readUserBuildTargets ) | ||
|
||
import Distribution.Client.Setup | ||
( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags ) | ||
import Distribution.Simple.Setup | ||
( HaddockFlags, fromFlagOrDefault ) | ||
import Distribution.Verbosity | ||
( normal ) | ||
|
||
import Distribution.Simple.Command | ||
( CommandUI(..), usageAlternatives ) | ||
import Distribution.Simple.Utils | ||
( wrapText ) | ||
import qualified Distribution.Client.Setup as Client | ||
|
||
testCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags) | ||
testCommand = Client.installCommand { | ||
commandName = "new-test", | ||
commandSynopsis = "Perform new-build and run tests", | ||
commandUsage = usageAlternatives "new-test" [ "[FLAGS] TARGET" ], | ||
commandDescription = Just $ \_ -> wrapText $ | ||
"Build and run test targets", | ||
commandNotes = Just $ \_pname -> | ||
"Examples:\n" | ||
} | ||
|
||
-- | The @test@ command is very much like @build@. It brings the install plan | ||
-- up to date, selects that part of the plan needed by the given or implicit | ||
-- test arget(s) and then executes the plan. | ||
-- | ||
-- Compared to @build@ the difference is that there's also test targets | ||
-- which are ephemeral. | ||
-- | ||
-- For more details on how this works, see the module | ||
-- "Distribution.Client.ProjectOrchestration" | ||
-- | ||
testAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags) | ||
-> [String] -> GlobalFlags -> IO () | ||
testAction (configFlags, configExFlags, installFlags, haddockFlags) | ||
targetStrings globalFlags = do | ||
|
||
userTargets <- readUserBuildTargets targetStrings | ||
|
||
buildCtx <- | ||
runProjectPreBuildPhase | ||
verbosity | ||
( globalFlags, configFlags, configExFlags | ||
, installFlags, haddockFlags ) | ||
PreBuildHooks { | ||
hookPrePlanning = \_ _ _ -> return (), | ||
|
||
hookSelectPlanSubset = \_buildSettings elaboratedPlan -> | ||
-- Interpret the targets on the command line as test targets | ||
-- (as opposed to say build or haddock targets). | ||
selectTargets | ||
verbosity | ||
TestDefaultComponents | ||
TestSpecificComponent | ||
userTargets | ||
False -- onlyDependencies, always False for test | ||
elaboratedPlan | ||
} | ||
|
||
printPlan verbosity buildCtx | ||
|
||
buildOutcomes <- runProjectBuildPhase verbosity buildCtx | ||
runProjectPostBuildPhase verbosity buildCtx buildOutcomes | ||
where | ||
verbosity = fromFlagOrDefault normal (configVerbosity configFlags) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: . |
4 changes: 4 additions & 0 deletions
4
cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
cabal "new-test" [] |