summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* Update docs for move to GitHub ActionsMartin Michlmayr2021-08-241-1/+1
|
* Fix silent errors when reading lines from input files.Austin Wise2021-08-242-0/+10
| | | | | | | | Handle files that don't end with a new line. Throw an error when the buffer size is exceeded. Fixes #516 Contributes to #1149
* Show "FAILURE in exit code" when success is expectedAlan Bram2021-05-041-5/+4
| | | | Fixes #2023.
* Fix amount tokenizer re: embedded minus sign.Donald Lam2021-05-021-0/+12
| | | | | An amount may have a (single) leading minus sign, but none after that. Bug #2001 (and #1809).
* Fix using day-of-week names for `xact` commandAlan Bram2021-04-101-0/+23
| | | | Also fix end-of-command boundary checks for keywords "at", "to", etc.
* Make test harness more Windows compatibleDaniel Coonce2021-02-023-17/+18
| | | | | Windows doesn't seem to use UTF-8 by default, so we can specify encoding='utf-8'. Also, backslashes are confusing to regex parsers.
* Don't use date format %FDaniel Coonce2021-02-021-1/+1
| | | | Date format %F is not available on all platforms.
* Fix issues related to payees declared on posting's metadataDiogo Trentini2021-02-022-6/+21
| | | | | Payees declared on posting's metadata are now validated with `--check-payees` option. Also, their aliases are now considered on reports as well.
* Add debit field to convert commandKai Wohlfahrt2021-01-313-1/+24
| | | | | This changes the error reported when a transaction with no amount is imported.
* compare_by_commodity: Always return the result of the recursive callChristoph Dittmann2021-01-301-0/+14
| | | | | | | | | | | | | | | | | | | | | | | Commit 501fbc08ae5493db77bb34f4c4fbe1f3a3bc14e3 changed the behavior of this function to not return the "equal" result (==0) from the recursive call. Previously, the function returned the result of the recursive call unconditionally. The current behavior causes an assertion error for certain postings. The regression test added in this commit shows such a posting. I found through Travis CI that the old behavior was incomplete and caused unstable orderings, so reverting to the old behavior doesn't work. Instead, this change adds a fallback: If the recursive call that compares the prices numerically returns "equal", then compare the prices with their original commodity as a tie breaker. This commit does not change any existing ordering, it only adds deterministic ordering in a case that currently triggers an assertion error. This fixes issue #1998.
* format_t::truncate support wide charactersKuang-che Wu2021-01-172-1/+123
| | | | also add unit tests
* Do not treat balance assignments with 0 diff as a null postingDaraul Harris2020-12-054-0/+112
| | | | | | | | | | | Ledger is treating balance assignments that have a 0 diff as having a null posting, leading to the posting being auto-balanced and therefore causing incorrect values to be returned for the transaction. I fixed this by just making the posting equal to amt - amt (0 in the right commodity). Fixes #1942
* Fix regression in sorted_amountsMartin Michlmayr2020-10-301-0/+17
| | | | | | | | | | Commit 557ab32 ("Expose a new utility function for balances: sorted_amounts") split out some code into a separate function. Unfortunately, in the process an "if" statement was dropped, leading to amounts being shown that shouldn't be shown because they are smaller than the display precision. Fixes #1969
* run demo.py test only when Python is enabledMartin Michlmayr2020-05-181-5/+7
| | | | | | | | Commit 92b6072ffd ("run demo.py with ctest") made demo.py part of the test suite. But we can only run it if Python is enabled in ledger. Fixes #1910
* Add regression test for issue #1895Martin Michlmayr2020-05-181-0/+31
| | | | Thanks to Feiko Nanninga for the test case.
* run demo.py with ctestAndy Clayton2020-05-181-0/+6
| | | | | Fix error from newer cmake/FindPython versions not printing internal Python_EXECUTABLE variable.
* Improve testcase for issue #1894 slightlyMartin Michlmayr2020-05-091-3/+8
|
* Add regression tests for issue #1894Rahix2020-05-092-0/+37
| | | | | | Add tests for wrong behavior caused by commit 49b07a1c1948 ("Correction to the way parens are parsed in query expressions") which was reverted with commit 869302ae9ce3. The bug report was issue #1894.
* Ensure that apply directives have an argumentMartin Michlmayr2020-04-271-0/+20
| | | | | | | | The directive `apply account` and similar directives (fixed, year...) require an argument. Ensure that an argument is given. Fixes #553 Fixes #1854
* fix: Fix #543 by tracking an account's real balanceDaraul2020-04-054-0/+104
| | | | | | | | | | | | | | Without these changes, whether an account's balance is virtual or real is not considered when asserting it's balance. This lead to situations where the user must consider their virtual postings when attemping to assert the real balance of the account. See test/regress/543_a.test for that testcase, taken from the original issue. This commit also includes other, fringe, situations that I noticed while working on the fix. It essentially just adds a separate attribute to the account class(?) that hold's the account's "real" balance, which is only updated when the user attempts an assertion on a real account. The virtual account's balance is updated the way it always was.
* Make explicit option a no-opCandyAngel2020-04-031-1/+1
| | | | Fixes #1877
* py3: ensure python output is not lostAndy Clayton2020-03-262-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unbuffer python's stdio to avoid output getting stuck in buffer when stdout is not a TTY. Normally buffers are flushed by `Py_Finalize` but Boost has a long-standing issue preventing the proper shutdown of the interpreter with `Py_Finalize` when embedded [1]. This applies the same fix as 139beba but to any ledger usage rather than only the test suite. I removed `PYTHONUNBUFFERED=1` from tests as there is no expectation that users should need to have this set for ledger to function. For example without this fix piping ledger into cat usually loses any output (unless the output is large enough to cause the buffer to flush): $ ./ledger -f "test/baseline/feat-value_py3.test" reg <class 'bool'> True [...] $ ./ledger -f "test/baseline/feat-value_py3.test" reg | cat $ Interestingly `--verify` causes `python_interpreter_t` to be destroyed -- it doesn't appear to be otherwise -- which does call `Py_Finalize`. As expected this fixes the issue but can also crash due to the boost issue mentioned above: $ ./ledger -f "test/baseline/feat-value_py3.test" --verify reg <class 'bool'> True [...] Segmentation fault (core dumped) $ ./ledger -f "test/baseline/feat-value_py3.test" --verify reg | cat <class 'bool'> True [...] $ 1. https://www.boost.org/doc/libs/1_62_0/libs/python/doc/html/tutorial/tutorial/embedding.html
* Revert expected test time value to correct valueAndy Clayton2020-03-251-1/+1
| | | | | | This was changed to be specific to the author's local TZ in 139beba. With the test TZ override fixed, revert this back to the value that is correct across all environments (including travis).
* fix setting TZ in testsAndy Clayton2020-03-252-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was regressed in 139beba which set `PYTHONUNBUFFERED` to fix other test issues. When setting multiple environment variables in this way they need to be delimited with semicolons rather than spaces. As it is `PYTHONUNBUFFERED` is being set to `1 TZ=America/Chicago`. The CMake docs are not as clear about this as they probably should be. This can be verified by throwing together a CTestTestfile.cmake: add_test(incorrect_env "printenv" "PYTHONUNBUFFERED" "TZ") set_tests_properties(incorrect_env PROPERTIES ENVIRONMENT "PYTHONUNBUFFERED=1 TZ=America/Chicago") add_test(correct_env "printenv" "PYTHONUNBUFFERED" "TZ") set_tests_properties(correct_env PROPERTIES ENVIRONMENT "PYTHONUNBUFFERED=1;TZ=America/Chicago") When run with `ctest -V`: 1: Test command: /usr/bin/printenv "PYTHONUNBUFFERED" "TZ" 1: Environment variables: 1: PYTHONUNBUFFERED=1 TZ=America/Chicago 1: Test timeout computed to be: 10000000 1: 1 TZ=America/Chicago 1/2 Test #1: incorrect_env ....................***Failed 0.00 sec test 2 Start 2: correct_env 2: Test command: /usr/bin/printenv "PYTHONUNBUFFERED" "TZ" 2: Environment variables: 2: PYTHONUNBUFFERED=1 2: TZ=America/Chicago 2: Test timeout computed to be: 10000000 2: 1 2: America/Chicago 2/2 Test #2: correct_env ...................... Passed 0.00 sec
* Add test for --average-lot-pricesMartin Michlmayr2019-12-252-1/+16
|
* test: split value_py.test into py2/py3 versions.Dimitri John Ledkov2019-12-073-0/+32
|
* test: No baseline tests for average-lot-pricesDimitri John Ledkov2019-12-071-0/+1
|
* test: Unbreak one more test case with python3 bridgeDimitri John Ledkov2019-12-063-5/+5
| | | | | | | | | | | python3 has buffered output by default, hence testcase option_py returned no output when executed under test harness. I think this is a real problem in the way python interpreter is embeded, and i.e. stdout is not flushed until after test case has died. However, running things unbuffered seems to make everything work. But for some reason I had to adjust 1057.test slightly. I have no idea what those numbers mean, and if running things unbuffered break stuff.
* Remove dependency on other testAlexis Hildebrandt2019-12-051-3/+3
|
* Make tests scripts Python 3 compatibleAlexis Hildebrandt2019-12-0515-81/+137
|
* Modernize CMake using backported FindPython module.Dimitri John Ledkov2019-12-052-9/+9
|
* Format annotations using format that can be parsedOleg Bulatov2019-11-274-5/+5
| | | | | | | | | | | | | | | | | I expect an output of `ledger print` to be consumable by ledger. But on the next journal ``` 2019/11/25 * test Foo 1 AAPL {1.00 EUR} [2019/11/24] Bar ``` it prints [19-Nov-24], which it does not understand with default options. With this patch it prints [2019/11/24].
* Remove know-ification of elements due to post stateCandyAngel2019-08-272-2/+14
|
* Add support for '%F' date format specifierMichael Budde2019-04-021-0/+20
| | | | | | | | | '%F' is equivalent to '%Y-%m-%d'. Using the '%F' format without this change this would not give any hard errors but instead give dates with wrong years because the 'has_year' trait would not be correctly detected and thus parsed dates would get set to the current year. Fixes #1775
* Fix tag value parsingMichael Budde2019-03-301-0/+17
| | | | | | | | | | | | If a tag is more than 2 characters from the beginning of the comment the tag value offset will be wrong. #1702 gives an example where the tag line starts with `;;` and the tag value thus becomes `: Bar` because of this bug. The use `index` in the offset calulation seems to be a lucky coincidence that works in the common case: "; tag: value" Fixes #1702
* Reject postings with comment after flagMichael Budde2019-03-301-0/+12
| | | | Fixes #1753
* Remove the 'org' command, which was always a hack to begin withJohn Wiegley2019-03-151-28/+0
|
* Corrections to opt-lots.testJohn Wiegley2019-03-151-1495/+1495
|
* Fix possible stack overflow in option parsing routineMartin Michlmayr2019-01-261-0/+7
| | | | | | | | | | | | | | | It is possible to create a stack overflow by giving an option that is longer than the buffer that is used during option parsing because the length of the input string is not checked. Prevent the issue by always checking the input string length and discarding options that does not fit in the buffer as invalid. This issue has been assigned CVE-2017-12481. Thanks to Gwan Yeong Kim for reporting this issue. Fixes #1222
* Fix possible stack overflow in date parsing routineMichael Budde2019-01-261-0/+9
| | | | | | | | | | | | | | | It is possible to create a stack overflow by giving a date that is longer than the buffer that is used during date parsing because the length of the input string is not checked. The `VERIFY` macro is only enabled when debug-mode is enabled and the `--verify-memory` argument is used. Prevent the issue by always checking the input string length and discarding dates that does not fit in the buffer as invalid. This issue has been assigned CVE-2017-12482. Fixes #1224
* Merge pull request #1743 from scfc/move-garbage-dat-to-test-using-itJohn Wiegley2019-01-252-30/+30
|\ | | | | Move garbage-input.dat to test case using it
| * Move garbage-input.dat to test case using itTim Landscheidt2019-01-222-30/+30
| |
* | Merge pull request #1744 from scfc/do-not-set-dependencies-for-target-checkJohn Wiegley2019-01-252-7/+0
|\ \ | | | | | | Do not set dependencies for target check
| * | Do not set dependencies for target checkTim Landscheidt2019-01-222-7/+0
| |/ | | | | | | | | | | The set_target_properties() commands themselves do not cause the tests to run if the target check is made, and as the target check executes ctest, all tests will be run anyway.
* / Ignore null deferred postingsMichael Budde2019-01-231-0/+5
|/ | | | | | | | | | | | | | | | | | All-null transactions (i.e. a transaction where all postings have a null amount) are discarded during parsing and the `xact` object is free'd. But if the transaction contains a deferred posting this results in a use-after-free vulnerability because a reference to the deferred posting is stored in the account object which is later read when deferred postings are applied after parsing is finished. Ignore null deferred postings to prevent this – they should not have any effect any way. Thanks to Cory Duplantis for reporting this issue and providing an initial analysis. Ref TALOS-2017-0304, CVE-2017-2808 Fixes #1723
* Fix parsing issue involving effective datesMartin Michlmayr2019-01-151-0/+12
| | | | | | | | | | | | | | | | | Cory Duplantis reported that "A specially crafted journal file can cause [an] integer underflow resulting in code execution". Cory provided this test case: Expenses:Food:Groceries $ 37.50 ; ] [=2004/01/01] Note the ] that comes before [ after the ;. This issue was reported and described in great detail by Cory Duplantis of Cisco Talos. This issue is known as TALOS-2017-0303 and has been assigned CVE-2017-2807. Cory's description can be found at https://www.talosintelligence.com/vulnerability_reports/TALOS-2017-0303 Fixes #1722
* Add test case for issue #1703Martin Michlmayr2019-01-121-0/+11
| | | | | Add a test case for issue #1703 which John Wiegley fixed in commit 56025cde ("Don't attempt to invert a value if it's already zero").
* Merge remote-tracking branch 'origin/master' into nextJohn Wiegley2018-07-191-0/+18
|\
| * Add parse error testManuel Amador (Rudd-O)2016-02-081-0/+18
| |
* | Add the test to make sure it works in the future.Pascal Fleury2018-07-181-0/+36
| |