Cabal-3.10.1.0: A framework for packaging Haskell software

Copyright | Thomas Tuegel 2010
License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Distribution.TestSuite

Description

This module defines the detailed test suite interface which makes it possible to expose individual tests to Cabal or other test agents.

Synopsis

- data TestInstance = TestInstance {
  - run :: IO Progress
  - name :: String
  - tags :: [String]
  - options :: [OptionDescr]
  - setOption :: String -> String -> Either String TestInstance
  }
- data OptionDescr = OptionDescr {
  - optionName :: String
  - optionDescription :: String
  - optionType :: OptionType
  - optionDefault :: Maybe String
  }
- data OptionType
  - = OptionFile {
    - optionFileMustExist :: Bool
    - optionFileIsDir :: Bool
    - optionFileExtensions :: [String]
    }
  - | OptionString {
    - optionStringMultiline :: Bool
    }
  - | OptionNumber {
    - optionNumberIsInt :: Bool
    - optionNumberBounds :: (Maybe String, Maybe String)
    }
  - | OptionBool
  - | OptionEnum [String]
  - | OptionSet [String]
  - | OptionRngSeed
- data Test
  - = Test TestInstance
  - | Group {
    - groupName :: String
    - concurrently :: Bool
    - groupTests :: [Test]
    }
  - | ExtraOptions [OptionDescr] Test
- type Options = [(String, String)]
- data Progress
  - = Finished Result
  - | Progress String (IO Progress)
- data Result
  - = Pass
  - | Fail String
  - | Error String
- testGroup :: String -> [Test] -> Test

# Documentation

data TestInstance Source #

Constructors

TestInstance |

Fields

- run :: IO Progress

  Perform the test.

- name :: String

  A name for the test, unique within a test suite.

- tags :: [String]

  Users can select groups of tests by their tags.

- options :: [OptionDescr]

  Descriptions of the options recognized by this test.

- setOption :: String -> String -> Either String TestInstance

  Try to set the named option to the given value. Returns an error message if the option is not supported or the value could not be correctly parsed; otherwise, a `TestInstance` with the option set to the given value is returned.

data OptionDescr Source #

Constructors

OptionDescr |

Fields

- optionName :: String
- optionDescription :: String

  A human-readable description of the option to guide the user setting it.

- optionType :: OptionType
- optionDefault :: Maybe String

#### Instances

Instances details

Read OptionDescr Source # |
Instance details Defined in Distribution.TestSuite Methods readsPrec :: Int -> ReadS OptionDescr Source # readList :: ReadS [OptionDescr] Source # readPrec :: ReadPrec OptionDescr Source # readListPrec :: ReadPrec [OptionDescr] Source #
Show OptionDescr Source # |
Instance details Defined in Distribution.TestSuite Methods showsPrec :: Int -> OptionDescr -> ShowS Source # show :: OptionDescr -> String Source # showList :: [OptionDescr] -> ShowS Source #
Eq OptionDescr Source # |
Instance details Defined in Distribution.TestSuite Methods (==) :: OptionDescr -> OptionDescr -> Bool # (/=) :: OptionDescr -> OptionDescr -> Bool #

data OptionType Source #

Constructors

OptionFile |

Fields

- optionFileMustExist :: Bool
- optionFileIsDir :: Bool
- optionFileExtensions :: [String]

OptionString |

Fields

- optionStringMultiline :: Bool

OptionNumber |

Fields

- optionNumberIsInt :: Bool
- optionNumberBounds :: (Maybe String, Maybe String)

OptionBool |
OptionEnum [String] |
OptionSet [String] |
OptionRngSeed |

#### Instances

Instances details

Read OptionType Source # |
Instance details Defined in Distribution.TestSuite Methods readsPrec :: Int -> ReadS OptionType Source # readList :: ReadS [OptionType] Source # readPrec :: ReadPrec OptionType Source # readListPrec :: ReadPrec [OptionType] Source #
Show OptionType Source # |
Instance details Defined in Distribution.TestSuite Methods showsPrec :: Int -> OptionType -> ShowS Source # show :: OptionType -> String Source # showList :: [OptionType] -> ShowS Source #
Eq OptionType Source # |
Instance details Defined in Distribution.TestSuite Methods (==) :: OptionType -> OptionType -> Bool # (/=) :: OptionType -> OptionType -> Bool #

data Test Source #

Constructors

Test TestInstance |
Group |

Fields

- groupName :: String
- concurrently :: Bool

  If true, then children of this group may be run in parallel. Note that this setting is not inherited by children. In particular, consider a group F with "concurrently = False" that has some children, including a group T with "concurrently = True". The children of group T may be run concurrently with each other, as long as none are run at the same time as any of the direct children of group F.

- groupTests :: [Test]

ExtraOptions [OptionDescr] Test |

type Options = [(String, String)] Source #

data Progress Source #

Constructors

Finished Result |
Progress String (IO Progress) |

data Result Source #

Constructors

Pass |
Fail String |
Error String |

#### Instances

Instances details

Read Result Source # |
Instance details Defined in Distribution.TestSuite Methods readsPrec :: Int -> ReadS Result Source # readList :: ReadS [Result] Source # readPrec :: ReadPrec Result Source # readListPrec :: ReadPrec [Result] Source #
Show Result Source # |
Instance details Defined in Distribution.TestSuite Methods showsPrec :: Int -> Result -> ShowS Source # show :: Result -> String Source # showList :: [Result] -> ShowS Source #
Eq Result Source # |
Instance details Defined in Distribution.TestSuite Methods (==) :: Result -> Result -> Bool # (/=) :: Result -> Result -> Bool #

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

Create a named group of tests, which are assumed to be safe to run in parallel.