This commit introduces the commandline argument -%/--percent to show percentages of the column's total instead of the absolute amounts for each account in reports. The signs of the values are preserved. This option is especially useful for the balance and incomestatement commands. If there are multiple commodities involved in a report hledger bails with an error message. This can be avoided by using --cost. Also note that if one uses -% with the balance command the chances are high that all numbers are 0. This is due to the fact that by default balance sums up to zero. If one wants to use -% in a meaningful way with balance one has to add a query. In order to keep the implementation as simple as possible --tree has no influence over how the percentages are calculated, i.e., the percentages always represent the fraction of the columns total. If one wants to know the percentages relative to a parent account, one has to use a query to narrow down the accounts. |
||
|---|---|---|
| .. | ||
| addons | ||
| balance | ||
| cli | ||
| i18n | ||
| journal | ||
| register | ||
| 0unittests.test | ||
| account-aliases.test | ||
| accounts-sorting.test | ||
| accounts.test | ||
| add.test | ||
| amount-rendering.test | ||
| balancesheet.test | ||
| cashflow.test | ||
| close.test | ||
| csv.test | ||
| descriptions.test | ||
| forecast.test | ||
| hledger-csv | ||
| incomestatement.test | ||
| notes.test | ||
| payees.test | ||
| pivot.test | ||
| prices.test | ||
| query-desc.test | ||
| query-tag.test | ||
| README.md | ||
| rewrite.test | ||
| roi.test | ||
| sample.journal | ||
| stats.test | ||
| tags.test | ||
| timeclock.test | ||
hledger’s 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=80makes output independent of your terminal width.--execdirruns each test within its own directory.-w `stack exec -- which hledger`ensures you are testing the hledger executable that was just built.-j16runs 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