tasty-1.5.3: Modern and extensible testing framework

Safe Haskell | None
Language | Haskell2010

Test.Tasty.Runners

Contents

- Working with the test tree
- Ingredients
- Standard console ingredients
  - Console test reporter
  - Tests list
- Command line handling
- Running tests
- Options
  - Patterns
- Utilities

Description

API for test runners.

Since: 0.1

Synopsis

- data TestTree
  - = IsTest t => SingleTest TestName t
  - | TestGroup TestName [TestTree]
  - | PlusTestOptions (OptionSet -> OptionSet) TestTree
  - | WithResource (ResourceSpec a) (IO a -> TestTree)
  - | AskOptions (OptionSet -> TestTree)
  - | After DependencyType Expr TestTree
- foldTestTree :: Monoid b => TreeFold b -> OptionSet -> TestTree -> b
- data TreeFold b = TreeFold {
  - foldSingle :: forall t. IsTest t => OptionSet -> TestName -> t -> b
  - foldGroup :: OptionSet -> TestName -> [b] -> b
  - foldResource :: forall a. OptionSet -> ResourceSpec a -> (IO a -> b) -> b
  - foldAfter :: OptionSet -> DependencyType -> Expr -> b -> b
  }
- trivialFold :: Monoid b => TreeFold b
- data ResourceSpec a = ResourceSpec (IO a) (a -> IO ())
- newtype Ap (f :: Type -> Type) a = Ap {
  - getApp :: f a
  }
- newtype Traversal (f :: Type -> Type) = Traversal {
  - getTraversal :: f ()
  }
- data Ingredient
  - = TestReporter [OptionDescription] (OptionSet -> TestTree -> Maybe (StatusMap -> IO (Time -> IO Bool)))
  - | TestManager [OptionDescription] (OptionSet -> TestTree -> Maybe (IO Bool))
- type Time = Double
- tryIngredients :: [Ingredient] -> OptionSet -> TestTree -> Maybe (IO Bool)
- ingredientOptions :: Ingredient -> [OptionDescription]
- ingredientsOptions :: [Ingredient] -> [OptionDescription]
- consoleTestReporter :: Ingredient
- listingTests :: Ingredient
- newtype ListTests = ListTests Bool
- testsNames :: OptionSet -> TestTree -> [TestName]
- parseOptions :: [Ingredient] -> TestTree -> IO OptionSet
- optionParser :: [OptionDescription] -> ([String], Parser OptionSet)
- suiteOptionParser :: [Ingredient] -> TestTree -> ([String], Parser OptionSet)
- defaultMainWithIngredients :: [Ingredient] -> TestTree -> IO ()
- data Status
  - = NotStarted
  - | Executing Progress
  - | Done Result
- data Result = Result {
  - resultOutcome :: Outcome
  - resultDescription :: String
  - resultShortDescription :: String
  - resultTime :: Time
  - resultDetailsPrinter :: ResultDetailsPrinter
  }
- data Outcome
  - = Success
  - | Failure FailureReason
- data FailureReason
  - = TestFailed
  - | TestThrewException SomeException
  - | TestTimedOut Integer
  - | TestDepFailed
- resultSuccessful :: Result -> Bool
- data Progress = Progress {
  - progressText :: String
  - progressPercent :: Float
  }
- emptyProgress :: Progress
- type StatusMap = IntMap (TVar Status)
- launchTestTree :: OptionSet -> TestTree -> (StatusMap -> IO (Time -> IO a)) -> IO a
- newtype NumThreads = NumThreads {
  - getNumThreads :: Int
  }
- newtype DependencyException = DependencyLoop [[Path]]
- suiteOptions :: [Ingredient] -> TestTree -> [OptionDescription]
- coreOptions :: [OptionDescription]
- type Path = Seq String
- newtype TestPattern = TestPattern (Maybe Expr)
- parseExpr :: String -> Maybe Expr
- parseTestPattern :: String -> Maybe TestPattern
- noPattern :: TestPattern
- exprMatches :: Expr -> Path -> Bool
- testPatternMatches :: TestPattern -> Path -> Bool
- installSignalHandlers :: IO ()
- timed :: IO a -> IO (Time, a)
- forceElements :: [a] -> ()
- formatMessage :: String -> IO String
- newtype SignalException = SignalException CInt
- getTime :: IO Time

