doctest-parallel-0.4: Test interactive Haskell examples

Safe Haskell | None
Language | Haskell2010

Test.DocTest.Internal.Runner

Synopsis

- data FromSetup
  - = FromSetup
  - | NotFromSetup
- data Summary = Summary {
  - sExamples :: Int
  - sTried :: Int
  - sErrors :: Int
  - sFailures :: Int
  }
- emptySummary :: Summary
- runModules :: (?verbosity :: LogLevel) => ModuleConfig -> Maybe Int -> Bool -> [String] -> [String] -> [ModuleName] -> IO Summary
- count :: Module [Located DocTest] -> Int
- type Report = StateT ReportState IO
- data ReportState = ReportState {
  - reportStateCount :: Int
  - reportStateInteractive :: Bool
  - reportStateSummary :: Summary
  }
- report :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => LogLevel -> String -> Report ()
- report_ :: (?verbosity :: LogLevel) => LogLevel -> String -> Report ()
- overwrite :: String -> Report ()
- shuffle :: Int -> [a] -> [a]
- runModule :: ModuleConfig -> Bool -> MVar () -> [String] -> Chan (ThreadId, ReportUpdate) -> ModuleName -> Ghc ()
- data ReportUpdate
  - = UpdateSuccess FromSetup
  - | UpdateModuleParsed ModuleName Int
  - | UpdateFailure FromSetup Location Expression [String]
  - | UpdateError FromSetup Location Expression String
  - | UpdateModuleDone
  - | UpdateInternalError ModuleName SomeException
  - | UpdateImportError ModuleName (Either String String)
  - | UpdateOptionError Location String
  - | UpdateLog LogLevel String
- makeThreadPool :: Int -> [String] -> (Chan (ThreadId, ReportUpdate) -> ModuleName -> Ghc ()) -> IO (Chan ModuleName, Chan (ThreadId, ReportUpdate))
- reportModuleParsed :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => ModuleName -> Int -> Report ()
- reportFailure :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => FromSetup -> Location -> Expression -> [String] -> Report ()
- reportError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => FromSetup -> Location -> Expression -> String -> Report ()
- reportOptionError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => Location -> String -> Report ()
- reportInternalError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => ModuleName -> SomeException -> Report ()
- reportImportError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => ModuleName -> Either String String -> Report ()
- reportSuccess :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => FromSetup -> Report ()
- updateSummary :: FromSetup -> Summary -> Report ()
- reportProgress :: (?verbosity :: LogLevel) => Report ()
- runTestGroup :: FromSetup -> Bool -> Interpreter -> IO () -> (ReportUpdate -> IO ()) -> [Located DocTest] -> IO Bool
- runExampleGroup :: FromSetup -> Bool -> Interpreter -> (ReportUpdate -> IO ()) -> [Located Interaction] -> IO Bool
- safeEvalWith :: Bool -> Interpreter -> String -> IO (Either String String)

# Documentation

data FromSetup Source #

Whether an "example" is part of setup block

Constructors

FromSetup |
NotFromSetup |

data Summary Source #

Summary of a test run.

Constructors

Summary |

Fields

- sExamples :: Int

  Total number of lines of examples (excluding setup)

- sTried :: Int

  Executed sTried lines so far

- sErrors :: Int

  Couldn't execute sErrors examples

- sFailures :: Int

  Got unexpected output for sFailures examples

#### Instances

Instances details

Monoid Summary Source # | Sum up summaries.
Instance details Defined in Test.DocTest.Internal.Runner Methods mempty :: Summary Source # mappend :: Summary -> Summary -> Summary Source # mconcat :: [Summary] -> Summary Source #
Semigroup Summary Source # |
Instance details Defined in Test.DocTest.Internal.Runner Methods (<>) :: Summary -> Summary -> Summary Source # sconcat :: NonEmpty Summary -> Summary Source # stimes :: Integral b => b -> Summary -> Summary Source #
Show Summary Source # | Format a summary.
Instance details Defined in Test.DocTest.Internal.Runner Methods showsPrec :: Int -> Summary -> ShowS Source # show :: Summary -> String Source # showList :: [Summary] -> ShowS Source #
Eq Summary Source # |
Instance details Defined in Test.DocTest.Internal.Runner Methods (==) :: Summary -> Summary -> Bool Source # (/=) :: Summary -> Summary -> Bool Source #

