Skip to content

Commit

Permalink
Add metavar annotations to tasty's own options
Browse files Browse the repository at this point in the history
  • Loading branch information
UnkindPartition committed Feb 12, 2018
1 parent b029403 commit 8afac70
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/Test/Tasty/Ingredients/ConsoleReporter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ instance IsOption UseColor where
defaultValue = Auto
parseValue = parseUseColor
optionName = return "color"
optionHelp = return "When to use colored output. Options are 'never', 'always' and 'auto' (default: 'auto')"
optionHelp = return "When to use colored output (default: 'auto')"
optionCLParser = mkOptionCLParser $ metavar "never|always|auto"

-- | @useColor when isTerm@ decides if colors should be used,
-- where @isTerm@ indicates whether @stdout@ is a terminal device.
Expand Down
5 changes: 5 additions & 0 deletions quickcheck/Test/Tasty/QuickCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import Data.Typeable
import Data.List
import Text.Printf
import Test.QuickCheck.Random (mkQCGen)
import Options.Applicative (metavar)
import System.Random (getStdRandom, randomR)
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
Expand Down Expand Up @@ -99,13 +100,15 @@ instance IsOption QuickCheckTests where
parseValue = fmap QuickCheckTests . safeRead
optionName = return "quickcheck-tests"
optionHelp = return "Number of test cases for QuickCheck to generate"
optionCLParser = mkOptionCLParser $ metavar "NUMBER"

instance IsOption QuickCheckReplay where
defaultValue = QuickCheckReplay Nothing
-- Reads a replay int seed
parseValue v = QuickCheckReplay . Just <$> safeRead v
optionName = return "quickcheck-replay"
optionHelp = return "Random seed to use for replaying a previous test run (use same --quickcheck-max-size)"
optionCLParser = mkOptionCLParser $ metavar "SEED"

instance IsOption QuickCheckShowReplay where
defaultValue = QuickCheckShowReplay False
Expand All @@ -121,12 +124,14 @@ instance IsOption QuickCheckMaxSize where
parseValue = fmap QuickCheckMaxSize . safeRead
optionName = return "quickcheck-max-size"
optionHelp = return "Size of the biggest test cases quickcheck generates"
optionCLParser = mkOptionCLParser $ metavar "NUMBER"

instance IsOption QuickCheckMaxRatio where
defaultValue = fromIntegral $ QC.maxDiscardRatio QC.stdArgs
parseValue = fmap QuickCheckMaxRatio . safeRead
optionName = return "quickcheck-max-ratio"
optionHelp = return "Maximum number of discared tests per successful test before giving up"
optionCLParser = mkOptionCLParser $ metavar "NUMBER"

instance IsOption QuickCheckVerbose where
defaultValue = QuickCheckVerbose False
Expand Down
3 changes: 2 additions & 1 deletion quickcheck/tasty-quickcheck.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ library
exposed-modules: Test.Tasty.QuickCheck
-- other-modules:
other-extensions: GeneralizedNewtypeDeriving, DeriveDataTypeable
build-depends: base == 4.*, tagged, tasty >= 0.10.1, random, QuickCheck >= 2.7
build-depends: base == 4.*, tagged, tasty >= 0.10.1, random, QuickCheck >= 2.7,
optparse-applicative

-- hs-source-dirs:
default-language: Haskell2010
Expand Down
2 changes: 2 additions & 0 deletions smallcheck/Test/Tasty/SmallCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Test.SmallCheck.Drivers as SC
import Control.Exception
import Data.Typeable
import Data.IORef
import Options.Applicative (metavar)
import Text.Printf
#if !MIN_VERSION_base(4,8,0)
import Data.Proxy
Expand All @@ -34,6 +35,7 @@ instance IsOption SmallCheckDepth where
parseValue = fmap SmallCheckDepth . safeRead
optionName = return "smallcheck-depth"
optionHelp = return "Depth to use for smallcheck tests"
optionCLParser = mkOptionCLParser $ metavar "NUMBER"

instance IsTest (SC.Property IO) where
testOptions = return [Option (Proxy :: Proxy SmallCheckDepth)]
Expand Down
3 changes: 2 additions & 1 deletion smallcheck/tasty-smallcheck.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Library
smallcheck >= 1.0,
base >= 4 && < 5,
async,
tagged
tagged,
optparse-applicative
ghc-options: -Wall -fno-warn-orphans
default-extensions: CPP

0 comments on commit 8afac70

Please sign in to comment.