module Hledger.Cli.Tests
where
import Control.Monad
import System.Exit
import Test.HUnit
import Hledger
import Hledger.Cli
#ifdef TESTS
import Test.Framework
import Hledger.Read.JournalReader
test' :: CliOpts -> IO ()
test' _opts = htfMain htf_importedTests
#else
test' :: CliOpts -> IO ()
test' opts = do
results <- runTests opts
if errors results > 0 || failures results > 0
then exitFailure
else exitWith ExitSuccess
runTests :: CliOpts -> IO Counts
runTests = liftM (fst . flip (,) 0) . runTestTT . flatTests
runTestsTillFailure :: CliOpts -> IO (Maybe String)
runTestsTillFailure _ = undefined
flatTests opts = TestList $ filter (matchesAccount (queryFromOpts nulldate $ reportopts_ opts) . testName) $ flattenTests tests_Hledger_Cli
hierarchicalTests opts = filterTests (matchesAccount (queryFromOpts nulldate $ reportopts_ opts) . testName) tests_Hledger_Cli
#endif