Commit Graph

104 Commits

Author SHA1 Message Date
Ingo Karkat
72caab8bbd Added test for del preserving line numbers. 2010-07-13 17:49:40 +02:00
Ingo Karkat
7501b225c2 ENH: Improved 'del ITEM# TERM' command.
- Condensing whitespace around TERM into a single space and removing leading/trailing spaces if at the beginning/end of the task.
- Proper error message if TERM not found.
- Aligned verbose removal message with the verbose output of the 'replace' command.
In addition, removed (accidental) printing of the task (without leading ITEM#) when checking for existence of the task; using empty check of task text as done elsewhere.
2010-07-13 17:48:54 +02:00
Ingo Karkat
2f4ba26994 ENH: Sentence delimiters for append action.
This fixes a personal annoyance.
If the text to be appended to the task begins with one of the delimiter characters, no whitespace is inserted in between. This makes appending to an enumeration (todo.sh add 42 ", foo") syntactically correct.
The list of delimiters is configurable (for personal preferences / non-English languages) via SENTENCE_DELIMITERS in the config file.
2010-07-05 13:49:58 +02:00
Ingo Karkat
5e44868261 ENH: 'prepend' and 'replace' actions keep prepended date.
Generalized and simplified the logic that already kept an existing priority to also keep a date added via todo.sh -t / TODOTXT_DATE_ON_ADD (unless the replaced text also starts with a date).
2010-07-05 11:24:19 +02:00
Ingo Karkat
f72c1034ee Added tests for custom actions (TODO_ACTIONS_DIR).
t0002-actions.sh for locating the .todo.actions.d directory.
t8000-actions.sh for the contract between todo.sh and custom actions.
2010-06-29 10:43:53 +02:00
Ingo Karkat
37fcc53b26 BUG: test_todo_session with error exit doesn't work
BUG 1: didn't report non-error exit
A test that enforces a non-zero exit code via "=== N" would succeed when the command under test returned with success (0); only differing exit codes would be correctly reported.
Corrected logic so that the check for the exit code would always run, not just when the command under test failed.

BUG 2: too early evaluation of $?
In the test expression, the evaluation of $? must be deferred until the test expression itself is evaluated.
Escaping $? to prevent premature evaluation in the context of the expression definition.
2010-06-29 08:00:24 +02:00
Glyn Faulkner
e7b5841721 Generalizes the PRI_X color support to all priorities.
It allows you to assign a distinct color to any priority, not just A, B and C. Submitted to the todo.txt mailing list on 3-Jun-2010; committed on behalf of the author because there was no follow-up; cp. http://tech.groups.yahoo.com/group/todotxt/message/2619
Also committed this because it fixes a sed expression error when there are spaces in a $PRI_... variable, which occurred in my integration with Conky.
Note: This commit obsoletes and replaces the previous fix to colorization in commit 8b7e2e6aad.
Added tests for highlighting of priorities.
2010-06-21 15:25:42 +02:00
Ingo Karkat
70b2c4ca40 Made verbose message of _addto() consistent with other task messages.
In verbose mode, commands first print the updated task, then summarize the change in the following line.
The add/addm/addto commands deviated from this, using "TODO: '<task>' added on line N."
This change splits this into two separate lines, obsoletes the implementation jargon of "line", and makes it easier to visually parse the message.
This is also a preparation for a possible future use of a _list()-like function, so that the updated task is processed and highlighted like the normal task output.
2010-06-04 16:50:09 +02:00
Ingo Karkat
69e756a2cd Bugfix: _list() cannot handle filter TERM starting with space.
Added proper quoting at check for search term starting with a dash.
Added tests for ls use with TERM, both with literal text and regexps. Seems that use case was missing from the tests so far.
Extra: Removed unnecessary "$@" argument to for() loop.
2010-06-04 16:22:15 +02:00
Ingo Karkat
8ff3a7ce4a Cleaned up terms in command error messages.
The messages now consistently use "task"; the use of "todo" is deprecated.
2010-05-27 15:48:37 +02:00
Ingo Karkat
15084aa4d7 Allow passing multiple items to depri, like for the do command. 2010-05-25 13:27:28 +02:00
Ingo Karkat
5876cc0437 Bugfix: depri first checks validity of item argument syntax before searching for todo.
Added testcase for the basic depriority command.
2010-05-25 13:08:27 +02:00
Ingo Karkat
9e5e6aef39 Printing usage message if no ITEM# given to "todo.sh do". 2010-05-25 10:10:09 +02:00
Ingo Karkat
edac86a94d Aligned "todo.sh do" usage message with existing support of passing multiple numbers. 2010-05-25 09:44:22 +02:00
Yujie Wu
2a65615c7a Added a case for the fixed replace command. 2010-05-08 08:52:59 +08:00
Gina Trapani
e395ac78d8 Fix line endings 2010-03-26 12:55:55 -07:00
Jared Cordasco
b6467eaa64 Updated _list() output to match updated addto. Adjusted tests to match.
- _list() now shows the capitalized filename in place of 'TODO:'.
  For example, listing garden.txt produces a output prefixed by 'GARDEN:'
  This eliminates the ' from $FILE' part of the _list() output. All tests
  were adjusted to match this new output.
2010-01-12 14:42:02 -05:00
Jared Cordasco
2d3820394a Refactored various add functionality to one function. Added tests.
- 'add' and 'addm' now 'addto' with $TODO_FILE instead of user supplied file

- 'addto' now shows the capitalized filename in place of 'TODO:'.
  For example, adding to garden.txt produces a output prefixed by 'GARDEN:'
  (Probably the most controversial part of this commit and up for
  discussion. If kept, the 'listfile' output should be made to match.
  Note that this convention would then minimize standard output by
  dropping the file name.)

- All existing add/addm/add-date tests pass. Two new test sequences were
  added to test 'addto' and 'listfile' functionality.

- A space/tab nuissance was cleared up in the tests/README file.
2010-01-10 01:16:11 -05:00
Paul Mansfield
97866082e6 Small change for addm test case.
* Seems echo -e isn't multiplatform compatible. Using >> for append
  instead.
2009-09-17 23:52:43 +01:00
Mike West
5f9fd4c759 Bug Fix: tasks whose ID begins with '0' ought to be ignored.
*   Fixed regex in `_list` to exclude lines that begin with whitespace,
    as the ' ' => '0' replacement hadn't yet been performed.

*   Added test cases to `t1300-ls.sh` to check for this condition.
2009-09-14 21:21:25 +02:00
Gina Trapani
5a49f4b5d5 Merge branch 'the1ts/addm' 2009-09-08 11:58:04 -07:00
Gina Trapani
f8e6a8d69d Merge branch 'the1ts/master' 2009-09-08 11:57:20 -07:00
Paul Mansfield
7a87077dfc Added new action addm
This allows addition of multiple todo items by sending multiple lines.
2009-09-06 18:53:31 +01:00
Paul Mansfield
ddaf9ade22 Bug Fix: Issue 6 append and replace unexpected behavior if there's an & in task (even in quotes)
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.
2009-09-05 20:36:38 +01:00
Gina Trapani
ce8a0a7875 Merge branch 'the1ts/master' 2009-09-04 16:11:50 -07:00
Paul Mansfield
f44bcfb067 Bug Fix, better fix for "add does not escape line breaks"
Now removes windows and unix style line breaks. Each test has a windows
and a unix style line break.
2009-09-04 12:23:48 +01:00
Gina Trapani
a19a3616c4 Merge branch 'the1ts/master' 2009-09-03 10:45:03 -07:00
Paul Mansfield
229737bd2f Bug Fix: Issue 1
Added a cleanitem function, this replaces newlines with a space.
Currently this is used in the add, append, prepend and replace actions.
2009-09-02 23:30:14 +01:00
Gina Trapani
857121090a Merge branch 'FND/disable_final_filter' 2009-09-01 09:53:37 -07:00
FND
490f5d34e8 added option to disable final filter
The option marker was chosen as "-x" here.
Alternatives might be "-X" or "-*".
2009-08-30 09:48:44 +01:00
Paul Mansfield
7baf051942 Bug Fix: do: no safeguard to do twice
Tests item is not marked done before attempting to mark item as "done".
2009-08-29 21:13:38 +01:00
Gina Trapani
266d9e1258 Merge branch 'mivok/master' 2009-08-26 16:21:14 -07:00
Paul Mansfield
91126e38aa Issue fix: Multiple do items
Can now do multiple items in one go.
Either comma seperated list or a whitespace seperated list
2009-06-25 00:14:00 +01:00
Paul Mansfield
d2e892049d Bugfix: Replace with priority set
Checks for a priority, if found removes priority does the replace
then adds back the priority.

Added a test for replace with priority set.
2009-06-24 19:24:53 +01:00
Paul Mansfield
0e2798acce Added test for prepend and priority fix 2009-06-24 14:06:25 +01:00
Mark Harrison
98569d5f8c Tests for additional default config file location 2009-06-22 22:34:45 -04:00
Emil Sit
78850255e0 tests: Add tests to validate listcon and listproj.
Two basic tests to ensure that listcon and listproj
function as expected.

Signed-off-by: Emil Sit <sit@emilsit.net>
2009-05-10 21:49:37 -04:00
Philippe Teuwen
701c30c04f test-lib.sh: unset some more TODOTXT env vars for extra safety
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>
2009-04-25 20:06:09 -04:00
Philippe Teuwen
2e62536f90 Bugfix: t0000-config test config file was wrong
$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>
2009-04-20 10:04:45 -04:00
Philippe Teuwen
c490e773cf test-lib.sh: Fixing grep for date detection on Mac OS X, thanks Dave!
Signed-off-by: Emil Sit <sit@emilsit.net>
2009-04-20 10:04:44 -04:00
Dave Hein
a67d0de625 Add TODOTXT_FINAL_FILTER to provide a final custom list filter.
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>
2009-04-19 20:30:53 -04:00
Philippe Teuwen
c8fc661256 Bugfix: test-lib.sh TEST_DIRECTORY could still contain symlink 2009-04-19 20:30:53 -04:00
Emil Sit
fee3133547 Uniformly use $TODO_SH to refer to script.
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>
2009-04-18 21:26:42 -04:00
Emil Sit
825c60514f tests: Factor basic add/list, replace, priority testing out of t9999
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>
2009-04-15 01:28:01 -04:00
Gina Trapani
fe99926bb2 Added date detection for Macs 2009-04-14 22:37:58 -04:00
Emil Sit
10bca653a0 tests: Update documentation to reflect recent changes.
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>
2009-04-12 10:14:09 -04:00
Philippe Teuwen
d6c57e4230 tests: add testshell.sh and port old testsuite.txt
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>
2009-04-12 10:01:34 -04:00
Emil Sit
b238a29430 tests: Explicitly control the date for todo.sh.
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>
2009-04-11 22:01:31 -04:00
Emil Sit
16a5103668 tests: Make test writing simpler and add two new tests.
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>
2009-04-11 22:00:49 -04:00
Philippe Teuwen
55f45e8515 tests: first unset TODOTXT_CFG_FILE
Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-05 06:37:38 +08:00