tasty-discover-5.2.0: Test discovery for the tasty framework.
Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Discover

Synopsis

Documentation

class Tasty a where Source #

Methods

tasty :: TastyInfo -> a -> IO TestTree Source #

Instances

Instances details
Tasty TestTree Source # 
Instance details

Defined in Test.Tasty.Discover

Tasty (IO TestTree) Source # 
Instance details

Defined in Test.Tasty.Discover

Tasty (IO [TestTree]) Source # 
Instance details

Defined in Test.Tasty.Discover

Tasty a => Tasty (Flavored a) Source # 
Instance details

Defined in Test.Tasty.Discover

Tasty [TestTree] Source # 
Instance details

Defined in Test.Tasty.Discover

data TastyInfo Source #

Instances

Instances details
Monoid TastyInfo Source # 
Instance details

Defined in Test.Tasty.Discover.TastyInfo

Semigroup TastyInfo Source # 
Instance details

Defined in Test.Tasty.Discover.TastyInfo

Generic TastyInfo Source # 
Instance details

Defined in Test.Tasty.Discover.TastyInfo

Associated Types

type Rep TastyInfo 
Instance details

Defined in Test.Tasty.Discover.TastyInfo

type Rep TastyInfo = D1 ('MetaData "TastyInfo" "Test.Tasty.Discover.TastyInfo" "tasty-discover-5.2.0-6BjWLNiFeo66Uowhh0b9lW" 'False) (C1 ('MetaCons "TastyInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last String)) :*: S1 ('MetaSel ('Just "description") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last String))))
Show TastyInfo Source # 
Instance details

Defined in Test.Tasty.Discover.TastyInfo

Eq TastyInfo Source # 
Instance details

Defined in Test.Tasty.Discover.TastyInfo

type Rep TastyInfo Source # 
Instance details

Defined in Test.Tasty.Discover.TastyInfo

type Rep TastyInfo = D1 ('MetaData "TastyInfo" "Test.Tasty.Discover.TastyInfo" "tasty-discover-5.2.0-6BjWLNiFeo66Uowhh0b9lW" 'False) (C1 ('MetaCons "TastyInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last String)) :*: S1 ('MetaSel ('Just "description") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last String))))

newtype SkipTest Source #

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.

Constructors

SkipTest Bool 

Instances

Instances details
Generic SkipTest Source # 
Instance details

Defined in Test.Tasty.Discover.Internal.Config

Associated Types

type Rep SkipTest 
Instance details

Defined in Test.Tasty.Discover.Internal.Config

type Rep SkipTest = D1 ('MetaData "SkipTest" "Test.Tasty.Discover.Internal.Config" "tasty-discover-5.2.0-6BjWLNiFeo66Uowhh0b9lW" 'True) (C1 ('MetaCons "SkipTest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

Methods

from :: SkipTest -> Rep SkipTest x #

to :: Rep SkipTest x -> SkipTest #

Show SkipTest Source # 
Instance details

Defined in Test.Tasty.Discover.Internal.Config

Eq SkipTest Source # 
Instance details

Defined in Test.Tasty.Discover.Internal.Config

IsOption SkipTest Source # 
Instance details

Defined in Test.Tasty.Discover.Internal.Config

type Rep SkipTest Source # 
Instance details

Defined in Test.Tasty.Discover.Internal.Config

type Rep SkipTest = D1 ('MetaData "SkipTest" "Test.Tasty.Discover.Internal.Config" "tasty-discover-5.2.0-6BjWLNiFeo66Uowhh0b9lW" 'True) (C1 ('MetaCons "SkipTest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

data Flavored a Source #

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

Instances

Instances details
Tasty a => Tasty (Flavored a) Source # 
Instance details

Defined in Test.Tasty.Discover

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.

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 skip and platform section (skipPlatform). 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 @

platform :: String -> TestTree -> TestTree Source #

Conditionally run a test based on a platform expression.

Usage guidelines, syntax, and examples: see the Guidelines for using skip and platform section (skipPlatform).

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