# Working with the test tree

data TestTree Source #

The main data structure defining a test suite.

It consists of individual test cases and properties, organized in named groups which form a tree-like hierarchy.

There is no generic way to create a test case. Instead, every test provider (tasty-hunit, tasty-smallcheck etc.) provides a function to turn a test case into a `TestTree`.

Groups can be created using `testGroup`.

Since: 0.1

Constructors

IsTest t => SingleTest TestName t | A single test of some particular type
TestGroup TestName [TestTree] | Assemble a number of tests into a cohesive group
PlusTestOptions (OptionSet -> OptionSet) TestTree | Add some options to child tests
WithResource (ResourceSpec a) (IO a -> TestTree) | Acquire the resource before the tests in the inner tree start and release it after they finish. The tree gets an `IO` action which yields the resource, although the resource is shared across all the tests. Since: 0.5
AskOptions (OptionSet -> TestTree) | Ask for the options and customize the tests based on them. Since: 0.6
After DependencyType Expr TestTree | Only run after all tests that match a given pattern finish (and, depending on the `DependencyType`, succeed). Since: 1.2

foldTestTree Source #

Arguments

:: Monoid b |
=> TreeFold b | the algebra (i.e. how to fold a tree)
-> OptionSet | initial options
-> TestTree | the tree to fold
-> b |

Fold a test tree into a single value.

The fold result type should be a monoid. This is used to fold multiple results in a test group. In particular, empty groups get folded into `mempty`.

Apart from pure convenience, this function also does the following useful things:

1. Keeping track of the current options (which may change due to `PlusTestOptions` nodes)
2. Filtering out the tests which do not match the patterns

Thus, it is preferred to an explicit recursive traversal of the tree.

Since: 0.7

data TreeFold b Source #

An algebra for folding a `TestTree`.

Instead of constructing fresh records, build upon `trivialFold` instead. This way your code won't break when new nodes/fields are indroduced.

Since: 0.7

Constructors

TreeFold |

Fields

- foldSingle :: forall t. IsTest t => OptionSet -> TestName -> t -> b
- foldGroup :: OptionSet -> TestName -> [b] -> b

  Since: 1.4

- foldResource :: forall a. OptionSet -> ResourceSpec a -> (IO a -> b) -> b
- foldAfter :: OptionSet -> DependencyType -> Expr -> b -> b

  Since: 1.2

trivialFold :: Monoid b => TreeFold b Source #

`trivialFold` can serve as the basis for custom folds. Just override the fields you need.

Here's what it does:

- single tests are mapped to `mempty` (you probably do want to override that)
- test groups are returned unmodified
- for a resource, an IO action that throws an exception is passed (you want to override this for runners/ingredients that execute tests)

Since: 0.7

data ResourceSpec a Source #

`ResourceSpec` describes how to acquire a resource (the first field) and how to release it (the second field).

Since: 0.6

Constructors

ResourceSpec (IO a) (a -> IO ()) |

newtype Ap (f :: Type -> Type) a Source #

Monoid generated by ``liftA2` (`<>`)`

Starting from GHC 8.6, a similar type is available from Data.Monoid. This type is nevertheless kept for compatibility.

Since: 0.8

Constructors

Ap |

Fields

- getApp :: f a

#### Instances

Instances details

