Commit graph

710 commits

Author SHA1 Message Date
Thomas Lauf
ffe329cd30 Adding centos8 to the test zoo
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-22 11:39:32 +02:00
Thomas Lauf
e451a135e2 Add test for command track with future time
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 23:04:03 +02:00
Shaun Ruffell
45eec2f7a0 Add test for command continue with future time
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 23:03:53 +02:00
Thomas Lauf
7405d2be96 Drop empty intervals during overlap resolution
- Closes #372

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 18:08:13 +02:00
Thomas Lauf
8daf11328d Add starting times to start command
- It seems that recent changes made the `stop` command faster such that these tests aborted with "The end of a date range must be after the start."

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
990e0772d0 Add tests for stop command
- Stop with no datetime (rare case of e.g. `timew stop :all`)
    - `stop` with tag after `start` without tags
2020-08-19 15:41:34 +02:00
Thomas Lauf
02491f8153 Restore behaviour for adding a new interval with same tag set
- Closes #351

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-14 22:33:16 +02:00
Shaun Ruffell
22dc0efa70 test: Add test to ensure Datafile throws when deleteInterval fails
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
48baa27057 test: Move TempDir to standalone file
I would like to use TempDir for the Datafile test in order to cleanup
any datafiles created as part of the test.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
eae8746df2 test: Add the timew binary as dependency of test target
If the timew binary changes, we should rebuild it before running
through the python tests.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
c75d9fefad test: Remove unused variables from DatetimeParser.t
Quiets the following warnings when building the test:

  test/DatetimeParser.t.cpp: In function ‘int main(int, char**)’:
  test/DatetimeParser.t.cpp:163:7: warning: unused variable ‘hm’ [-Wunused-variable]
     int hm  = (12 * 3600) + (34 * 60);      // The time 12:34:00 in seconds.
         ^~
  test/DatetimeParser.t.cpp:164:7: warning: unused variable ‘z’ [-Wunused-variable]
     int z   = 3600;                         // TZ offset.
         ^
  test/DatetimeParser.t.cpp:317:7: warning: unused variable ‘t8a’ [-Wunused-variable]
     int t8a   = (8 * 3600);
         ^~~
  test/DatetimeParser.t.cpp:318:7: warning: unused variable ‘t830a’ [-Wunused-variable]
     int t830a = (8 * 3600) + (30 * 60);
         ^~~~~
  test/DatetimeParser.t.cpp:319:7: warning: unused variable ‘t8p’ [-Wunused-variable]
     int t8p   = (20 * 3600);
         ^~~
  test/DatetimeParser.t.cpp:320:7: warning: unused variable ‘t830p’ [-Wunused-variable]
     int t830p = (20 * 3600) + (30 * 60);
         ^~~~~
  test/DatetimeParser.t.cpp:321:7: warning: unused variable ‘t12p’ [-Wunused-variable]
     int t12p  = (12 * 3600);
         ^~~~
  test/DatetimeParser.t.cpp:322:7: warning: unused variable ‘t1p’ [-Wunused-variable]
     int t1p   = (13 * 3600);
         ^~~
  test/DatetimeParser.t.cpp:325:7: warning: variable ‘adjust’ set but not used [-Wunused-but-set-variable]
     int adjust = (time_now.hour () > 10 || (time_now.hour () == 10 && time_now.minute () > 30)) ? 86400 : 0;
         ^~~~~~

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
b2a8fe6f55 test: Add tests for -1, 0, 1, and 2 'journal.size' settings
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
0a4644bfc7 AtomicFile: Add size() and remove() methods
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Thomas Lauf
6bf708dbeb Use dynamic test data for interval enclosing a month border in delete.t
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 13:59:05 +02:00
Thomas Lauf
90b5b1085e Adapt delete.t and move.t as today is now interpreted as a range
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-15 17:22:32 +02:00
Shaun Ruffell
cc82f468e1 CmdStart: Honor the :adjust flag when overwriting a currently open interval
Move the adjustment of a new open interval that is enclosed by the
current open interval into the validation processing, where the other
overlap resolution takes place.

This will allow the start command to honor the :adjust flag when
starting a new interval that predates the current open interval.

Closes #326

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-12 12:27:31 +02:00
Shaun Ruffell
4aacba47df CmdStart: Do not assume :all hint means now
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-07-08 21:28:41 +02:00
Shaun Ruffell
6a52a412ba CmdStart: Do not silently fail if tags match
It was possible previously to start an interval with a filter earlier
than the current filter, and if the tags matched, the command would
report success without actually moving the start time.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-07-08 21:28:41 +02:00
Thomas Lauf
7bc511bc73 Update tests for TagInfoDatabase
- Add tests for JSON output
- Separate different test scenarios
- Optimize JSON output in `TagInfoDatabase::toJson ()`

