Skip to content

Commit

Permalink
test-lib: Add test_todo_custom_completion variant.
Browse files Browse the repository at this point in the history
This extension of test_todo_completion additionally takes the completion function to use, so that customized completions for todo.sh aliases can be tested.
  • Loading branch information
inkarkat committed Feb 29, 2012
1 parent 79f4287 commit 3d0a4d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tests/README
Expand Up @@ -197,6 +197,11 @@ library for your script to use.
context of the last argument. <message> should state what it
is testing.

- test_todo_custom_completion <completefunc> <message> <cmdline> <completions>

Same as above, but in addition allows to specify a custom
completion function.

- test_tick [interval]

The test harness has an internal view of time which is
Expand Down
15 changes: 11 additions & 4 deletions tests/test-lib.sh
Expand Up @@ -632,9 +632,11 @@ EOF
exit 0
}

test_todo_completion () {
test "$#" = 3 ||
error "bug in the test script: not 3 parameters to test_todo_completion"
test_todo_custom_completion () {
test "$#" = 4 ||
error "bug in the test script: not 4 parameters to test_todo_custom_completion"
completeFunc=$1
shift
if ! test_skip "$@"
then
description=$1
Expand All @@ -657,7 +659,7 @@ test_todo_completion () {
EXPECT=("$@")

source "$TEST_DIRECTORY/../todo_completion"
_todo
$completeFunc
ret=$?
if [ "$ret" = 0 ]
then
Expand All @@ -684,6 +686,11 @@ $(test_cmp expect compreply)"
fi
echo >&3 ""
}
test_todo_completion () {
test "$#" = 3 ||
error "bug in the test script: not 3 parameters to test_todo_completion"
test_todo_custom_completion _todo "$@"
}

test_init_todo "$test"
# Use -P to resolve symlinks in our working directory so that the pwd
Expand Down

0 comments on commit 3d0a4d0

Please sign in to comment.