Applicative f => Applicative (Ap f) Source # |
Instance details Defined in Test.Tasty.Runners.Reducers Methods pure :: a -> Ap f a Source # (<*>) :: Ap f (a -> b) -> Ap f a -> Ap f b Source # liftA2 :: (a -> b -> c) -> Ap f a -> Ap f b -> Ap f c Source # (*>) :: Ap f a -> Ap f b -> Ap f b Source # (<*) :: Ap f a -> Ap f b -> Ap f a Source #
Functor f => Functor (Ap f) Source # |
Instance details Defined in Test.Tasty.Runners.Reducers Methods fmap :: (a -> b) -> Ap f a -> Ap f b Source # (<$) :: a -> Ap f b -> Ap f a Source #
Monad f => Monad (Ap f) Source # |
Instance details Defined in Test.Tasty.Runners.Reducers Methods (>>=) :: Ap f a -> (a -> Ap f b) -> Ap f b Source # (>>) :: Ap f a -> Ap f b -> Ap f b Source # return :: a -> Ap f a Source #
(Applicative f, Monoid a) => Monoid (Ap f a) Source # |
Instance details Defined in Test.Tasty.Runners.Reducers Methods mempty :: Ap f a Source # mappend :: Ap f a -> Ap f a -> Ap f a Source # mconcat :: [Ap f a] -> Ap f a Source #
(Applicative f, Monoid a) => Semigroup (Ap f a) Source # | Since: 0.12.0.1
Instance details Defined in Test.Tasty.Runners.Reducers Methods (<>) :: Ap f a -> Ap f a -> Ap f a Source # sconcat :: NonEmpty (Ap f a) -> Ap f a Source # stimes :: Integral b => b -> Ap f a -> Ap f a Source #

newtype Traversal (f :: Type -> Type) Source #

Monoid generated by `*>`.

Since: 0.8

Constructors

Traversal |

Fields

- getTraversal :: f ()

#### Instances

Instances details

Applicative f => Monoid (Traversal f) Source # |
Instance details Defined in Test.Tasty.Runners.Reducers Methods mempty :: Traversal f Source # mappend :: Traversal f -> Traversal f -> Traversal f Source # mconcat :: [Traversal f] -> Traversal f Source #
Applicative f => Semigroup (Traversal f) Source # | Since: 0.12.0.1
Instance details Defined in Test.Tasty.Runners.Reducers Methods (<>) :: Traversal f -> Traversal f -> Traversal f Source # sconcat :: NonEmpty (Traversal f) -> Traversal f Source # stimes :: Integral b => b -> Traversal f -> Traversal f Source #

# Ingredients

data Ingredient Source #

`Ingredient`s make your test suite tasty.

Ingredients represent different actions that you can perform on your test suite. One obvious ingredient that you want to include is one that runs tests and reports the progress and results.

Another standard ingredient is one that simply prints the names of all tests.

Similar to test providers (see `IsTest`), every ingredient may specify which options it cares about, so that those options are presented to the user if the ingredient is included in the test suite.

An ingredient can choose, typically based on the `OptionSet`, whether to run. That's what the `Maybe` is for. The first ingredient that agreed to run does its work, and the remaining ingredients are ignored. Thus, the order in which you arrange the ingredients may matter.

Usually, the ingredient which runs the tests is unconditional and thus should be placed last in the list. Other ingredients usually run only if explicitly requested via an option. Their relative order thus doesn't matter.

That's all you need to know from an (advanced) user perspective. Read on if you want to create a new ingredient.

There are two kinds of ingredients.

The first kind is `TestReporter`. If the ingredient that agrees to run is a `TestReporter`, then tasty will automatically launch the tests and pass a `StatusMap` to the ingredient. All the ingredient needs to do then is to process the test results and probably report them to the user in some way (hence the name).

`TestManager` is the second kind of ingredient. It is typically used for test management purposes (such as listing the test names), although it can also be used for running tests (but, unlike `TestReporter`, it has to launch the tests manually if it wants them to be run). It is therefore more general than `TestReporter`. `TestReporter` is provided just for convenience.

The function's result should indicate whether all the tests passed.

In the `TestManager` case, it's up to the ingredient author to decide what the result should be. When no tests are run, the result should probably be `True`. Sometimes, even if some tests run and fail, it still makes sense to return `True`.

Since: 0.4

Constructors

TestReporter [OptionDescription] (OptionSet -> TestTree -> Maybe (StatusMap -> IO (Time -> IO Bool))) | For the explanation on how the callback works, see the documentation for `launchTestTree`. Since: 0.10
TestManager [OptionDescription] (OptionSet -> TestTree -> Maybe (IO Bool)) | Since: 0.4

type Time = Double Source #

