clean up concurrent output of tests
Using concurrent-output this is easy. Just have to check if tasty has color enabled, and propagate it into the worker processes, some of which will be run without a controlling console. Also added a call to installSignalHandlers; I noticed that interrupting the test suite could leave the console in a bad state and this fixes that. The ansi-terminal dependency is free, since tasty also depends on it. Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
ca711f1741
commit
d3b7c6705c
3 changed files with 15 additions and 5 deletions
|
@ -15,10 +15,13 @@ import Test.Tasty.HUnit
|
||||||
import Test.Tasty.QuickCheck
|
import Test.Tasty.QuickCheck
|
||||||
import Test.Tasty.Options
|
import Test.Tasty.Options
|
||||||
import Test.Tasty.Ingredients.Rerun
|
import Test.Tasty.Ingredients.Rerun
|
||||||
|
import Test.Tasty.Ingredients.ConsoleReporter
|
||||||
import Options.Applicative.Types
|
import Options.Applicative.Types
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Concurrent.Async
|
import Control.Concurrent.Async
|
||||||
import System.Environment (getArgs)
|
import System.Environment (getArgs)
|
||||||
|
import System.Console.Concurrent
|
||||||
|
import System.Console.ANSI
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import Types.Test
|
import Types.Test
|
||||||
|
@ -495,7 +498,7 @@ setTestMode testmode = do
|
||||||
, ("GIT_ANNEX_USE_GIT_SSH", "1")
|
, ("GIT_ANNEX_USE_GIT_SSH", "1")
|
||||||
, ("TESTMODE", show testmode)
|
, ("TESTMODE", show testmode)
|
||||||
]
|
]
|
||||||
|
|
||||||
runFakeSsh :: [String] -> IO ()
|
runFakeSsh :: [String] -> IO ()
|
||||||
runFakeSsh ("-n":ps) = runFakeSsh ps
|
runFakeSsh ("-n":ps) = runFakeSsh ps
|
||||||
runFakeSsh (_host:cmd:[]) =
|
runFakeSsh (_host:cmd:[]) =
|
||||||
|
@ -698,17 +701,21 @@ parallelTestRunner opts mkts
|
||||||
hPutStrLn stderr "warnings from tasty:"
|
hPutStrLn stderr "warnings from tasty:"
|
||||||
mapM_ (hPutStrLn stderr) warnings
|
mapM_ (hPutStrLn stderr) warnings
|
||||||
environ <- Utility.Env.getEnvironment
|
environ <- Utility.Env.getEnvironment
|
||||||
ps <- getArgs
|
args <- getArgs
|
||||||
pp <- Annex.Path.programPath
|
pp <- Annex.Path.programPath
|
||||||
exitcodes <- forConcurrently [1..length ts] $ \n -> do
|
termcolor <- hSupportsANSIColor stdout
|
||||||
|
let ps = if useColor (lookupOption (tastyOptionSet opts)) termcolor
|
||||||
|
then "--color=always":args
|
||||||
|
else "--color=never":args
|
||||||
|
exitcodes <- withConcurrentOutput $ forConcurrently [1..length ts] $ \n -> do
|
||||||
let subdir = tmpdir </> show n
|
let subdir = tmpdir </> show n
|
||||||
ensuredir subdir
|
ensuredir subdir
|
||||||
let p = (proc pp ps)
|
let p = (proc pp ps)
|
||||||
{ env = Just ((subenv, show (n, crippledfilesystem, adjustedbranchok)):environ)
|
{ env = Just ((subenv, show (n, crippledfilesystem, adjustedbranchok)):environ)
|
||||||
, cwd = Just subdir
|
, cwd = Just subdir
|
||||||
}
|
}
|
||||||
withCreateProcess p $
|
(_, _, _, pid) <- createProcessConcurrent p
|
||||||
\_ _ _ pid -> waitForProcess pid
|
waitForProcess pid
|
||||||
unless (keepFailuresOption opts) finalCleanup
|
unless (keepFailuresOption opts) finalCleanup
|
||||||
if all (== ExitSuccess) exitcodes
|
if all (== ExitSuccess) exitcodes
|
||||||
then exitSuccess
|
then exitSuccess
|
||||||
|
@ -732,6 +739,7 @@ parallelTestRunner opts mkts
|
||||||
]
|
]
|
||||||
, ts !! (n - 1)
|
, ts !! (n - 1)
|
||||||
]
|
]
|
||||||
|
installSignalHandlers
|
||||||
case tryIngredients ingredients (tastyOptionSet opts) t of
|
case tryIngredients ingredients (tastyOptionSet opts) t of
|
||||||
Nothing -> error "No tests found!?"
|
Nothing -> error "No tests found!?"
|
||||||
Just act -> ifM act
|
Just act -> ifM act
|
||||||
|
|
1
debian/control
vendored
1
debian/control
vendored
|
@ -70,6 +70,7 @@ Build-Depends:
|
||||||
libghc-tasty-hunit-dev,
|
libghc-tasty-hunit-dev,
|
||||||
libghc-tasty-quickcheck-dev,
|
libghc-tasty-quickcheck-dev,
|
||||||
libghc-tasty-rerun-dev,
|
libghc-tasty-rerun-dev,
|
||||||
|
libghc-ansi-terminal-dev,
|
||||||
libghc-optparse-applicative-dev (>= 0.11.0),
|
libghc-optparse-applicative-dev (>= 0.11.0),
|
||||||
libghc-torrent-dev,
|
libghc-torrent-dev,
|
||||||
libghc-concurrent-output-dev,
|
libghc-concurrent-output-dev,
|
||||||
|
|
|
@ -378,6 +378,7 @@ Executable git-annex
|
||||||
tasty-hunit,
|
tasty-hunit,
|
||||||
tasty-quickcheck,
|
tasty-quickcheck,
|
||||||
tasty-rerun,
|
tasty-rerun,
|
||||||
|
ansi-terminal >= 0.9,
|
||||||
aws (>= 0.20),
|
aws (>= 0.20),
|
||||||
DAV (>= 1.0)
|
DAV (>= 1.0)
|
||||||
CC-Options: -Wall
|
CC-Options: -Wall
|
||||||
|
|
Loading…
Add table
Reference in a new issue