hledger/tests
Stephen Morgan 9de238757b lib,cli,ui: Introduce showMixed*Unnormalised, eliminate most direct calls of strWidth.
This introduces some new helper functions which are exactly the same
as what we had before, but do not call
normaliseMixedAmountSquashPricesForDisplay, so that we can use the new
functions for displaying Transaction and Posting. It also goes through
and gets rid of most uses of the old showMixed* functions which would
benefit from using the new interface.
2020-11-04 14:25:20 +11:00
..
addons ;tests: fix some func tests broken by c6da152e 2019-12-28 21:08:27 -08:00
balance lib: BudgetReport uses new renderTable inteface, now has more compact output. 2020-11-04 14:25:20 +11:00
cli ;cli: more tests for #1363 2020-10-18 21:47:01 -07:00
i18n lib,cli,ui: Introduce showMixed*Unnormalised, eliminate most direct calls of strWidth. 2020-11-04 14:25:20 +11:00
journal lib: BudgetReport uses new renderTable inteface, now has more compact output. 2020-11-04 14:25:20 +11:00
print lib,cli,ui: Introduce showMixed*Unnormalised, eliminate most direct calls of strWidth. 2020-11-04 14:25:20 +11:00
register cli: Ensure register reports are correctly aligned for negative numbers. 2020-11-04 14:25:20 +11:00
0unittests.test ;tests: move 0unittests up, delete unused examples symlink 2019-07-08 08:02:54 +01:00
account-aliases.test Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08:00
accounts-sorting.test ;tests: flatten functional test files a bit 2019-07-08 08:28:03 +01:00
accounts.test cli: Allow --drop in account command in tree mode. 2020-07-07 16:05:05 -07:00
add.test ;tests: flatten functional test files a bit 2019-07-08 08:28:03 +01:00
amount-rendering.test lib, cli: Use --flat as the default mode for all reports. 2020-07-07 15:49:08 -07:00
balancesheet.test make account type autodetection (& hledger-smooth) case insensitive again (#1341) 2020-09-03 09:52:00 -07:00
cashflow.test lib: Refactor MultiBalanceReport row sorting, make sure totals are calculated after pruning. 2020-07-07 18:46:34 -07:00
close.test lib,cli,ui: Introduce showMixed*Unnormalised, eliminate most direct calls of strWidth. 2020-11-04 14:25:20 +11:00
codes.test codes: functional tests 2020-07-07 14:00:02 -07:00
csv.test lib,cli,ui: Introduce showMixed*Unnormalised, eliminate most direct calls of strWidth. 2020-11-04 14:25:20 +11:00
csvtest.sh ;csv: fix functional tests breakage on mac 2020-06-22 15:44:49 -07:00
descriptions.test payees: Split command into descriptions, payees, and notes 2019-07-15 08:22:16 +01:00
forecast.test journal: apply commodity styles to forecasted transactions (#1371) 2020-10-19 08:59:25 -07:00
incomestatement.test cli: No longer force --no-total in compound balance reports when using --percent. 2020-08-11 15:16:29 -07:00
notes.test payees: Split command into descriptions, payees, and notes 2019-07-15 08:22:16 +01:00
payees.test payees: Split command into descriptions, payees, and notes 2019-07-15 08:22:16 +01:00
pivot.test lib: More consistent period formatting. 2020-06-04 19:30:42 -07:00
prices.test prices: style price amounts; always show full precision 2019-10-20 07:09:34 -07:00
query-desc.test Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08:00
query-tag.test Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08:00
README.md doc: add a README for the functional tests, linked from contrib guide 2019-04-19 09:56:33 -07:00
rewrite.test lib,cli,ui: Introduce showMixed*Unnormalised, eliminate most direct calls of strWidth. 2020-11-04 14:25:20 +11:00
roi.test Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08:00
sample.journal ;tests: flatten functional test files a bit 2019-07-08 08:28:03 +01:00
stats.test ;tests: flatten functional test files a bit 2019-07-08 08:28:03 +01:00
tags.test tags: add --values flag 2019-07-26 23:18:21 +01:00
timeclock.test lib: drop the file format auto-detection feature 2020-03-01 14:06:29 -08:00
timedot.test lib: drop the file format auto-detection feature 2020-03-01 14:06:29 -08:00

hledgers functional tests. See also Contributor Guide: Tests.

These mainly test the hledger CLI and (indirectly) hledger-lib. They are organised roughly by component.

Running these requires shelltestrunner. Older test files are in 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
:tests/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` tests/cli/query-args.test
:tests/cli/query-args.test:1: [OK]
:tests/cli/query-args.test:2: [OK]
:tests/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 tests/cli/query-args.test | entr bash -c "COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests/cli/query-args.test -i1"
:tests/cli/query-args.test:1: [OK]

         Test Cases  Total      
 Passed  1           1          
 Failed  0           0          
 Total   1           1          
:tests/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