Time in seconds. Used to measure how long the tests took to run.

Since: 0.10

tryIngredients :: [Ingredient] -> OptionSet -> TestTree -> Maybe (IO Bool) Source #

Run the first `Ingredient` that agrees to be run.

If no one accepts the task, return `Nothing`. This is usually a sign of misconfiguration.

Since: 0.4

ingredientOptions :: Ingredient -> [OptionDescription] Source #

Return the options which are relevant for the given ingredient.

Note that this isn't the same as simply pattern-matching on `Ingredient`. E.g. options for a `TestReporter` automatically include `NumThreads`.

Since: 0.4

ingredientsOptions :: [Ingredient] -> [OptionDescription] Source #

Like `ingredientOptions`, but folds over multiple ingredients.

Since: 0.4

# Standard console ingredients

NOTE: the exports in this section are deprecated and will be removed in the future. Please import Test.Tasty.Ingredients.Basic if you need them.

## Console test reporter

consoleTestReporter :: Ingredient Source #

A simple console UI.

Since: 0.4

## Tests list

listingTests :: Ingredient Source #

The ingredient that provides the test listing functionality.

Since: 0.4

newtype ListTests Source #

This option, when set to `True`, specifies that we should run in the «list tests» mode.

Since: 0.4

Constructors

ListTests Bool |

#### Instances

Instances details

Eq ListTests Source # |
Instance details Defined in Test.Tasty.Ingredients.ListTests Methods (==) :: ListTests -> ListTests -> Bool Source # (/=) :: ListTests -> ListTests -> Bool Source #
Ord ListTests Source # |

Instance details

Defined in Test.Tasty.Ingredients.ListTests

Methods

compare :: ListTests -> ListTests -> Ordering Source #

(<) :: ListTests -> ListTests -> Bool Source #

(<=) :: ListTests -> ListTests -> Bool Source #

(>) :: ListTests -> ListTests -> Bool Source #

(>=) :: ListTests -> ListTests -> Bool Source #

max :: ListTests -> ListTests -> ListTests Source #

min :: ListTests -> ListTests -> ListTests Source #

IsOption ListTests Source # |
Instance details Defined in Test.Tasty.Ingredients.ListTests Methods defaultValue :: ListTests Source # parseValue :: String -> Maybe ListTests Source # optionName :: Tagged ListTests String Source # optionHelp :: Tagged ListTests String Source # showDefaultValue :: ListTests -> Maybe String Source # optionCLParser :: Parser ListTests Source #

testsNames :: OptionSet -> TestTree -> [TestName] Source #

Obtain the list of all tests in the suite.

Since: 0.4

# Command line handling

parseOptions :: [Ingredient] -> TestTree -> IO OptionSet Source #

Parse the command-line and environment options passed to tasty.

Useful if you need to get the options before `defaultMain` is called.

Once within the test tree, `askOption` should be used instead.

The arguments to this function should be the same as for `defaultMainWithIngredients`. If you don't use any custom ingredients, pass `defaultIngredients`.

Since: 1.2.2

optionParser :: [OptionDescription] -> ([String], Parser OptionSet) Source #

Generate a command line parser from a list of option descriptions, alongside any related warning messages.

Since: 1.3

suiteOptionParser :: [Ingredient] -> TestTree -> ([String], Parser OptionSet) Source #

The command line parser for the test suite, alongside any related warnings.

Since: 1.3

defaultMainWithIngredients :: [Ingredient] -> TestTree -> IO () Source #

Parse the command line arguments and run the tests using the provided ingredient list.

When the tests finish, this function calls `exitWith` with the exit code that indicates whether any tests have failed. See `defaultMain` for details.

Since: 0.4

# Running tests

data Status Source #

Current status of a test.

Since: 0.1

Constructors

NotStarted | test has not started running yet
Executing Progress | test is being run
Done Result | test finished with a given result

#### Instances

Instances details

Show Status Source # | Since: 1.2
Instance details Defined in Test.Tasty.Run Methods showsPrec :: Int -> Status -> ShowS Source # show :: Status -> String Source # showList :: [Status] -> ShowS Source #

data Result Source #

A test result.

