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:
@@ -197,6 +197,11 @@ library for your script to use.
|
|||||||
context of the last argument. <message> should state what it
|
context of the last argument. <message> should state what it
|
||||||
is testing.
|
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]
|
- test_tick [interval]
|
||||||
|
|
||||||
The test harness has an internal view of time which is
|
The test harness has an internal view of time which is
|
||||||
|
|||||||
@@ -632,9 +632,11 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
test_todo_completion () {
|
test_todo_custom_completion () {
|
||||||
test "$#" = 3 ||
|
test "$#" = 4 ||
|
||||||
error "bug in the test script: not 3 parameters to test_todo_completion"
|
error "bug in the test script: not 4 parameters to test_todo_custom_completion"
|
||||||
|
completeFunc=$1
|
||||||
|
shift
|
||||||
if ! test_skip "$@"
|
if ! test_skip "$@"
|
||||||
then
|
then
|
||||||
description=$1
|
description=$1
|
||||||
@@ -657,7 +659,7 @@ test_todo_completion () {
|
|||||||
EXPECT=("$@")
|
EXPECT=("$@")
|
||||||
|
|
||||||
source "$TEST_DIRECTORY/../todo_completion"
|
source "$TEST_DIRECTORY/../todo_completion"
|
||||||
_todo
|
$completeFunc
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ "$ret" = 0 ]
|
if [ "$ret" = 0 ]
|
||||||
then
|
then
|
||||||
@@ -684,6 +686,11 @@ $(test_cmp expect compreply)"
|
|||||||
fi
|
fi
|
||||||
echo >&3 ""
|
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"
|
test_init_todo "$test"
|
||||||
# Use -P to resolve symlinks in our working directory so that the pwd
|
# Use -P to resolve symlinks in our working directory so that the pwd
|
||||||
|
|||||||
Reference in New Issue
Block a user