test-lib: Add test_todo_custom_completion variant.

This extension of test_todo_completion additionally takes the completion function to use, so that customized completions for todo.sh aliases can be tested.
This commit is contained in:
Ingo Karkat
2012-02-27 13:38:58 +01:00
parent c1dcd0ed78
commit 9fb52d04e6
2 changed files with 16 additions and 4 deletions

View File

@@ -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

View File

@@ -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
@@ -657,7 +659,7 @@ test_todo_completion () {
EXPECT=("$@")
source "$TEST_DIRECTORY/../todo_completion"
_todo
$completeFunc
ret=$?
if [ "$ret" = 0 ]
then
@@ -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