-- | This module contains the runners that take a set of specs, evaluate their examples, and-- report to a given handle.--moduleTest.Hspec.Runner(Specs,hspec,hspecB,hHspec,hHspecWithFormat,toExitCode,Summary(..)-- * Deprecated functions,hspecX)whereimportControl.Monad(unless,(>=>))importControl.ApplicativeimportData.MonoidimportTest.Hspec.InternalimportTest.Hspec.FormattersimportTest.Hspec.Formatters.InternalimportSystem.IOimportSystem.Exit-- | Evaluate and print the result of checking the spec examples.runFormatter::Formatter->Spec->FormatM()runFormatterformatter=go0[]wherego::Int->[String]->Spec->FormatM()gonestinggroups(SpecGroupgroupxs)=doexampleGroupStartedformatternestinggroupmapM_(go(succnesting)(group:groups))xsgonestinggroups(SpecExamplerequiremente)=doresult<-liftIO$safeEvaluateExampleecaseresultofSuccess->doincreaseSuccessCountexampleSucceededformatternestingrequirementFailerr->doincreaseFailCountexampleFailedformatternestingrequirementerrn<-getFailCountaddFailMessage$failureDetailsgroupsrequirementerrnPendingreason->doincreasePendingCountexamplePendingformatternestingrequirementreasonfailureDetails::[String]->String->String->Int->StringfailureDetailsgroupsrequirementerri=showi++") "++groups_++requirement++" FAILED"++err_whereerr_|nullerr=""|otherwise="\n"++errgroups_=casegroupsof[x]->x++" "_->concatMap(++" - ")(reversegroups)-- | Create a document of the given specs and write it to stdout.---- Exit the program with `exitSuccess` if all examples passed, with-- `exitFailure` otherwise.hspec::Specs->IO()hspec=hspecB>=>(`unless`exitFailure){-# DEPRECATED hspecX "use hspec instead" #-}hspecX::Specs->IOahspecX=hspecB>=>exitWith.toExitCode-- | Create a document of the given specs and write it to stdout.---- Return `True` if all examples passed, `False` otherwise.hspecB::Specs->IOBoolhspecB=fmapsuccess.hHspecstdoutwheresuccess::Summary->Boolsuccesss=summaryFailuress==0-- | Create a document of the given specs and write it to the given handle.---- > writeReport filename specs = withFile filename WriteMode (\h -> hHspec h specs)--hHspec::Handle->Specs->IOSummaryhHspechspecs=douseColor<-hIsTerminalDevicehhHspecWithFormatspecdocuseColorhspecs-- | Create a document of the given specs and write it to the given handle.-- THIS IS LIKELY TO CHANGEhHspecWithFormat::Formatter->Bool->Handle->Specs->IOSummaryhHspecWithFormatformatteruseColorhss=runFormatMuseColorh$domapM_(runFormatterformatter)ssfailedFormatterformatterfooterFormatterformatterSummary<$>getTotalCount<*>getFailCounttoExitCode::Bool->ExitCodetoExitCodeTrue=ExitSuccesstoExitCodeFalse=ExitFailure1-- | Summary of a test run.dataSummary=Summary{summaryExamples::Int,summaryFailures::Int}deriving(Eq,Show)instanceMonoidSummarywheremempty=Summary00(Summaryx1x2)`mappend`(Summaryy1y2)=Summary(x1+y1)(x2+y2)