hledger/hledger/test
Simon Michael 94b3f090be csv, timedot, timeclock: respect --alias options (fix #859)
Command-line account aliases now also affect transactions read
from these formats (not just journal format).

lib: journalApplyAliases, transactionApplyAliases, postingApplyAliases
helpers have been added.
2020-11-24 09:17:01 -08:00
..
addons cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
balance ;bal: budget: add tests clarifying a surprising behaviour 2020-11-19 15:15:04 -08:00
cli cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
i18n cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
import cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
journal lib: new more robust price lookup implementation, fixing #1402 2020-11-23 18:08:41 -08:00
print cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
register cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
0unittests.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
account-aliases.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
accounts-sorting.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
accounts.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
add.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
amount-rendering.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
balancesheet.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
cashflow.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
close.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
codes.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
csv.test csv, timedot, timeclock: respect --alias options (fix #859) 2020-11-24 09:17:01 -08:00
csvtest.sh cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
descriptions.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
forecast.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
incomestatement.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
notes.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
payees.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
pivot.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
prices.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
query-desc.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
query-tag.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
README.md cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
rewrite.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
roi.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
sample.journal cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
stats.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
tags.test cli, lib: move functional tests into hledger/test/ 2020-11-16 08:47:41 -08:00
timeclock.test csv, timedot, timeclock: respect --alias options (fix #859) 2020-11-24 09:17:01 -08: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