44# This builtin only works in real completions, so stub it for the tests
55compopt () { true ; }
66
7+ begin-test-suite () {
8+ print-binary-versions
9+ echo
10+ }
11+
12+ end-test-suite () {
13+ true
14+ }
15+
716begin-test () {
817 echo " TEST: $1 "
918}
1019
1120end-test () {
1221 local status=$?
1322 if [[ $status -eq 0 ]]; then
14- echo ' PASS'
23+ echo ' PASS'
1524 echo
1625 else
1726 if [[ -n $_TEST_BINARIES ]]; then
1827 echo
19- local bin
20- for bin in " ${_TEST_BINARIES[@]} " ; do
21- " $bin " --version
22- done
28+ print-binary-versions
2329 fi
2430 exit $status
2531 fi
2632}
2733
2834test-completion () {
29- print-array ' RUNNING TEST: ' " $@ "
30- _COMPLETION_TEST=( $@ )
35+ _COMPLETION_TEST=( $@ ⇥)
36+ print-array ' INPUT: ' " ${_COMPLETION_TEST[@]} "
3137 COMP_WORDS=($@ )
3238 COMP_CWORD=$(( $# - 1 ))
3339 COMP_LINE=" $* "
@@ -36,35 +42,35 @@ test-completion() {
3642}
3743
3844expect () {
39- print-array ' EXPECTED RESULT: ' " $@ "
45+ print-array ' EXPECTED RESULT:' " $@ "
4046 local word
4147 for word in " $@ " ; do
4248 if ! [[ " ${COMPREPLY[@]} " =~ " $word " ]]; then
43- echo ' Completion failed!'
44- print-array ' Command: ' " ${_COMPLETION_TEST[@]} "
45- print-array ' Output: ' " ${COMPREPLY[@]} "
46- echo " Missing: $( printf " %q" " $word " ) "
49+ echo ' Expectation failed!'
50+ print-array ' Output:' " ${COMPREPLY[@]} "
51+ if [[ -n $COMPREPLY ]]; then
52+ echo " Missing: $( printf " %q" " $word " ) "
53+ fi
4754 exit 1
4855 fi >&2
4956 done
5057}
5158
5259reject () {
53- print-array ' SHOULD NOT INCLUDE: ' " $@ "
60+ print-array ' SHOULD NOT INCLUDE:' " $@ "
5461 local word
5562 for word in " $@ " ; do
5663 if [[ " ${COMPREPLY[@]} " =~ " $word " ]]; then
57- echo ' Completion failed!'
58- print-array ' Command: ' " ${_COMPLETION_TEST[@]} "
59- print-array ' Output: ' " ${COMPREPLY[@]} "
60- echo " Unexpected: $( printf " %q" " $word " ) "
64+ echo ' Expectation failed!'
65+ print-array ' Output:' " ${COMPREPLY[@]} "
66+ echo " Unexpected: $( printf " %q" " $word " ) "
6167 exit 1
6268 fi >&2
6369 done
6470}
6571
6672print-array () {
67- echo -n " $1 "
73+ printf ' %-22s ' " $1 "
6874 if [[ $# -eq 1 ]]; then
6975 echo ' (empty)'
7076 return
@@ -75,3 +81,11 @@ print-array() {
7581 done
7682 echo
7783}
84+
85+ print-binary-versions () {
86+ echo ' Versions:'
87+ local bin
88+ for bin in " ${_TEST_BINARIES[@]} " ; do
89+ " $bin " --version || echo " ` $bin --version` failed with status $? " >&2
90+ done
91+ }
0 commit comments