Skip to content

Commit

Permalink
Merge branch 'master' of github.com:batterseapower/test-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
batterseapower committed Jan 27, 2012
2 parents ba09f9c + dcb27aa commit 9c3126c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
16 changes: 12 additions & 4 deletions core/Test/Framework/Runners/Console.hs
Expand Up @@ -71,8 +71,11 @@ optionsDescription = [
(NoArg (mempty { ropt_xml_nested = Just True })) (NoArg (mempty { ropt_xml_nested = Just True }))
"use nested testsuites to represent groups in JUnit XML (not standards compliant)", "use nested testsuites to represent groups in JUnit XML (not standards compliant)",
Option [] ["plain"] Option [] ["plain"]
(NoArg (mempty { ropt_plain_output = Just True })) (NoArg (mempty { ropt_color_mode = Just ColorNever }))
"do not use any ANSI terminal features to display the test run", "do not use any ANSI terminal features to display the test run",
Option [] ["color"]
(NoArg (mempty { ropt_color_mode = Just ColorAlways }))
"use ANSI terminal features to display the test run",
Option [] ["hide-successes"] Option [] ["hide-successes"]
(NoArg (mempty { ropt_hide_successes = Just True })) (NoArg (mempty { ropt_hide_successes = Just True }))
"hide sucessful tests, and only show failures" "hide sucessful tests, and only show failures"
Expand Down Expand Up @@ -123,9 +126,14 @@ defaultMainWithOpts tests ropts = do


-- Get a lazy list of the test results, as executed in parallel -- Get a lazy list of the test results, as executed in parallel
running_tests <- runTests ropts' tests running_tests <- runTests ropts' tests


isplain <- case unK $ ropt_color_mode ropts' of
ColorAuto -> not `fmap` hIsTerminalDevice stdout
ColorNever -> return True
ColorAlways -> return False

-- Show those test results to the user as we get them -- Show those test results to the user as we get them
fin_tests <- showRunTestsTop (unK $ ropt_plain_output ropts') (unK $ ropt_hide_successes ropts') running_tests fin_tests <- showRunTestsTop isplain (unK $ ropt_hide_successes ropts') running_tests
let test_statistics' = gatherStatistics fin_tests let test_statistics' = gatherStatistics fin_tests


-- Output XML report (if requested) -- Output XML report (if requested)
Expand All @@ -146,6 +154,6 @@ completeRunnerOptions ro = RunnerOptions {
ropt_test_patterns = K $ ropt_test_patterns ro `orElse` mempty, ropt_test_patterns = K $ ropt_test_patterns ro `orElse` mempty,
ropt_xml_output = K $ ropt_xml_output ro `orElse` Nothing, ropt_xml_output = K $ ropt_xml_output ro `orElse` Nothing,
ropt_xml_nested = K $ ropt_xml_nested ro `orElse` False, ropt_xml_nested = K $ ropt_xml_nested ro `orElse` False,
ropt_plain_output = K $ ropt_plain_output 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
} }
2 changes: 1 addition & 1 deletion core/Test/Framework/Runners/Console/Run.hs
Expand Up @@ -18,7 +18,7 @@ import System.IO


import Text.PrettyPrint.ANSI.Leijen import Text.PrettyPrint.ANSI.Leijen


import Data.Monoid import Data.Monoid (mempty)


import Control.Arrow (second, (&&&)) import Control.Arrow (second, (&&&))
import Control.Monad (unless) import Control.Monad (unless)
Expand Down
7 changes: 4 additions & 3 deletions core/Test/Framework/Runners/Options.hs
Expand Up @@ -6,6 +6,7 @@ import Test.Framework.Runners.TestPattern


import Data.Monoid import Data.Monoid


data ColorMode = ColorAuto | ColorNever | ColorAlways


type RunnerOptions = RunnerOptions' Maybe type RunnerOptions = RunnerOptions' Maybe
type CompleteRunnerOptions = RunnerOptions' K type CompleteRunnerOptions = RunnerOptions' K
Expand All @@ -15,7 +16,7 @@ data RunnerOptions' f = RunnerOptions {
ropt_test_patterns :: f [TestPattern], ropt_test_patterns :: f [TestPattern],
ropt_xml_output :: f (Maybe FilePath), ropt_xml_output :: f (Maybe FilePath),
ropt_xml_nested :: f Bool, ropt_xml_nested :: f Bool,
ropt_plain_output :: f Bool, ropt_color_mode :: f ColorMode,
ropt_hide_successes :: f Bool ropt_hide_successes :: f Bool
} }


Expand All @@ -26,7 +27,7 @@ instance Monoid (RunnerOptions' Maybe) where
ropt_test_patterns = Nothing, ropt_test_patterns = Nothing,
ropt_xml_output = Nothing, ropt_xml_output = Nothing,
ropt_xml_nested = Nothing, ropt_xml_nested = Nothing,
ropt_plain_output = Nothing, ropt_color_mode = Nothing,
ropt_hide_successes = Nothing ropt_hide_successes = Nothing
} }


Expand All @@ -36,6 +37,6 @@ instance Monoid (RunnerOptions' Maybe) where
ropt_test_patterns = mappendBy ropt_test_patterns ro1 ro2, ropt_test_patterns = mappendBy ropt_test_patterns ro1 ro2,
ropt_xml_output = mappendBy ropt_xml_output ro1 ro2, ropt_xml_output = mappendBy ropt_xml_output ro1 ro2,
ropt_xml_nested = getLast (mappendBy (Last . ropt_xml_nested) ro1 ro2), ropt_xml_nested = getLast (mappendBy (Last . ropt_xml_nested) ro1 ro2),
ropt_plain_output = getLast (mappendBy (Last . ropt_plain_output) 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)
} }
2 changes: 1 addition & 1 deletion core/test-framework.cabal
@@ -1,5 +1,5 @@
Name: test-framework Name: test-framework
Version: 0.4.2.0 Version: 0.4.2.1
Cabal-Version: >= 1.2.3 Cabal-Version: >= 1.2.3
Category: Testing Category: Testing
Synopsis: Framework for running and organising tests, with HUnit and QuickCheck support Synopsis: Framework for running and organising tests, with HUnit and QuickCheck support
Expand Down
2 changes: 1 addition & 1 deletion hunit/Test/Framework/Providers/HUnit.hs
Expand Up @@ -47,7 +47,7 @@ data TestCaseResult = TestCasePassed
instance Show TestCaseResult where instance Show TestCaseResult where
show result = case result of show result = case result of
TestCasePassed -> "OK" TestCasePassed -> "OK"
TestCaseFailed message -> "Failed: " ++ message TestCaseFailed message -> message
TestCaseError message -> "ERROR: " ++ message TestCaseError message -> "ERROR: " ++ message


testCaseSucceeded :: TestCaseResult -> Bool testCaseSucceeded :: TestCaseResult -> Bool
Expand Down

0 comments on commit 9c3126c

Please sign in to comment.