Since: 0.1

Constructors

Result |

Fields

- resultOutcome :: Outcome

  Did the test fail? If so, why?

- resultDescription :: String

  `resultDescription` may contain some details about the test. For a passed test it's ok to leave it empty. Providers like SmallCheck and QuickCheck use it to provide information about how many tests were generated.

  For a failed test, `resultDescription` should typically provide more information about the failure.

  Since: 0.11

- resultShortDescription :: String

  The short description printed in the test run summary, usually `OK` or `FAIL`.

  Since: 0.10

- resultTime :: Time

  How long it took to run the test, in seconds.

- resultDetailsPrinter :: ResultDetailsPrinter

  An action that prints additional information about a test.

  This is similar to `resultDescription` except it can produce colorful/formatted output; see Test.Tasty.Providers.ConsoleFormat.

  This can be used instead of or in addition to `resultDescription`.

  Usually this is set to `noResultDetails`, which does nothing.

  Since: 1.3.1

#### Instances

Instances details

Show Result Source # | Since: 1.2
Instance details Defined in Test.Tasty.Core Methods showsPrec :: Int -> Result -> ShowS Source # show :: Result -> String Source # showList :: [Result] -> ShowS Source #

data Outcome Source #

Outcome of a test run

Note: this is isomorphic to ``Maybe` `FailureReason``. You can use the `generic-maybe` package to exploit that.

Since: 0.8

Constructors

Success | test succeeded
Failure FailureReason | test failed because of the `FailureReason`

#### Instances

Instances details

Generic Outcome Source # |

Instance details

Defined in Test.Tasty.Core

Associated Types

