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

Add --no-tests parameter to stack test #517

Merged
merged 1 commit into from
Jul 7, 2015
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.swp
*.tag
*~
*_flymake.hs
.hsenv
.stack-work/
/.cabal-sandbox/
Expand Down
22 changes: 13 additions & 9 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -721,15 +721,19 @@ singleTest rerunTests ac ee task =
setTestBuilt pkgDir

toRun <-
if rerunTests
then return True
else do
success <- checkTestSuccess pkgDir
if success
then do
unless (null testsToRun) $ announce "skipping already passed test"
return False
else return True
if (boptsNoTests (eeBuildOpts ee))
then do
announce "Test running disabled by --no-tests flag."
return False
else if rerunTests
then return True
else do
success <- checkTestSuccess pkgDir
if success
then do
unless (null testsToRun) $ announce "skipping already passed test"
return False
else return True

when toRun $ do
bconfig <- asks getBuildConfig
Expand Down
3 changes: 3 additions & 0 deletions src/Stack/Build/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ data BuildOpts =
-- ^ Watch files for changes and automatically rebuild
,boptsKeepGoing :: !(Maybe Bool)
-- ^ Keep building/running after failure
,boptsNoTests :: !Bool
-- ^ If set, don't run the tests
}
deriving (Show)

Expand All @@ -323,6 +325,7 @@ defaultBuildOpts = BuildOpts
, boptsCoverage = False
, boptsFileWatch = False
, boptsKeepGoing = Nothing
, boptsNoTests = False
}

-- | Run a Setup.hs action after building a package, before installing.
Expand Down
8 changes: 7 additions & 1 deletion src/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ buildOpts cmd = fmap process $
BuildOpts <$> target <*> libProfiling <*> exeProfiling <*>
optimize <*> haddock <*> haddockDeps <*> finalAction <*> dryRun <*> ghcOpts <*>
flags <*> installExes <*> preFetch <*> testArgs <*> onlySnapshot <*> coverage <*>
fileWatch' <*> keepGoing
fileWatch' <*> keepGoing <*> noTests
where process bopts =
if boptsCoverage bopts
then bopts { boptsExeProfile = True
Expand Down Expand Up @@ -748,6 +748,12 @@ buildOpts cmd = fmap process $
(long "coverage" <>
help "Generate a code coverage report")
else pure False
noTests =
if cmd == Test
then flag False True
(long "no-run-tests" <>
help "Disable running of tests. (Tests will still be built.)")
else pure False

fileWatch' = flag False True
(long "file-watch" <>
Expand Down