test-lib: Also check completion exit code.
The completion may unexpectedly abort somewhere. Additionally, reformat the failure messages (don't prepend a "*", this should be reserved to mark the individual test runs) and use "compreply" instead of "output", so that it's already clear from the diff output that the completion is being tested.
This commit is contained in:
@@ -305,7 +305,7 @@ $cmp_output"
|
|||||||
else
|
else
|
||||||
cmp_output=$(test_cmp expect output)
|
cmp_output=$(test_cmp expect output)
|
||||||
test_failure_ "$2" "$3" "
|
test_failure_ "$2" "$3" "
|
||||||
* expected exit code $1, actual ${eval_ret}${cmp_output:+
|
expected exit code $1, actual ${eval_ret}${cmp_output:+
|
||||||
}${cmp_output}"
|
}${cmp_output}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -324,7 +324,7 @@ test_expect_code () {
|
|||||||
test_ok_ "$2"
|
test_ok_ "$2"
|
||||||
else
|
else
|
||||||
test_failure_ "$2" "$3" "
|
test_failure_ "$2" "$3" "
|
||||||
* expected exit code $1, actual ${eval_ret}"
|
expected exit code $1, actual ${eval_ret}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo >&3 ""
|
echo >&3 ""
|
||||||
@@ -658,10 +658,12 @@ test_todo_completion () {
|
|||||||
|
|
||||||
source "$TEST_DIRECTORY/../todo_completion"
|
source "$TEST_DIRECTORY/../todo_completion"
|
||||||
_todo
|
_todo
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" = 0 ]
|
||||||
|
then
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
printf "%s${EXPECT:+\\n}" "${EXPECT[*]}" > expect
|
printf "%s${EXPECT:+\\n}" "${EXPECT[*]}" > expect
|
||||||
printf "%s${COMPREPLY:+\\n}" "${COMPREPLY[*]}" > output
|
printf "%s${COMPREPLY:+\\n}" "${COMPREPLY[*]}" > compreply
|
||||||
IFS=$SAVEIFS
|
IFS=$SAVEIFS
|
||||||
|
|
||||||
if [ ${#COMPREPLY[@]} -eq ${#EXPECT[@]} ]
|
if [ ${#COMPREPLY[@]} -eq ${#EXPECT[@]} ]
|
||||||
@@ -670,12 +672,14 @@ test_todo_completion () {
|
|||||||
then
|
then
|
||||||
test_ok_ "$description"
|
test_ok_ "$description"
|
||||||
else
|
else
|
||||||
test_failure_ "$description" "Differing completion(s):
|
test_failure_ "$description" "$(test_cmp expect compreply)"
|
||||||
$(test_cmp expect output)"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
test_failure_ "$description" "Expected ${#EXPECT[@]} completion(s), got ${#COMPREPLY[@]}:
|
test_failure_ "$description" "expected ${#EXPECT[@]} completion(s), got ${#COMPREPLY[@]}:
|
||||||
$(test_cmp expect output)"
|
$(test_cmp expect compreply)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
test_failure_ "$description" "expected completions, actual exit code $ret"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo >&3 ""
|
echo >&3 ""
|
||||||
|
|||||||
Reference in New Issue
Block a user