emptySummary :: Summary Source #

runModules Source #

Arguments

:: (?verbosity :: LogLevel) |
=> ModuleConfig | Configuration options specific to module
-> Maybe Int | Number of threads to use. Defaults to `getNumProcessors`.
-> Bool | Implicit Prelude
-> [String] | Arguments passed to the GHC for parsing
-> [String] | Arguments passed to the GHCi process.
-> [ModuleName] | Modules under test
-> IO Summary |

Run all examples from a list of modules.

count :: Module [Located DocTest] -> Int Source #

Count number of expressions in given module.

type Report = StateT ReportState IO Source #

A monad for generating test reports.

data ReportState Source #

Constructors

ReportState |

Fields

- reportStateCount :: Int

  characters on the current line

- reportStateInteractive :: Bool

  should intermediate results be printed?

- reportStateSummary :: Summary

  test summary

report :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => LogLevel -> String -> Report () Source #

Add output to the report.

report_ :: (?verbosity :: LogLevel) => LogLevel -> String -> Report () Source #

Add intermediate output to the report.

This will be overwritten by subsequent calls to `report`/`report_`. Intermediate out may not contain any newlines.

overwrite :: String -> Report () Source #

Add output to the report, overwrite any intermediate out.

shuffle :: Int -> [a] -> [a] Source #

Shuffle a list given a seed for an RNG

runModule Source #

Arguments

:: ModuleConfig |
-> Bool |
-> MVar () | GHC lock
-> [String] | Eval GHCi arguments
-> Chan (ThreadId, ReportUpdate) |
-> ModuleName |
-> Ghc () |

Run all examples from given module.

data ReportUpdate Source #

Constructors

UpdateSuccess FromSetup | Test succeeded
UpdateModuleParsed ModuleName Int | Parsed module, found n examples
UpdateFailure FromSetup Location Expression [String] | Test failed with unexpected result
UpdateError FromSetup Location Expression String | Test failed with an error
UpdateModuleDone | All examples tested in module
UpdateInternalError ModuleName SomeException | Exception caught while executing internal code
UpdateImportError ModuleName (Either String String) | Could not import module
UpdateOptionError Location String | Unrecognized flag in module specific option
UpdateLog LogLevel String | Unstructured message

makeThreadPool :: Int -> [String] -> (Chan (ThreadId, ReportUpdate) -> ModuleName -> Ghc ()) -> IO (Chan ModuleName, Chan (ThreadId, ReportUpdate)) Source #

reportModuleParsed :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => ModuleName -> Int -> Report () Source #

reportFailure :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => FromSetup -> Location -> Expression -> [String] -> Report () Source #

reportError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => FromSetup -> Location -> Expression -> String -> Report () Source #

reportOptionError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => Location -> String -> Report () Source #

reportInternalError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => ModuleName -> SomeException -> Report () Source #

reportImportError :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => ModuleName -> Either String String -> Report () Source #

reportSuccess :: (?verbosity :: LogLevel, ?threadId :: ThreadId) => FromSetup -> Report () Source #

updateSummary :: FromSetup -> Summary -> Report () Source #

reportProgress :: (?verbosity :: LogLevel) => Report () Source #

runTestGroup :: FromSetup -> Bool -> Interpreter -> IO () -> (ReportUpdate -> IO ()) -> [Located DocTest] -> IO Bool Source #

Run given test group.

The interpreter state is zeroed with `:reload` first. This means that you can reuse the same `Interpreter` for several test groups.

runExampleGroup :: FromSetup -> Bool -> Interpreter -> (ReportUpdate -> IO ()) -> [Located Interaction] -> IO Bool Source #

Execute all expressions from given example in given `Interpreter` and verify the output.

safeEvalWith :: Bool -> Interpreter -> String -> IO (Either String String) Source #