diff options
Diffstat (limited to 'test/lib/library.exp')
| -rw-r--r-- | test/lib/library.exp | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/test/lib/library.exp b/test/lib/library.exp index 1e2c7456..9321c5ca 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -584,6 +584,24 @@ proc assert_no_output {{cmd} {test ""} {prompt /@}} { } +# Check that ~part completes to ~full/ if home dir exists. +# @param string $cmd The command to attempt home dir completion for. +# @param string $test Optional parameter with test name. +# @param string $prompt (optional) Bash prompt. Default is "/@" +proc assert_complete_homedir {{cmd} {test ""} {prompt /@}} { + if {[string length $test] == 0} { + set test "$cmd should complete ~part to ~full/ if home dir exists" + } + assert_bash_exec {for u in $(compgen -u); do \ + eval test -d ~$u && echo $u; unset u; done} {} /@ users + if {![find_unique_completion_pair $users part full]} { + untested "Not running, no suitable test user found: $test" + } else { + assert_complete "~$full/" "$cmd ~$part" $test -nospace + } +} + + # Source/run file with additional tests if completion for the specified command # is installed in bash, and the command is available. # @param string $command Command to check completion availability for. @@ -602,21 +620,6 @@ proc assert_source_completions {command {file ""}} { } -# Assert that a _filedir_xspec completion is installed for specified command -# @param string $command Command to check completion installation for. -proc assert_xspec_completion_installed {command} { - set test "Completion via _filedir_xspec() should be installed" - set cmd "complete -p $command" - send "$cmd\r" - - set expected "^$cmd\r\ncomplete -F _filedir_xspec $command\r\n/@$" - expect { - -re $expected { pass "$test" } - -re /@ { fail "$test at prompt" } - } -} - - # Sort list. # `exec sort' is used instead of `lsort' to achieve exactly the # same sort order as in bash. @@ -929,7 +932,8 @@ proc find_unique_completion_pair {{list} {partName} {fullName}} { upvar $partName part upvar $fullName full set bestscore 0 - set list [lsort $list] + # Uniquify the list, that's what completion does too. + set list [lsort -unique $list] set n [llength $list] for {set i 0} {$i < $n} {incr i} { set cur [lindex $list $i] @@ -991,8 +995,23 @@ proc start_bash {} { if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash} set env(SRCDIR) $::srcdir set env(SRCDIRABS) $::srcdirabs - exp_spawn $TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc - assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc" + + # PS1, INPUTRC, TERM and stty columns must be initialized + # *before* starting bash to take proper effect. + + # Set fixed prompt `/@' + set env(PS1) "/@" + # Configure readline + set env(INPUTRC) "$::srcdir/config/inputrc" + # Avoid escape junk at beginning of line from readline, + # see e.g. http://bugs.gentoo.org/246091 + set env(TERM) "dumb" + # Ensure enough columns so expect doesn't have to care about line breaks + set stty_init "columns 150" + + exp_spawn $TOOL_EXECUTABLE --norc + assert_bash_exec {} "$TOOL_EXECUTABLE --norc" + assert_bash_exec "source $::srcdir/config/bashrc" } @@ -1023,6 +1042,11 @@ proc start_interactive_test {} { if {[info exists OPT_BASH_XTRACE]} { init_bash_xtrace } + global OPT_BUFFER_SIZE + if {[info exists OPT_BUFFER_SIZE]} { + verbose "Changing default expect match buffer size to $OPT_BUFFER_SIZE" + match_max $OPT_BUFFER_SIZE + } global OPT_TIMEOUT if {[info exists OPT_TIMEOUT]} { global timeout |