type Rep Outcome |
Instance details Defined in Test.Tasty.Core type Rep Outcome = D1 ('MetaData "Outcome" "Test.Tasty.Core" "tasty-1.5.3-Cx633LXucsH6WTvNpdpDhS" 'False) (C1 ('MetaCons "Success" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Failure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FailureReason)))

Methods

from :: Outcome -> Rep Outcome x Source #

to :: Rep Outcome x -> Outcome Source #

Show Outcome Source # |
Instance details Defined in Test.Tasty.Core Methods showsPrec :: Int -> Outcome -> ShowS Source # show :: Outcome -> String Source # showList :: [Outcome] -> ShowS Source #
type Rep Outcome Source # |
Instance details Defined in Test.Tasty.Core type Rep Outcome = D1 ('MetaData "Outcome" "Test.Tasty.Core" "tasty-1.5.3-Cx633LXucsH6WTvNpdpDhS" 'False) (C1 ('MetaCons "Success" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Failure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FailureReason)))

data FailureReason Source #

If a test failed, `FailureReason` describes why.

Since: 0.8

Constructors

TestFailed | test provider indicated failure of the code to test, either because the tested code returned wrong results, or raised an exception
TestThrewException SomeException | the test code itself raised an exception. Typical cases include missing example input or output files. Usually, providers do not have to implement this, as their `run` method may simply raise an exception.
TestTimedOut Integer | test didn't complete in allotted time
TestDepFailed | a dependency of this test failed, so this test was skipped. Since: 1.2

#### Instances

Instances details

Show FailureReason Source # |
Instance details Defined in Test.Tasty.Core Methods showsPrec :: Int -> FailureReason -> ShowS Source # show :: FailureReason -> String Source # showList :: [FailureReason] -> ShowS Source #

resultSuccessful :: Result -> Bool Source #

`True` for a passed test, `False` for a failed one.

Since: 0.8

data Progress Source #

Test progress information.

This may be used by a runner to provide some feedback to the user while a long-running test is executing.

Since: 0.1

Constructors

Progress |

Fields

- progressText :: String

  textual information about the test's progress

- progressPercent :: Float

  `progressPercent` should be a value between 0 and 1. If it's impossible to compute the estimate, use 0.

#### Instances

Instances details

Show Progress Source # | Since: 1.2
Instance details Defined in Test.Tasty.Core Methods showsPrec :: Int -> Progress -> ShowS Source # show :: Progress -> String Source # showList :: [Progress] -> ShowS Source #
Eq Progress Source # | Since: 1.5
Instance details Defined in Test.Tasty.Core Methods (==) :: Progress -> Progress -> Bool Source # (/=) :: Progress -> Progress -> Bool Source #

emptyProgress :: Progress Source #

Empty progress

Since: 1.5

type StatusMap = IntMap (TVar Status) Source #

Mapping from test numbers (starting from 0) to their status variables.

This is what an ingredient uses to analyse and display progress, and to detect when tests finish.

Since: 0.1

launchTestTree Source #

Arguments

:: OptionSet |
-> TestTree |

-> (StatusMap -> IO (Time -> IO a))

A callback. First, it receives the `StatusMap` through which it can observe the execution of tests in real time. Typically (but not necessarily), it waits until all the tests are finished.

After this callback returns, the test-running threads (if any) are terminated and all resources acquired by tests are released.

The callback must return another callback (of type ``Time` -> `IO` a`) which additionally can report and/or record the total time taken by the test suite. This time includes the time taken to run all resource initializers and finalizers, which is why it is more accurate than what could be measured from inside the first callback.

-> IO a |

Start running the tests (in background, in parallel) and pass control to the callback.

Once the callback returns, stop running the tests.

The number of test running threads is determined by the `NumThreads` option.

Since: 0.10

newtype NumThreads Source #

Number of parallel threads to use for running tests.

Note that this is not included in `coreOptions`. Instead, it's automatically included in the options for any `TestReporter` ingredient by `ingredientOptions`, because the way test reporters are handled already involves parallelism. Other ingredients may also choose to include this option.

Since: 0.1

Constructors

NumThreads |

Fields

- getNumThreads :: Int

#### Instances

Instances details

Num NumThreads Source # |
Instance details Defined in Test.Tasty.Options.Core Methods (+) :: NumThreads -> NumThreads -> NumThreads Source # (-) :: NumThreads -> NumThreads -> NumThreads Source # (*) :: NumThreads -> NumThreads -> NumThreads Source # negate :: NumThreads -> NumThreads Source # abs :: NumThreads -> NumThreads Source # signum :: NumThreads -> NumThreads Source # fromInteger :: Integer -> NumThreads Source #
Eq NumThreads Source # |
Instance details Defined in Test.Tasty.Options.Core Methods (==) :: NumThreads -> NumThreads -> Bool Source # (/=) :: NumThreads -> NumThreads -> Bool Source #
Ord NumThreads Source # |

Instance details

Defined in Test.Tasty.Options.Core

Methods

compare :: NumThreads -> NumThreads -> Ordering Source #

(<) :: NumThreads -> NumThreads -> Bool Source #

(<=) :: NumThreads -> NumThreads -> Bool Source #

(>) :: NumThreads -> NumThreads -> Bool Source #

(>=) :: NumThreads -> NumThreads -> Bool Source #

max :: NumThreads -> NumThreads -> NumThreads Source #

min :: NumThreads -> NumThreads -> NumThreads Source #

IsOption NumThreads Source # |
Instance details Defined in Test.Tasty.Options.Core Methods defaultValue :: NumThreads Source # parseValue :: String -> Maybe NumThreads Source # optionName :: Tagged NumThreads String Source # optionHelp :: Tagged NumThreads String Source # showDefaultValue :: NumThreads -> Maybe String Source # optionCLParser :: Parser NumThreads Source #

newtype DependencyException Source #

Exceptions related to dependencies between tests.

Since: 1.2

Constructors

DependencyLoop [[Path]] | Test dependencies form cycles. In other words, test A cannot start until test B finishes, and test B cannot start until test A finishes. Field lists detected cycles. Since: 1.5

#### Instances

Instances details

Exception DependencyException Source # |
Instance details Defined in Test.Tasty.Run Methods toException :: DependencyException -> SomeException Source # fromException :: SomeException -> Maybe DependencyException Source # displayException :: DependencyException -> String Source # backtraceDesired :: DependencyException -> Bool Source #
Show DependencyException Source # |
Instance details Defined in Test.Tasty.Run Methods showsPrec :: Int -> DependencyException -> ShowS Source # show :: DependencyException -> String Source # showList :: [DependencyException] -> ShowS Source #

# Options

suiteOptions :: [Ingredient] -> TestTree -> [OptionDescription] Source #

All the options relevant for this test suite. This includes the options for the test tree and ingredients, and the core options.

Since: 0.4

coreOptions :: [OptionDescription] Source #

The list of all core options, i.e. the options not specific to any provider or ingredient, but to tasty itself. Currently contains `TestPattern` and `Timeout`.

Since: 0.1

## Patterns

type Path = Seq String Source #

Since: 1.2

newtype TestPattern Source #

Since: 1.0

Constructors

TestPattern (Maybe Expr) | Since: 1.1

#### Instances

Instances details

Show TestPattern Source # | Since: 1.1
Instance details Defined in Test.Tasty.Patterns Methods showsPrec :: Int -> TestPattern -> ShowS Source # show :: TestPattern -> String Source # showList :: [TestPattern] -> ShowS Source #
Eq TestPattern Source # | Since: 1.1
Instance details Defined in Test.Tasty.Patterns Methods (==) :: TestPattern -> TestPattern -> Bool Source # (/=) :: TestPattern -> TestPattern -> Bool Source #
IsOption TestPattern Source # | Since tasty-1.5, this option can be specified multiple times on the command line. Only the tests matching all given patterns will be selected.
Instance details Defined in Test.Tasty.Patterns Methods defaultValue :: TestPattern Source # parseValue :: String -> Maybe TestPattern Source # optionName :: Tagged TestPattern String Source # optionHelp :: Tagged TestPattern String Source # showDefaultValue :: TestPattern -> Maybe String Source # optionCLParser :: Parser TestPattern Source #

parseExpr :: String -> Maybe Expr Source #

Since: 1.2

parseTestPattern :: String -> Maybe TestPattern Source #

Since: 1.0

noPattern :: TestPattern Source #

Since: 1.0

exprMatches :: Expr -> Path -> Bool Source #

Since: 1.2

testPatternMatches :: TestPattern -> Path -> Bool Source #

Since: 1.0

# Utilities

installSignalHandlers :: IO () Source #

Install signal handlers so that e.g. the cursor is restored if the test suite is killed by SIGTERM. Upon a signal, a `SignalException` will be thrown to the thread that has executed this action.

This function is called automatically from the `defaultMain*` family of functions. You only need to call it explicitly if you call `tryIngredients` yourself.

This function does nothing when POSIX signals are not supported.

Since: 1.2.1

timed :: IO a -> IO (Time, a) Source #

Measure the time taken by an `IO` action to run.

Since: 1.2.2

forceElements :: [a] -> () Source #

Force elements of a list (https://ro-che.info/articles/2015-05-28-force-list).

Since: 1.0.1

formatMessage :: String -> IO String Source #

Catch possible exceptions that may arise when evaluating a string. For normal (total) strings, this is a no-op.

This function should be used to display messages generated by the test suite (such as test result descriptions).

See e.g. https://github.com/UnkindPartition/tasty/issues/25.

Since: 0.10.1

newtype SignalException Source #

This exception is thrown when the program receives a signal, assuming `installSignalHandlers` was called.

The `CInt` field contains the signal number, as in `Signal`. We don't use that type synonym, however, because it's not available on non-UNIXes.

Since: 1.2.1

Constructors

SignalException CInt |

#### Instances

Instances details

Exception SignalException Source # |
Instance details Defined in Test.Tasty.Runners.Utils Methods toException :: SignalException -> SomeException Source # fromException :: SomeException -> Maybe SignalException Source # displayException :: SignalException -> String Source # backtraceDesired :: SignalException -> Bool Source #
Show SignalException Source # |
Instance details Defined in Test.Tasty.Runners.Utils Methods showsPrec :: Int -> SignalException -> ShowS Source # show :: SignalException -> String Source # showList :: [SignalException] -> ShowS Source #

getTime :: IO Time Source #

Get monotonic time.

Warning: This is not the system time, but a monotonically increasing time that facilitates reliable measurement of time differences.

Since: 1.2.2