doctest-parallel-0.4: Test interactive Haskell examples

Safe Haskell | None
Language | Haskell2010

Test.DocTest.Internal.Options

Synopsis

- usage :: String
- version :: String
- ghcVersion :: String
- versionInfo :: String
- info :: String
- data Result a
  - = ResultStderr String
  - | ResultStdout String
  - | Result a
- type Warning = String
- type ModuleName = String
- data Config = Config {
  - cfgLogLevel :: LogLevel
  - cfgModules :: [ModuleName]
  - cfgThreads :: Maybe Int
  - cfgModuleConfig :: ModuleConfig
  - cfgNix :: Bool
  - cfgGhcArgs :: [String]
  }
- data ModuleConfig = ModuleConfig {
  - cfgPreserveIt :: Bool
  - cfgRandomizeOrder :: Bool
  - cfgSeed :: Maybe Int
  - cfgImplicitModuleImport :: Bool
  }
- defaultModuleConfig :: ModuleConfig
- defaultConfig :: Config
- parseLocatedModuleOptions :: ModuleName -> ModuleConfig -> [Located String] -> Either (Location, String) ModuleConfig
- parseModuleOption :: ModuleConfig -> String -> Maybe ModuleConfig
- parseOptions :: [String] -> Result Config
- parseGhcArg :: String -> Maybe String
- parseSeed :: String -> Maybe Int
- parseLogLevel :: String -> Maybe LogLevel
- parseThreads :: String -> Maybe Int
- parseSpecificFlag :: String -> String -> Maybe String
- parseFlag :: String -> (String, Maybe String)

# Documentation

usage :: String Source #

version :: String Source #

ghcVersion :: String Source #

versionInfo :: String Source #

info :: String Source #

data Result a Source #

Constructors

ResultStderr String |
ResultStdout String |
Result a |

#### Instances

Instances details

Functor Result Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods fmap :: (a -> b) -> Result a -> Result b Source # (<$) :: a -> Result b -> Result a Source #
Show a => Show (Result a) Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods showsPrec :: Int -> Result a -> ShowS Source # show :: Result a -> String Source # showList :: [Result a] -> ShowS Source #
Eq a => Eq (Result a) Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods (==) :: Result a -> Result a -> Bool Source # (/=) :: Result a -> Result a -> Bool Source #

type Warning = String Source #

type ModuleName = String Source #

data Config Source #

Constructors

Config |

Fields

- cfgLogLevel :: LogLevel

  Verbosity level.

- cfgModules :: [ModuleName]

  Module names to test. An empty list means "test all modules".

- cfgThreads :: Maybe Int

  Number of threads to use. Defaults to autodetection based on the number of cores.

- cfgModuleConfig :: ModuleConfig

  Options specific to modules

- cfgNix :: Bool

  Detect Nix build environment and try to make GHC aware of the local package being tested.

- cfgGhcArgs :: [String]

  Extra arguments passed to GHC when parsing

#### Instances

Instances details

NFData Config Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods rnf :: Config -> () Source #
Generic Config Source # |

Instance details

Defined in Test.DocTest.Internal.Options

Associated Types

type Rep Config |

Instance details

Defined in Test.DocTest.Internal.Options

