hledger/hledger/test
2023-04-20 14:36:41 -10:00
..
addons cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
balance feat: bal: A new --count report type counts postings instead of amounts. 2023-04-20 14:36:41 -10:00
cli queries: Prefix boolean queries with expr: 2023-03-27 10:29:26 -10:00
errors dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
i18n dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
import cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
journal imp: areg: when restricted by extra query args, show a hint in title 2023-02-21 08:29:59 -10:00
ledger-compat ;doc: journal: cheatsheet: clarify date tag 2023-02-04 11:30:26 -10:00
print dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
register imp: cli: report intervals can now start on arbitrary dates 2023-02-17 07:24:19 -10:00
_move.test bin: hledger-move, helps make subaccount/cost-preserving transfers 2022-10-07 14:28:04 -10:00
0unittests.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
account-aliases.test fix: aliases: Make sure we can escape forward slashes in account 2022-03-16 19:01:03 -10:00
accounts-sorting.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
accounts.test feat: accounts: --types shows account types (#1820) 2022-02-01 18:06:19 -10:00
activity.test activity: fix output after #1982; add tests 2023-02-21 07:17:21 -10:00
add.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
amount-rendering.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
aregister.test fix: areg: handle an extra account query correctly (fix #2007) 2023-02-21 10:04:07 -10:00
balancesheet.test imp: csv: Do not display thousands separators when outputting csv. 2021-12-06 15:17:46 -10:00
cashflow.test !imp: type: Change the default account inference for Cash accounts to only match 2022-02-03 15:32:00 -10:00
check-accounts.test imp: errors: more error prettification 2022-07-13 03:59:44 +01:00
check-balancednoautoconversion.test imp: errors: assertions, balanced: more consistent format 2022-07-12 16:53:08 +01:00
check-commodities.test imp: errors: more error prettification 2022-07-13 03:59:44 +01:00
check-ordereddates.test imp: errors: more error prettification 2022-07-13 03:59:44 +01:00
check-payees.test imp: errors: more error prettification 2022-07-13 03:59:44 +01:00
check-tags.test feat: check: the tags check checks tag names 2023-02-16 11:56:22 -10:00
check-uniqueleafnames.test imp: check: uniqueleafnames: use the standard error format (#1436) 2022-04-25 02:56:59 -10:00
close.test imp: close: more cleanup; add --close; always default to ALE (#2020) 2023-04-06 11:12:35 -10:00
codes.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
csv.test imp: csv: check assigned account names are valid (parseable) (#1978) 2023-01-11 21:42:47 -10:00
csvtest.sh ;dev: csvtest.sh: note need for 1+ lines above RULES 2023-01-11 21:38:04 -10:00
descriptions.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
forecast.test dev: print: fix a date-sensitive JSON test 2023-04-06 11:12:35 -10:00
incomestatement.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
json.test lib!: lib: Remove aismultiplier from Amount. 2021-07-22 19:06:33 -10:00
notes.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
payees.test payees: add --used/--declared flags, like accounts 2021-01-17 16:37:38 -08:00
pivot.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
prices.test fix: price: Make sure inferred market prices have the correct sign with 2022-03-10 17:34:49 -10:00
query-bool.test queries: Update boolean queries to be case-insensitive 2023-03-27 10:29:26 -10:00
query-desc.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
query-tag.test feat: queries can now match account tags (#1817) 2022-01-30 09:47:52 -10:00
query-type.test imp: journal: ignore redundant costs; --infer-costs more robustly 2023-01-25 19:00:29 -10:00
README.md cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
related.test imp: balance: Allow --related flag for balance reports. (#1469) 2021-11-08 14:03:50 -10:00
rewrite.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
roi.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
sample.journal cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
stats.test dev: tests: convert remaining format 1 tests to format 3 (or 2) 2023-02-16 11:55:15 -10:00
tags.test fix: tags: also match accounts declared but not used (#1857) 2022-04-14 12:28:43 -10:00
timeclock.test imp: errors: timeclock, csv error improvements 2022-07-23 02:35:52 +01:00
timedot.test csv, timedot, timeclock: respect --alias options (fix #859) 2020-11-24 09:17:01 -08:00
unittest.hs ;ci: use --pedantic for all; fix a warning with unit test suites 2020-03-07 14:43:50 -08:00

hledger test-related files. See also Contributor Guide: Tests.

unittest.hs - main file for a cabal test suite in the hledger package (run by “cabal test” or “stack test”). Runs the unit tests built in to all hledger modules. Not used much, we usually run them via hledgers builtin “test” command instead.

doctest.hs - main file for another cabal test suite. Runs the doctests embedded in haddock comments in some hledger modules.

The rest of the files here are functional tests, run with shelltestrunner. These test the hledger CLI and (indirectly) the hledger-lib package. They are organised roughly by component.

Older test files are in shelltestrunners format 1; newer ones use format 3 (preferred). Some tests invoke unix commands so will not run in a Windows CMD shell.

Run them all (also builds hledger):

make functest

See how the Makefile is invoking shelltestrunner:

$ make functest -n
stack build --fast hledger
(COLUMNS=80 stack exec -- shelltest --execdir -j16 --hide-successes --exclude=/_ -w `stack exec -- which hledger` tests \
        && echo functest PASSED) || (echo functest FAILED; false)

These are the most important:

  • COLUMNS=80 makes output independent of your terminal width.
  • --execdir runs each test within its own directory.
  • -w `stack exec -- which hledger` ensures you are testing the hledger executable that was just built.
  • -j16 runs tests in parallel which is much faster.

Run only the tests matching a regular expression:

$ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests -i balance-assertions.*19
:hledger/test/journal/balance-assertions.test:19: [OK]

         Test Cases  Total      
 Passed  1           1          
 Failed  0           0          
 Total   1           1          

Run only the tests in one file:

$ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` hledger/test/cli/query-args.test
:hledger/test/cli/query-args.test:1: [OK]
:hledger/test/cli/query-args.test:2: [OK]
:hledger/test/cli/query-args.test:3: [OK]

         Test Cases  Total      
 Passed  3           3          
 Failed  0           0          
 Total   3           3          

Run a test repeatedly as its file is changed:

$ ls hledger/test/cli/query-args.test | entr bash -c "COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` hledger/test/cli/query-args.test -i1"
:hledger/test/cli/query-args.test:1: [OK]

         Test Cases  Total      
 Passed  1           1          
 Failed  0           0          
 Total   1           1          
:hledger/test/cli/query-args.test:1: [OK]

         Test Cases  Total      
 Passed  1           1          
 Failed  0           0          
 Total   1           1          
  C-c C-c

More shelltestrunner options:

$ shelltest --help