Using the cleaninput function, to escape &'s on certain actions.
Currently the actions needing escaped &'s are append, prepend and replace.
Other actions including add need unescaped &'s.
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>
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>
Add a basic test framework, borrowed from the framework used
by git.git. A shell script library (tests/test-lib.sh) helps
generate the fixtures, and simplifies the process of writing
test scripts. Tests can be run as a suite (via 'make test')
or individually (sh tests/t0000-config.sh). Results are aggregated
upon completion. Includes a detailed README.
A basic test of config file processing is part of this commit.
Signed-off-by: Emil Sit <sit@emilsit.net>