lib: clarify package test suites, run all easytests
This commit is contained in:
parent
582e088325
commit
6081fead11
@ -1,14 +1,19 @@
|
||||
{-
|
||||
Runs hledger doctests.
|
||||
Usage examples: in hledger source dir,
|
||||
make ghci-doctest, :main [--verbose] [--slow] [CIFILEPATHSUBSTRINGS]
|
||||
or:
|
||||
stack test hledger-lib:test:doctests [--test-arguments '[--verbose] [--slow] [CIFILEPATHSUBSTRINGS]']
|
||||
Run doctests in Hledger source files under the current directory
|
||||
(./Hledger.hs, ./Hledger/**, ./Text/**) using the doctest runner.
|
||||
|
||||
Arguments are case-insensitive file path substrings.
|
||||
Arguments are case-insensitive file path substrings, to limit the files searched.
|
||||
--verbose shows files being searched for doctests and progress while running.
|
||||
--slow reloads ghci between each test (https://github.com/sol/doctest#a-note-on-performance).
|
||||
|
||||
Eg, in hledger source dir:
|
||||
|
||||
$ make ghci-doctest, :main [--verbose] [--slow] [CIFILEPATHSUBSTRINGS]
|
||||
|
||||
or:
|
||||
|
||||
$ stack test hledger-lib:test:doctests [--test-arguments '[--verbose] [--slow] [CIFILEPATHSUBSTRINGS]']
|
||||
|
||||
-}
|
||||
|
||||
{-# LANGUAGE PackageImports #-}
|
||||
@ -28,10 +33,12 @@ main = do
|
||||
pats = filter (not . ("-" `isPrefixOf`)) args
|
||||
|
||||
-- find source files
|
||||
sourcefiles1 <- glob "Hledger/**/*.hs"
|
||||
sourcefiles2 <- glob "Text/**/*.hs"
|
||||
let sourcefiles = filter (not . isInfixOf "/.") $ ["Hledger.hs"] ++ sourcefiles1 ++ sourcefiles2
|
||||
|
||||
sourcefiles <- filter (not . isInfixOf "/.") <$> mconcat [
|
||||
glob "Hledger.hs"
|
||||
,glob "Hledger/**/*.hs"
|
||||
,glob "Text/**/*.hs"
|
||||
]
|
||||
|
||||
-- filter by patterns (case insensitive infix substring match)
|
||||
let
|
||||
fs | null pats = sourcefiles
|
||||
|
||||
41
hledger-lib/test/easytests.hs
Executable file → Normal file
41
hledger-lib/test/easytests.hs
Executable file → Normal file
@ -1,38 +1,5 @@
|
||||
#!/usr/bin/env stack exec -- ghcid -Tmain
|
||||
-- Run tests using project's resolver, whenever ghcid is happy.
|
||||
--
|
||||
-- Experimental tests using easytest, an alternative to hunit (eg).
|
||||
-- https://hackage.haskell.org/package/easytest
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
{-
|
||||
Run hledger-lib's easytest tests using the easytest runner.
|
||||
-}
|
||||
import Hledger
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
run
|
||||
-- rerun "journal.standard account types.queries.assets"
|
||||
-- rerunOnly 2686786430487349354 "journal.standard account types.queries.assets"
|
||||
$ tests [
|
||||
|
||||
test "journal.standard account types.queries" $
|
||||
let
|
||||
j = samplejournal
|
||||
journalAccountNamesMatching :: Query -> Journal -> [AccountName]
|
||||
journalAccountNamesMatching q = filter (q `matchesAccount`) . journalAccountNames
|
||||
namesfrom qfunc = journalAccountNamesMatching (qfunc j) j
|
||||
in
|
||||
tests
|
||||
[ test "assets" $
|
||||
expectEq (namesfrom journalAssetAccountQuery) ["assets","assets:bank","assets:bank:checking","assets:bank:saving","assets:cash"]
|
||||
, test "liabilities" $
|
||||
expectEq (namesfrom journalLiabilityAccountQuery) ["liabilities","liabilities:debts"]
|
||||
, test "equity" $
|
||||
expectEq (namesfrom journalEquityAccountQuery) []
|
||||
, test "income" $
|
||||
expectEq (namesfrom journalIncomeAccountQuery) ["income","income:gifts","income:salary"]
|
||||
, test "expenses" $
|
||||
expectEq (namesfrom journalExpenseAccountQuery) ["expenses","expenses:food","expenses:supplies"]
|
||||
]
|
||||
|
||||
]
|
||||
main = run easytests
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
import Hledger (tests_Hledger)
|
||||
{-
|
||||
Run hledger-lib's HUnit tests using the test-framework test runner,
|
||||
passing --hide-successes and any additional command line args.
|
||||
-}
|
||||
|
||||
import System.Environment (getArgs)
|
||||
import Test.Framework.Providers.HUnit (hUnitTestToTests)
|
||||
import Test.Framework.Runners.Console (defaultMainWithArgs)
|
||||
import Hledger (tests_Hledger)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
args <- getArgs
|
||||
let args' = "--hide-successes" : args
|
||||
|
||||
Loading…
Reference in New Issue
Block a user