hledger/tests
Simon Michael e0fab4f882
Merge pull request #1256 from Xitian9/balanceReport
SMorgan: 
This PR aims to accomplish two major goals:

-    Get boring parent ellision working for multiBalanceReport
-    Remove the special BalanceReport code, and just use multiBalanceReport

I believe it does both, with the following additional benefits:

    A refactor of multiBalanceReportWith, to make the structure easier to follow, and with a clearer division of responsibilities
    All decisions for how an account name is to be displayed are now made in multiBalanceReport, rather than scattered around the code base
    Some miscellaneous improvements in account name rendering, including --drop now working with MultiBalanceReports, and addressing some of #373

Algorithmic changes:

-    Using HashMap AccountName (Map DateSpan Account) instead of [[MixedAmount]] is new. I admit I didn't profile this change (though given the nubs and lookups, I thought it was appropriate), so I'm glad it produces a speedup.
-    Producing the starting balances no longer calls the whole balanceReport, just the first few functions to get what it needs.
-    displayedAccounts is completely rewritten. Perhaps one subtle thing to note is that in tree mode it no longer excludes nodes with zero inclusive balance unless they also have zero exclusive balance.

SMichael: 
I'll mark the passing of the old multiBalanceReport, into which I poured many an hour :). It is in a way the heart (brain ?) of hledger - the key feature of ledgerlikes (balance report) and a key improvement introduced by hledger (tabular multiperiod balance reports). You have split that 300-line though well documented function into modular parts, which could be a little harder to understand in detail but are easier to understand in the large and more amenable to further refactoring. Then you fixed some old limitations (boring parent eliding in multi period balance reports, --drop with tree mode reports), allowing us to drop the old balanceReport and focus on just the new multiBalanceReport. And for representing the tabular data you replaced the semantically correct but inefficient list of lists with a map of maps, speeding up many-columned balance reports significantly (~40%). Last and not least you made it really easy to review. Thanks @Xitian9, great work.
2020-06-23 06:42:22 -07:00
..
addons ;tests: fix some func tests broken by c6da152e 2019-12-28 21:08:27 -08:00
balance lib: multiBalanceReport: Remove old balanceReport code, update some tests. 2020-06-22 22:27:09 +10:00
cli lib: More consistent period formatting. 2020-06-04 19:30:42 -07:00
i18n Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08:00
journal cli: Make --no-total remove subtotals from CompoundBalanceReport, not just net total. 2020-06-22 12:16:07 -07:00
print Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08:00
register lib: More consistent period formatting. 2020-06-04 19:30:42 -07: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 ;tests: flatten functional test files a bit 2019-07-08 08:28:03 +01:00
add.test ;tests: flatten functional test files a bit 2019-07-08 08:28:03 +01:00
amount-rendering.test Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08:00
balancesheet.test cli: Make --no-total remove subtotals from CompoundBalanceReport, not just net total. 2020-06-22 12:16:07 -07:00
cashflow.test lib: Use .. in place of ,, for date ranges in compound balance reports. 2020-06-04 19:30:42 -07:00
close.test ; close: update flag names in tests 2020-01-22 15:25:10 -08:00
csv.test test: reordered cases in rules parser change error msg 2020-06-22 12:10:47 -07: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 lib: More consistent period formatting. 2020-06-04 19:30:42 -07:00
incomestatement.test cli: Make --no-total remove subtotals from CompoundBalanceReport, not just net total. 2020-06-22 12:16:07 -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 Get "make functest" (mostly) working again 2020-01-07 15:58:54 -08: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