type Rep Config = D1 ('MetaData "Config" "Test.DocTest.Internal.Options" "doctest-parallel-0.4-Ku6xlKqGqCgHDSZeb8KTkx" 'False) (C1 ('MetaCons "Config" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cfgLogLevel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LogLevel) :*: (S1 ('MetaSel ('Just "cfgModules") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ModuleName]) :*: S1 ('MetaSel ('Just "cfgThreads") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)))) :*: (S1 ('MetaSel ('Just "cfgModuleConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleConfig) :*: (S1 ('MetaSel ('Just "cfgNix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "cfgGhcArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [String])))))

Methods

from :: Config -> Rep Config x Source #

to :: Rep Config x -> Config Source #

Show Config Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods showsPrec :: Int -> Config -> ShowS Source # show :: Config -> String Source # showList :: [Config] -> ShowS Source #
Eq Config Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods (==) :: Config -> Config -> Bool Source # (/=) :: Config -> Config -> Bool Source #
type Rep Config Source # |

Instance details

Defined in Test.DocTest.Internal.Options

type Rep Config = D1 ('MetaData "Config" "Test.DocTest.Internal.Options" "doctest-parallel-0.4-Ku6xlKqGqCgHDSZeb8KTkx" 'False) (C1 ('MetaCons "Config" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cfgLogLevel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LogLevel) :*: (S1 ('MetaSel ('Just "cfgModules") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ModuleName]) :*: S1 ('MetaSel ('Just "cfgThreads") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)))) :*: (S1 ('MetaSel ('Just "cfgModuleConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleConfig) :*: (S1 ('MetaSel ('Just "cfgNix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "cfgGhcArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [String])))))

data ModuleConfig Source #

Constructors

ModuleConfig |

Fields

- cfgPreserveIt :: Bool

  Preserve the `it` variable between examples (default: `False`)

- cfgRandomizeOrder :: Bool

  Randomize the order in which test cases in a module are run (default: `False`)

- cfgSeed :: Maybe Int

  Initialize random number generator used to randomize test cases when `cfgRandomizeOrder` is set. If set to `Nothing`, a random seed is picked from a system RNG source on startup.

- cfgImplicitModuleImport :: Bool

  Import a module before testing it. Can be disabled to enabled to test non-exposed modules.

#### Instances

Instances details

NFData ModuleConfig Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods rnf :: ModuleConfig -> () Source #
Generic ModuleConfig Source # |

Instance details

Defined in Test.DocTest.Internal.Options

Associated Types

type Rep ModuleConfig |

Instance details

Defined in Test.DocTest.Internal.Options

type Rep ModuleConfig = D1 ('MetaData "ModuleConfig" "Test.DocTest.Internal.Options" "doctest-parallel-0.4-Ku6xlKqGqCgHDSZeb8KTkx" 'False) (C1 ('MetaCons "ModuleConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cfgPreserveIt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "cfgRandomizeOrder") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "cfgSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)) :*: S1 ('MetaSel ('Just "cfgImplicitModuleImport") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))

Methods

from :: ModuleConfig -> Rep ModuleConfig x Source #

to :: Rep ModuleConfig x -> ModuleConfig Source #

Show ModuleConfig Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods showsPrec :: Int -> ModuleConfig -> ShowS Source # show :: ModuleConfig -> String Source # showList :: [ModuleConfig] -> ShowS Source #
Eq ModuleConfig Source # |
Instance details Defined in Test.DocTest.Internal.Options Methods (==) :: ModuleConfig -> ModuleConfig -> Bool Source # (/=) :: ModuleConfig -> ModuleConfig -> Bool Source #
type Rep ModuleConfig Source # |

Instance details

Defined in Test.DocTest.Internal.Options

type Rep ModuleConfig = D1 ('MetaData "ModuleConfig" "Test.DocTest.Internal.Options" "doctest-parallel-0.4-Ku6xlKqGqCgHDSZeb8KTkx" 'False) (C1 ('MetaCons "ModuleConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cfgPreserveIt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "cfgRandomizeOrder") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "cfgSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)) :*: S1 ('MetaSel ('Just "cfgImplicitModuleImport") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))

defaultModuleConfig :: ModuleConfig Source #

defaultConfig :: Config Source #

parseLocatedModuleOptions :: ModuleName -> ModuleConfig -> [Located String] -> Either (Location, String) ModuleConfig Source #

parseModuleOption :: ModuleConfig -> String -> Maybe ModuleConfig Source #

parseOptions :: [String] -> Result Config Source #

parseGhcArg :: String -> Maybe String Source #

Parse ghc-arg argument

    >>> parseGhcArg "--ghc-arg=foobar"
    Just "foobar"

parseSeed :: String -> Maybe Int Source #

Parse seed argument

    >>> parseSeed "--seed=6"
    Just 6
    >>> parseSeed "--seeeed=6"
    Nothing

parseLogLevel :: String -> Maybe LogLevel Source #

Parse seed argument

    >>> parseLogLevel "--log-level=Debug"
    Just Debug
    >>> parseLogLevel "--log-level=debug"
    Just Debug
    >>> parseSeed "---log-level=debug"
    Nothing

parseThreads :: String -> Maybe Int Source #

Parse number of threads argument

    >>> parseThreads "-j6"
    Just 6
    >>> parseThreads "-j-2"
    Nothing
    >>> parseThreads "-jA"
    Nothing

parseSpecificFlag :: String -> String -> Maybe String Source #

Parse a specific flag with a value, or return `Nothing`

    >>> parseSpecificFlag "--foo" "foo"
    Nothing
    >>> parseSpecificFlag "--foo=" "foo"
    Nothing
    >>> parseSpecificFlag "--foo=5" "foo"
    Just "5"
    >>> parseSpecificFlag "--foo=5" "bar"
    Nothing

parseFlag :: String -> (String, Maybe String) Source #

Parse a flag into its flag and argument component.

Example:

    >>> parseFlag "--optghc=foo"
    ("--optghc",Just "foo")
    >>> parseFlag "--optghc="
    ("--optghc",Nothing)
    >>> parseFlag "--fast"
    ("--fast",Nothing)