Commit df4f9150 introduced the use of "grep -w -o". This
combination was broken from the introduction of -o (in 2001) until
subsequent release of GNU grep 2.5.3 in 2007---see changelog for
2005-11-10. In particular, OS X uses a pre-2.5.3 version
of GNU grep.
Work around by replacing with two greps: one to find maximal
strings with @s in them (still relying on -o) and the second to
extract contexts.
Reported by Jon Smajda <jon@smajda.com>; fix developed
in conjunction with Philippe Teuwen <phil@teuwen.org>.
Signed-off-by: Emil Sit <sit@emilsit.net>
While preparing a setup where env vars overload config file,
I had the bad experience that my actual todo.txt was messed up
by the testsuite so it's safer to unset everything.
Even so, some tests could have failed if some TODOTXT_ were set
in the user environment, for example:
export TODOTXT_PLAIN=1
./t1200-pri.sh
Since test-lib.sh does not depend on bash currently, calculate
the list of variables to be unset using set|sed.
Signed-off-by: Emil Sit <sit@emilsit.net>
$TODO_DIR were not protected therefore evaluated to null string
Hopefully it was used only to test for its own presence
but better to fix it in case someone wants to reuse that code
Signed-off-by: Emil Sit <sit@emilsit.net>
The idea behind this is to allow a config file or addon to inject
a list output filter after all the other filtering has been
performed. The existing TODOTXT_SORT_COMMAND provides a hook
for a custom filter prior to colorization and priority/context/proj
hiding; this new TODOTXT_FINAL_FILTER provides a hook for custom
filtering after the colorization and pri/con/proj hiding.
(I found this hook was needed when I wanted to trim the output to a
maximum line length.)
Note: I've added a number of tests of the list command, including
one for this new variable, as part of this change.
Signed-off-by: Emil Sit <sit@emilsit.net>
Set $TODO_SH to just be $(basename "$0") at the beginning
of the script and use it in all usage messages.
This happens to simplify testing because it allows us to refer to
the script as "todo.sh" in all output. For general use, if the
user has aliased to file to something else, the usage messages will
still reflect that alias.
Signed-off-by: Emil Sit <sit@emilsit.net>
add/list and replace are already covered by existing tests.
Add a new test, t1200-pri.sh, that handles the priority tests.
Signed-off-by: Emil Sit <sit@emilsit.net>
* 'test-framework' of git://github.com/sit/todo.txt-cli:
tests: Update documentation to reflect recent changes.
tests: add testshell.sh and port old testsuite.txt
tests: Explicitly control the date for todo.sh.
tests: Make test writing simpler and add two new tests.
Merge Phil's README_generate-test into the main README
and also update the test library documentation to reflect
test_todo_session and test_tick.
Signed-off-by: Emil Sit <sit@emilsit.net>
Add a simple helper script testshell.sh that can be called
to set up an environment for generating test case transcripts
that can then be pasted into an actual test script.
Port old testsuite.txt into t9999-testsuite_example.sh
with the aim of refactoring it later into smaller tests.
Also, change test_todo_session to count from one instead of zero when
autogenerating tests.
Signed-off-by: Emil Sit <sit@emilsit.net>
Create a custom date view for todo.sh tests -- the time
is set in TODO_TEST_TIME as seconds since the Unix epoch
and a custom wrapper in the testing directory is put at the
front of the path to intercept todo.sh calls to date for
date formatting.
This will only work as long as todo.sh calls $(date) for
date formatting. It also assumes a date command that
supports the -d flag (such as the one in GNU coreutils.)
Add a test for TODOTXT_DATE_ON_ADD to exercise this functionality.
Signed-off-by: Emil Sit <sit@emilsit.net>
Add a test_todo_session function to test-lib.sh that enables
easy recording of input and output from todo.sh (including
annotation of exit status for testing error cases).
Begin to port and re-factor testsuite.txt into smaller
test cases, starting with basic add list functionality
and replace functionality.
Thanks to Philippe Teuwen <phil@teuwen.org> for feedback
and improvements.
Signed-off-by: Emil Sit <sit@emilsit.net>
Instead of directly setting a value in todo.cfg, let the user
know what the default is and how to customize it. This allows
developers the flexibility of changing the default in todo.sh
without having to worry about fixing people's config files.
Signed-off-by: Emil Sit <sit@emilsit.net>
Users are probably unlikely to change the definition
of colors like $BLACK so just define them in todo.sh
and comment them out in todo.cfg. Similarly, leave
default values for priority coloring available but
commented out.
Signed-off-by: Emil Sit <sit@emilsit.net>