| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Tasty.Discover
Synopsis
- class Tasty a where
- data TastyInfo
- newtype SkipTest = SkipTest Bool
- data Flavored a = Flavored {
- flavoring :: TestTree -> TestTree
- unFlavored :: a
- flavored :: (TestTree -> TestTree) -> a -> Flavored a
- name :: String -> TastyInfo
- description :: String -> TastyInfo
- nameOf :: TastyInfo -> String
- descriptionOf :: TastyInfo -> String
- skip :: TestTree -> TestTree
- applySkips :: TestTree -> TestTree
- platform :: String -> TestTree -> TestTree
- evaluatePlatformExpression :: String -> String -> Bool
Documentation
Instances
Newtype wrapper for skip test option.
This option type integrates with Tasty's option system to control whether
tests should be skipped. When set to SkipTest True, tests will show as
[SKIPPED] in yellow in the test output and won't actually execute.
Used internally by the skip function and Flavored type to implement
test skipping functionality.
Instances
| Generic SkipTest Source # | |||||
Defined in Test.Tasty.Discover.Internal.Config Associated Types
| |||||
| Show SkipTest Source # | |||||
| Eq SkipTest Source # | |||||
| IsOption SkipTest Source # | |||||
Defined in Test.Tasty.Discover.Internal.Config Methods parseValue :: String -> Maybe SkipTest # optionName :: Tagged SkipTest String # optionHelp :: Tagged SkipTest String # showDefaultValue :: SkipTest -> Maybe String # | |||||
| type Rep SkipTest Source # | |||||
Defined in Test.Tasty.Discover.Internal.Config | |||||
A general-purpose wrapper for transforming TestTrees generated by tasty_ functions.
The Flavored type allows you to apply transformations to test trees before they are added to the test suite. This enables applying various options and modifications such as skipping tests, setting timeouts, adding metadata, grouping, etc.
Example usage:
-- Skip a test
tasty_skipThis :: Flavored Property
tasty_skipThis = flavored skip $ property $ do
-- This test will be skipped
H.failure
Constructors
| Flavored | |
Fields
| |
flavored :: (TestTree -> TestTree) -> a -> Flavored a Source #
Create a Flavored wrapper with a specific transformation function.
flavored f a applies transformation f to the TestTree generated from a.
description :: String -> TastyInfo Source #
descriptionOf :: TastyInfo -> String Source #
skip :: TestTree -> TestTree Source #
Mark a test tree to be skipped by setting the SkipTest option to True.
Usage guidelines: see the Guidelines for using section (skip and platformskipPlatform).
In short, for tasty_ tests prefer flavored skip to let the outer Tasty instance
short-circuit at the TestTree level. Direct skip on a pre-built tree applies the option
to the subtree; the test can still observe SkipTest via askOption.
Examples: @ -- Direct usage on a TestTree (the test can read SkipTest via askOption) test_directSkip :: TestTree test_directSkip = skip $ testCase "will be skipped" $ pure ()
- - Preferred for tasty_ tests: apply at the right stage using Flavored tasty_skipProperty :: Flavored Property tasty_skipProperty = flavored skip $ property $ do
- - This property will be skipped H.failure @
applySkips :: TestTree -> TestTree Source #
platform :: String -> TestTree -> TestTree Source #
Conditionally run a test based on a platform expression.
Usage guidelines, syntax, and examples: see the Guidelines for using
section (skip and platformskipPlatform).
The expression supports logical operations with platform names: - Platform names: "linux", "darwin", "mingw32", "windows", "unix" - Negation: "!platform" (not on platform) - Conjunction: "platform1 & platform2" (on both platforms) - Disjunction: "platform1 | platform2" (on either platform) - Parentheses: "(platform1 | platform2) & !platform3"
Examples: @ -- Only on Linux test_linuxOnly :: TestTree test_linuxOnly = platform "linux" $ testCase "Linux only" $ pure ()
- - Not on Windows or macOS test_notWinMac :: TestTree test_notWinMac = platform "!windows & !darwin" $ testCase "Unix-like only" $ pure ()
- - On Linux or macOS but not Windows test_unixLike :: TestTree test_unixLike = platform "(linux | darwin) & !windows" $ testCase "Unix-like" $ pure () @
evaluatePlatformExpression :: String -> String -> Bool Source #
Evaluate a platform expression against a given platform string.
Inputs:
- The first argument is the platform expression (e.g. "linux | darwin", "!windows").
- The second argument is the current platform, typically System.Info.os (e.g. "linux", "darwin", "mingw32").
Semantics (result is True when the test should run):
- Supported platform names: "linux", "darwin", "mingw32", "windows" (alias for "mingw32"), and "unix" (alias for "linux | darwin").
- Supported operators: NOT !, AND &, OR |.
- Unknown simple names evaluate to False (do not run).
- Malformed or empty expressions evaluate to True (default to running).
Malformed includes the presence of operator characters without a valid parse.
- Parentheses characters ( and ) are tokenized but grouping is not currently implemented;
using parentheses in the expression will cause it to be treated as malformed and therefore
default to True (run). Prefer composing with & and | without parentheses.
Examples:
evaluatePlatformExpression "linux" "linux" == True evaluatePlatformExpression "linux" "darwin" == False evaluatePlatformExpression "!windows" "mingw32" == False evaluatePlatformExpression "linux|darwin" "darwin" == True evaluatePlatformExpression "unix" "darwin" == True -- alias for linux|darwin evaluatePlatformExpression "unknown" "linux" == False -- unknown simple name evaluatePlatformExpression "" "linux" == True -- empty -> run