test-framework 0.6 → 0.6.1
raw patch · 3 files changed
+29/−5 lines, 3 files
Files
- Test/Framework/Runners/Console.hs +22/−1
- Test/Framework/Runners/Options.hs +6/−3
- test-framework.cabal +1/−1
Test/Framework/Runners/Console.hs view
@@ -14,6 +14,7 @@ import Test.Framework.Seed import Test.Framework.Utilities +import Control.Monad (when) import System.Console.GetOpt import System.Environment import System.Exit@@ -64,6 +65,9 @@ Option [] ["no-timeout"] (NoArg (mempty { ropt_test_options = Just (mempty { topt_timeout = Just Nothing }) })) "specifies that tests should be run without a timeout, by default",+ Option ['l'] ["list-tests"]+ (NoArg (mempty { ropt_list_only = Just True }))+ "list available tests but don't run any; useful to guide subsequent --select-tests", Option ['t'] ["select-tests"] (ReqArg (\t -> mempty { ropt_test_patterns = Just [read t] }) "TEST-PATTERN") "only tests that match at least one glob pattern given by an instance of this argument will be run",@@ -127,6 +131,10 @@ defaultMainWithOpts tests ropts = do let ropts' = completeRunnerOptions ropts + when (unK$ ropt_list_only ropts') $ do + putStr $ listTests tests+ exitSuccess+ -- Get a lazy list of the test results, as executed in parallel running_tests <- runTests ropts' tests @@ -149,7 +157,19 @@ then ExitSuccess else ExitFailure 1 +-- | Print out a list of available tests.+listTests :: [Test] -> String+listTests tests = "\ntest-framework: All available tests:\n"+++ "====================================\n"++ + concat (map (++"\n") (concatMap (showTest "") tests))+ where + showTest :: String -> Test -> [String]+ showTest path (Test name _testlike) = [" "++path ++ name]+ showTest path (TestGroup name tests) = concatMap (showTest (path++":"++name)) tests+ showTest path (PlusTestOptions _ test) = showTest path test+ showTest path (BuildTest build) = [] + completeRunnerOptions :: RunnerOptions -> CompleteRunnerOptions completeRunnerOptions ro = RunnerOptions { ropt_threads = K $ ropt_threads ro `orElse` processorCount,@@ -158,5 +178,6 @@ ropt_xml_output = K $ ropt_xml_output ro `orElse` Nothing, ropt_xml_nested = K $ ropt_xml_nested ro `orElse` False, ropt_color_mode = K $ ropt_color_mode ro `orElse` ColorAuto,- ropt_hide_successes = K $ ropt_hide_successes ro `orElse` False+ ropt_hide_successes = K $ ropt_hide_successes ro `orElse` False,+ ropt_list_only = K $ ropt_list_only ro `orElse` False }
Test/Framework/Runners/Options.hs view
@@ -17,7 +17,8 @@ ropt_xml_output :: f (Maybe FilePath), ropt_xml_nested :: f Bool, ropt_color_mode :: f ColorMode,- ropt_hide_successes :: f Bool+ ropt_hide_successes :: f Bool,+ ropt_list_only :: f Bool } instance Monoid (RunnerOptions' Maybe) where@@ -28,7 +29,8 @@ ropt_xml_output = Nothing, ropt_xml_nested = Nothing, ropt_color_mode = Nothing,- ropt_hide_successes = Nothing+ ropt_hide_successes = Nothing,+ ropt_list_only = Nothing } mappend ro1 ro2 = RunnerOptions {@@ -38,5 +40,6 @@ ropt_xml_output = mappendBy ropt_xml_output ro1 ro2, ropt_xml_nested = getLast (mappendBy (Last . ropt_xml_nested) ro1 ro2), ropt_color_mode = getLast (mappendBy (Last . ropt_color_mode) ro1 ro2),- ropt_hide_successes = getLast (mappendBy (Last . ropt_hide_successes) ro1 ro2)+ ropt_hide_successes = getLast (mappendBy (Last . ropt_hide_successes) ro1 ro2),+ ropt_list_only = getLast (mappendBy (Last . ropt_list_only) ro1 ro2) }
test-framework.cabal view
@@ -1,5 +1,5 @@ Name: test-framework-Version: 0.6+Version: 0.6.1 Cabal-Version: >= 1.2.3 Category: Testing Synopsis: Framework for running and organising tests, with HUnit and QuickCheck support