- Removes RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
I tried placing my timewarrior database in Dropbox and noticed that everytime
I ran a command, Dropbox would indicate that it was syncing. Running fswatch
on macOS I saw that there was an event for timewarrior.cfg on every run. This
change eliminates the file system events when not writing to the database.
Related to #284
This test uses libfiu to create random failures in fputs and the write system
calls to verify out-of-space errors on the filesystem do not corrupt the
database.
Related to #155
Database objects were unconditionally writing out the tags database
file. For commands that are not modifying any tags, this is unnecessary.
We will now track if there have been modifications so we can use it to
determine if we need to save the tags to a file.
Closes#284
Introduce AtomicFile and a test of this module to the code.
AtomicFile is like File, except all writes go to temporary files until
the class method finalize_all () is called and the temporary files are
copied over the real files. If any writes fail, like when there is no
more space on the filesystem, none of the files in the database will be
modified.
Since we need version 1.00 of libfiu, I have only added it to the debian
testing container, which includes libfiu-1.00 in the default repository.
Related to #155
There were places in Database, CmdReport, and CmdHelp that were using a File
object when only the Path interface was needed. This is some minor cleanup I
noticed while studying the File usage as part of preparating for converting to
AtomicFile.
This fixes an error I introduced in the recent code to avoid loading the
entire database. It only now appeared because I happened to run the test
suite on the first of the month.
Below is the error I was seeing:
$ test/delete.t
1..5
ok 1 - delete.t: Delete a single closed interval
ok 2 - delete.t: Delete an interval which encloses a month border
ok 3 - delete.t: Delete a mix of open/closed intervals
not ok 4 - delete.t: Delete a single open interval
# FAIL: AssertionError on file test/delete.t line 56 in test_delete_open:
# 'self.assertEqual(len(j), 1)':
# 0 != 1
ok 5 - delete.t: Delete an open interval that spans over an exclusion
The problem is that when there was one entry in the 2020-01.data file
and one in the 2020-02.data file, when I deleted the single one in the
2020-02.data file, the interator constructor was not updating the lines
iterator when moving to a new file.
Since the recent switch to python3, I've been noticing that some of the tests
have been aborting with the following error when I use LANG=en_US instead of
LANG=en_US.UTF-8:
UnicodeEncodeError: 'latin-1' codec can't encode character '\u0455' in position 57: ordinal not in range(256)
Arguably, I should run with a unicode locale while running the test, but it
*looks* to me like the original ѕ was not intended.
When some of the individual tests fail to run, the `make test` target would
still pass since test/problems would not return an error which could hide the
fact that there are problems in the test.
With this change, if you do not have the python dateutil package, you will now
get output like:
'test_totals.t' failed to run any tests.
Passed: 975
Failed: 1
Unexpected successes: 0
Skipped: 0
Expected failures: 0
Runtime: 4.83 seconds
Or, if you do not have UTF-8 encoding set in your language you will get
something like:
'track.t' failed to run all tests.
'stop.t' failed to run all tests.
'start.t' failed to run all tests.
'test_totals.t' failed to run all tests.
Passed: 941
Failed: 50
Unexpected successes: 0
Skipped: 0
Expected failures: 0
Runtime: 4.55 seconds
This test updates one of the existing tests to make sure that an non-synthetic
interval in addition with the synthetic intervals can be moved properly.
getIntervalsByIds will be used by commands that are loading complete database
currently when they really want a few intervals that the user specified by ID.
Related to issue #245