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
String
host <- IO String
getHostName
ZonedTime
theTime <- IO ZonedTime
getZonedTime
RunDescription -> IO RunDescription
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return RunDescription {
errors :: Int
errors = Int
0
, failedCount :: Int
failedCount = TestCount -> Int
testCountTotal (TestStatistics -> TestCount
ts_failed_tests TestStatistics
test_statistics)
, skipped :: Maybe Int
skipped = Maybe Int
forall a. Maybe a
Nothing
, hostname :: Maybe String
hostname = String -> Maybe String
forall a. a -> Maybe a
Just String
host
, suiteName :: String
suiteName = String
"test-framework tests"
, testCount :: Int
testCount = TestCount -> Int
testCountTotal (TestStatistics -> TestCount
ts_total_tests TestStatistics
test_statistics)
, time :: Double
time = Double
0.0
, timeStamp :: Maybe String
timeStamp = String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ TimeLocale -> String -> ZonedTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%a %B %e %k:%M:%S %Z %Y" ZonedTime
theTime
, runId :: Maybe String
runId = Maybe String
forall a. Maybe a
Nothing
, package :: Maybe String
package = Maybe String
forall a. Maybe a
Nothing
, tests :: [FinishedTest]
tests = [FinishedTest]
fin_tests
}