Skip to content

Commit

Permalink
Add --no-run-tests parameter to stack test.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianBirch committed Jul 6, 2015
1 parent 311f881 commit ff9d00c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
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
23 changes: 13 additions & 10 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -714,17 +714,20 @@ singleTest rerunTests ac ee task =
TTLocal lp -> writeBuildCache pkgDir $ lpNewBuildCache lp
TTUpstream _ _ -> assert False $ return ()
cabal (console && configHideTHLoading config) $ "build" : components

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 @@ -667,7 +667,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 @@ -746,6 +746,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

0 comments on commit ff9d00c

Please sign in to comment.