diff --git a/.gitignore b/.gitignore index 9be5fa2e5b..bb87ac1be7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.swp *.tag *~ +*_flymake.hs .hsenv .stack-work/ /.cabal-sandbox/ diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 3dfde31a7a..610ff6f88e 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -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 diff --git a/src/Stack/Build/Types.hs b/src/Stack/Build/Types.hs index 9191c8747a..051d6d5695 100644 --- a/src/Stack/Build/Types.hs +++ b/src/Stack/Build/Types.hs @@ -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) @@ -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. diff --git a/src/main/Main.hs b/src/main/Main.hs index 166cf5d394..c9ac89ac92 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -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 @@ -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" <>