batterseapower / test-framework

Framework for running and organising QuickCheck test properties and HUnit test cases
http://bsp.lighthouseapp.com/projects/15661-hs-test-framework
83 stars 45 forks source link

Export optionsDescription #27

Closed basvandijk closed 11 years ago

basvandijk commented 11 years ago

Hi Max,

I would like to use test-framework in a test suite where I need to specify some additional command line arguments. Moreover, I would like to use cmdtheline to handle the command line processing.

I've written a patch for cmdtheline that provides an adapter for a list of OptDescrs.

If test-framework would export it's options then I can use both packages together like in the following:

import Data.Functor                     ( (<$>) )
import Data.Maybe                       ( catMaybes )
import Data.Monoid                      ( mconcat )
import System.Console.CmdTheLine        ( Term, run, defTI )
import System.Console.CmdTheLine.GetOpt ( optDescrsTerm )
import Test.Framework                   ( defaultMainWithOpts, optionsDescription )

main :: IO ()
main = run (term, defTI)

term :: Term (IO ())
term = defaultMainWithOpts [] . mconcat . catMaybes <$>
         optDescrsTerm optionsDescription

Running it:

$ ./test --help
NAME

SYNOPSIS
       b, [OPTION]...

OPTIONS
       --maximum-generated-tests=NUMBER, -a NUMBER
           how many automated tests something like QuickCheck should try, by
           default

       --maximum-test-depth=NUMBER, -d NUMBER
           to what depth something like SmallCheck should test the properties,
           by default

       --threads=NUMBER, -j NUMBER
           number of threads to use to run tests

       --list-tests, -l
           list available tests but don't run any; useful to guide subsequent
           --select-tests

       --timeout=NUMBER, -o NUMBER
           how many seconds a test should be run for before giving up, by
           default

       --maximum-test-size=NUMBER, -s NUMBER
           to what size something like QuickCheck should test the properties,
           by default

       --select-tests=TEST-PATTERN, -t TEST-PATTERN
           only tests that match at least one glob pattern given by an
           instance of this argument will be run

       --color
           use ANSI terminal features to display the test run

       --help
           show this help message

       --help[=FMT] (default=pager)
           Show this help in format FMT (pager, plain, or groff).

       --hide-successes
           hide sucessful tests, and only show failures

       --jxml=FILE
           write a JUnit XML summary of the output to FILE

       --jxml-nested
           use nested testsuites to represent groups in JUnit XML (not
           standards compliant)

       --maximum-unsuitable-generated-tests=NUMBER
           how many unsuitable candidate tests something like QuickCheck
           should endure before giving up, by default

       --no-timeout
           specifies that tests should be run without a timeout, by default

       --plain
           do not use any ANSI terminal features to display the test run

       --test-seed=NUMBER|random
           default seed for test random number generator
batterseapower commented 11 years ago

Looks fine to me! Released as v0.6.2

basvandijk commented 11 years ago

Thanks!