test-karya-0.0.3: Testing framework.

Safe HaskellNone
LanguageHaskell2010

EL.Test.RunTests

Contents

Description

Run tests. This is meant to be invoked via a main module generated by EL.Test.GenerateRunTests.

Synopsis

Documentation

data Test Source #

Constructors

Test 

Fields

data Flag Source #

Instances
Eq Flag Source # 
Instance details

Defined in EL.Test.RunTests

Methods

(==) :: Flag -> Flag -> Bool #

(/=) :: Flag -> Flag -> Bool #

Show Flag Source # 
Instance details

Defined in EL.Test.RunTests

Methods

showsPrec :: Int -> Flag -> ShowS #

show :: Flag -> String #

showList :: [Flag] -> ShowS #

data Jobs Source #

Constructors

Auto 
NJobs !Int 
Instances
Eq Jobs Source # 
Instance details

Defined in EL.Test.RunTests

Methods

(==) :: Jobs -> Jobs -> Bool #

(/=) :: Jobs -> Jobs -> Bool #

Show Jobs Source # 
Instance details

Defined in EL.Test.RunTests

Methods

showsPrec :: Int -> Jobs -> ShowS #

show :: Jobs -> String #

showList :: [Jobs] -> ShowS #

run :: [String] -> [Test] -> IO () Source #

Called by the generated main function.

runTests :: [Test] -> [Flag] -> [String] -> IO Bool Source #

runInSubprocess :: Test -> IO () Source #

Isolate the test by running it in a subprocess. I'm not sure if this is necessary, but I believe at the time GUI-using tests would crash each other without it. Presumably they left some GUI state around that process exit will clean up.

parallel jobs

runParallel :: [FilePath] -> [Test] -> IO () Source #

Run tests in parallel, redirecting stdout and stderr to each output.

jobThread :: FilePath -> Queue (Text, [Test]) -> IO () Source #

Pull tests off the queue and feed them to a single subprocess.

testsCompleteLine :: Text Source #

Signal to the caller that the current batch of tests are done.

run tests

matchingTests :: [String] -> [Test] -> [Test] Source #

Match all tests whose names match any regex, or if a test is an exact match, just that test.

isolate :: IO a -> IO a Source #

Try to save and restore any process level state in case the test messes with it. Currently this just restores CWD, but probably there is more than that. For actual isolation probably a subprocess is necessary.

catch :: Text -> IO a -> IO () Source #

queue

newtype Queue a Source #

This is a simple channel which is written to once, and read from until empty.

Constructors

Queue (MVar [a]) 

newQueue :: [a] -> IO (Queue a) Source #

whileJust :: Monad m => m (Maybe a) -> (a -> m ()) -> m () Source #

check output

clearDirectory :: FilePath -> IO () Source #

Empty the directory, but don't remove it entirely, in case it's /tmp or something.

extractStats Source #

Arguments

:: Text 
-> ([Text], Int, Int, Int)

(failureContext, failures, checks, tests)

extractFailures Source #

Arguments

:: [Text] 
-> [Maybe Text]

Just context for a failure, Nothing for a success.

Collect lines before and after each failure for context.

I collect before because that's where debugging info about that test is likely to show up, and I collect after because the failure output may have multiple lines.

It can be confusing that I can get the failure lines of the previous test as context for the current one. To fix that I'd have to explicitly mark all lines of the failure, or put some ending marker afterwards. It's not hard but maybe not worth it.