summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Python: Transaction.remove_post should call xact_base_t::remove_postDavid Sklar2023-01-101-6/+21
|
* Python: test cleanupsDavid Sklar2023-01-093-8/+4
| | | | | | | | 1. Remove references to modules (exceptions, StringIO) no longer needed for Pythn3 2. Use assertEqual instead of assertEquals 3. Clear journal files with a close_journal_files() function that uses the then-current underlying python_session pointer. Calling session.close_journal_files() sometimes leads to segfaults because python_session has changed after it was injected into the python module (as "session") on module startup.
* typosspaette2023-01-074-4/+4
|
* Fix balancing commodity with smaller unit.Maria2022-10-112-0/+26
|
* Fix typos found by codespellAlexis Hildebrandt2022-07-191-1/+1
|
* Update copyright statement for 2022Alexis Hildebrandt2022-07-021-1/+1
|
* Replace os.path.abspath with os.path.realpathAlexis Hildebrandt2022-07-015-10/+10
| | | | | | to fix failing tests on Darwin, where /tmp is a symlink to /private/tmp and the tests fail as ledger reports filenames with the symlink resolved to /private/tmp, but the tests expect files with /tmp.
* Fix unrounding for equityOleg Bulatov2022-05-061-0/+30
|
* Fix test formattingJohn Wiegley2022-05-031-3/+3
|
* Add test/regress/2109.testJohn Wiegley2022-05-031-0/+23
|
* Avoid making references to nullKunht Kun2022-03-171-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | In `compare_items` if `sort_order` is a top level expression, it has no context and `get_context()` method returns the null pointer. To see this, run $ ledger -f test/input/demo.ledger --sort display_amount reg --debug scope.symbols and there will be many lines like [DEBUG] Binding scope 0 with ... In such case making a reference to the context is an undefined behavior (honestly the dereferencing itself feels quite problematic, but many compilers just run without any complaints) and could potentially cause segfaults. Therefore, we change to use only the grandchild scope (`left` or `right`) for `find_sort_values` here. Note that it may seem to be more appropriate to use `report` here for the parent scope. However, in `find_sort_values` which is called right after, the `report` scope is always bound to this scope. So we only use grandchild scope to avoid unnecessary operations. Fixes #2069.
* Avoid dereferencing null pointerKunht Kun2022-03-121-0/+12
| | | | | | | Here `comm` could be a null pointer (the new test regress/2057 shows such a case). So test it before dereferencing to avoid segfault. Re: #2057
* Ensure absolute path for includeKunht Kun2022-03-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure the path of file to include in `instance_t::include_directive` is always an absolute path. Previously when the journal file is given through stdin, we prepend a "./" to the filename to include. However, in Boost >= 1.77, `path::normalize` strips the leading "./" [1]. Our `resolve_path` function calls `normalize` and thus now it returns "file" for "./file" instead of the previous "./file". This change causes a failing test regress/BF3C1F82-2 [2], and also breaks the `include` directive for stdin input: $ touch file-to-include $ echo "include file-to-include" | ledger -f - reg gives While parsing file "", line 1: Error: File to include was not found: "file-to-include" Therefore, we change to prepend the `context.current_directory` to make the filename absolute in this case as well. The test regress/BF3C1F82-2 is also updated to match the new output. Fixes #2075. [1] https://github.com/boostorg/filesystem/commit/16bd89b7c0398d0dc5904148a865ef3fc3ece7ec [2] https://github.com/ledger/ledger/issues/2075
* Modify a regression test to match output from Boost 1.77John Wiegley2022-02-241-2/+2
| | | | A better fix for this issue is needed, however.
* Use correct int return type for stream input operationskanreki2021-12-082-0/+19
| | | | | | | | This makes it safe to compare results to -1 to indicate EOF, regardless of whether char is considered signed or unsigned; and so eliminates compiler warnings on platforms such as ARM. Fixes bug #2058.
* Fix --time-colon for negative time amountsRafael Ascensão2021-09-271-0/+23
| | | | | | | | | | | | | | | While the current formula works for positive numbers, negative numbers are incorrectly represented. One of the issues comes from the fact that floor(x) < x for every x. `amount_t precision` will always be a non negative number and the code that attempts to fix the issue for negative number will never run. If we truncate the number instead, the current formula works for both positive and negative numbers without making negative numbers a corner case. So let's do that. Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com>
* 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