module Test.Framework.Runners.XML (
produceReport
) where
import Test.Framework.Runners.Statistics ( testCountTotal, TestStatistics(..) )
import Test.Framework.Runners.Core ( FinishedTest )
import Test.Framework.Runners.XML.JUnitWriter ( RunDescription(..), serialize )
import Data.Time.Format ( formatTime )
import Data.Time.LocalTime ( getZonedTime )
import Data.Time.Format ( defaultTimeLocale )
import Network.HostName ( getHostName )
produceReport :: Bool -> TestStatistics -> [FinishedTest] -> IO String
produceReport :: Bool -> TestStatistics -> [FinishedTest] -> IO String
produceReport Bool
nested TestStatistics
test_statistics [FinishedTest]
fin_tests = (RunDescription -> String) -> IO RunDescription -> IO String
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Bool -> RunDescription -> String
serialize Bool
nested) (IO RunDescription -> IO String) -> IO RunDescription -> IO String
forall a b. (a -> b) -> a -> b
$ TestStatistics -> [FinishedTest] -> IO RunDescription
mergeResults TestStatistics
test_statistics [FinishedTest]
fin_tests
mergeResults :: TestStatistics -> [FinishedTest] -> IO RunDescription
mergeResults :: TestStatistics -> [FinishedTest] -> IO RunDescription
mergeResults TestStatistics
test_statistics [FinishedTest]
fin_tests = do
host <- IO String
getHostName
theTime <- getZonedTime
return RunDescription {
errors = 0
, failedCount = testCountTotal (ts_failed_tests test_statistics)
, skipped = Nothing
, hostname = Just host
, suiteName = "test-framework tests"
, testCount = testCountTotal (ts_total_tests test_statistics)
, time = 0.0
, timeStamp = Just $ formatTime defaultTimeLocale "%a %B %e %k:%M:%S %Z %Y" theTime
, runId = Nothing
, package = Nothing
, tests = fin_tests
}