- Closes #325

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-02 22:42:45 +02:00
Thomas Lauf
d99872eb90 Finish implementation of 'continue by tag'
- This adds the last bits to the PR started by Christian Roesch:
- Some code formatting
- Specifying both id(s) and tag(s) is an error
- Clear range for tag filter: The range is meant to set the new interval's range, not the filter's
- Added tests
- Overhauled test using relative times and testing exported intervals instead of command line output
- Closes #241

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-02 19:59:47 +02:00
Christian Rösch
3def4b10c4 Refactor code as suggested and add tests. 2020-07-01 16:16:58 +02:00
Christian Rösch
f3280966e0 Allow continue by tag. 2020-07-01 16:16:58 +02:00
Thomas Lauf
6db29f1df5 Move overlap resolution from CmdContinue to function autoAdjust
- Only an open interval can truncate another open interval.
  Otherwise the `:adjust` hint has to be applied

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-01 08:12:04 +02:00
Thomas Lauf
63f230013a Detect whether a date is meant as range
- Add DatetimeParser::parse_range: If a date contains no time, it is assumed to be a fixed range, else an open range starting at given datetime
- Add tests for summary with named dates 'yesterday' and 'today'
- Remove closing of filter in CmdSummary.cpp
- Closes #333

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-28 20:52:43 +02:00
Thomas Lauf
2906f36830 Add test for command summary with :all hint
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-22 22:21:27 +02:00
Thomas Lauf
7e11fde992 Remove template.t from test folder
- This file was development only, now any other test file can serve as template for new tests
- Closes #303

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-22 09:16:08 +02:00
Thomas Lauf
c71eeb6dfd Add DOM-query for ids
- Closes #126

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
a508dd21ea Get and use filter from CLI when processing DOM references
- Closes #188

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
6e5236d472 Add DOM query dom.tracked.tags
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
5c234c95f9 Move test setup to the test methods
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
ad58309159 Update Copyright
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-04-19 12:41:23 +02:00
Thomas Lauf
41c50e009c Add test for export with tag filter
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-06 16:13:00 +01:00
Shaun Ruffell
42872f5168 test: Add test for filtering non-contiguous intervals
Related to #293

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-03-06 16:10:19 +01:00
Thomas Lauf
bf87509329 Handle case of empty interval, fix tests
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-03 22:24:45 +01:00
Thomas Lauf
368d033ce5 Rename atomic to AtomicFileTest
- Avoid possible clash with lib atomic on macOS, e.g. in /Library/Developer/CommandLineTools/usr/include/c++/v1/memory:668

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-02 21:42:53 +01:00
Thomas Lauf
551964eb15 Fix check for libfiu usage
- on macOS, use "otool -L" instead of "ldd"

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-01 21:08:32 +01:00
Shaun Ruffell
b5df2a2aa5 CmdHelp: Return error if man command fails
I feel this is expected behavior, but also eliminates the following compile time
warning on one of my systems:

  warning: ignoring return value of ‘int system(const char*)’, declared with
    attribute warn_unused_result [-Wunused-result]

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-03-01 21:02:43 +01:00
Thomas Lauf
9ae84426d9 Upgrade pip
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-01 20:33:41 +01:00
Thomas Lauf
fa4371d30c Return exit code of ./problems, not the last command, on macOS
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-01 20:33:40 +01:00
Thomas Lauf
6b75a5f92d Set bufsize to '-1' so we use io.DEFAULT_BUFFER_SIZE
- 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>
2020-02-23 19:26:29 +01:00
Thomas Lauf
72f13b859f Remove obsolete code
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
cb7240fe1a Linebreak after <"""> in multiline doc-comments
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
457e73f772 Remove unnecessary input
- ":yes" hint already takes care of that

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
bb73c293ef Remove line breaks
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Shaun Ruffell
dcfe0d1c3d test/docker: containers should return non-zero values on failures 2020-02-23 19:03:40 +01:00
Shaun Ruffell
926ecd7333 test: Add write-failure.t
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
2020-02-23 19:03:40 +01:00
Shaun Ruffell
8e99c07d85 Introduce AtomicFiles
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
2020-02-23 19:03:40 +01:00
Shaun Ruffell
85c5655f79 Replace 'ѕ' with 's' in test docstrings
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.
2020-01-26 22:38:52 +01:00
Shaun Ruffell
6852fd2924 test/problems: Report when tests do not run properly
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
2020-01-26 22:38:52 +01:00
Shaun Ruffell
d62fc02649 test/problems: Change to allow match to be saved after each condition
This isn't a functional change, but will allow the capture groups to be
inspected for each of the regular expressions in a future commit.
2020-01-26 22:38:52 +01:00