Introduce --infer-equity option which will generate conversion postings. --cost will override --infer-equity. This means there will no longer be unbalanced transactions, but will be offsetting conversion postings to balance things out. For example. 2000-01-01 a 1 AAA @@ 2 BBB b -2 BBB When converting to cost, this is treated the same as before. When used with --infer-equity, this is now treated as: 2000-01-01 a 1 AAA equity:conversion:AAA-BBB:AAA -1 AAA equity:conversion:AAA-BBB:BBB 2 BBB b -2 BBB There is a new account type, Conversion/V, which is a subtype of Equity/E. The first account declared with this type, if any, is used as the base account for inferred equity postings in conversion transactions, overriding the default "equity:conversion". API changes: Costing has been changed to ConversionOp with three options: NoConversionOp, ToCost, and InferEquity. The first correspond to the previous NoCost and Cost options, while the third corresponds to the --infer-equity flag. This converts transactions with costs (one or more transaction prices) to transactions with equity:conversion postings. It is in ConversionOp because converting to cost with -B/--cost and inferring conversion equity postings with --infer-equity are mutually exclusive. Correspondingly, the cost_ record of ReportOpts has been changed to conversionop_. This also removes show_costs_ option in ReportOpts, as its functionality has been replaced by the richer cost_ option. |
||
|---|---|---|
| .. | ||
| addons | ||
| balance | ||
| cli | ||
| i18n | ||
| import | ||
| journal | ||
| register | ||
| 0unittests.test | ||
| account-aliases.test | ||
| accounts-sorting.test | ||
| accounts.test | ||
| add.test | ||
| amount-rendering.test | ||
| aregister.test | ||
| balancesheet.test | ||
| cashflow.test | ||
| check-accounts.test | ||
| check-balancednoautoconversion.test | ||
| check-commodities.test | ||
| check-ordereddates.test | ||
| check-payees.test | ||
| check-uniqueleafnames.test | ||
| close.test | ||
| codes.test | ||
| csv.test | ||
| csvtest.sh | ||
| descriptions.test | ||
| forecast.test | ||
| incomestatement.test | ||
| json.test | ||
| notes.test | ||
| payees.test | ||
| pivot.test | ||
| prices.test | ||
| query-desc.test | ||
| query-tag.test | ||
| README.md | ||
| related.test | ||
| rewrite.test | ||
| roi.test | ||
| sample.journal | ||
| stats.test | ||
| tags.test | ||
| timeclock.test | ||
| timedot.test | ||
| unittest.hs | ||
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 hledger’s 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 shelltestrunner’s 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
: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