diff options
Diffstat (limited to 'test/lib/library.exp')
-rw-r--r-- | test/lib/library.exp | 103 |
1 files changed, 6 insertions, 97 deletions
diff --git a/test/lib/library.exp b/test/lib/library.exp index 9321c5ca..899d74b6 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -51,7 +51,7 @@ proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {out -1}} { # @param string $command Command to locate proc assert_bash_type {command} { set test "$command should be available in bash" - set cmd "type $command &> /dev/null && echo -n 0 || echo -n 1" + set cmd "type $command &>/dev/null && echo -n 0 || echo -n 1" send "$cmd\r" expect "$cmd\r\n" expect { @@ -508,39 +508,6 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} { } -# Make sure the specified command executed from within Tcl/Expect. -# Fail the test with status UNSUPPORTED if Tcl fails with error "POSIX/ENOENT -# (No such file or directory)", or with the given Tcl failure status command -# (default "unresolved") if other error occurs. -# NOTE: Further tests are assumed if executing the command is successful. The -# test isn't immediately declared to have PASSED if the command is -# executed successful. -# @param string $command -# @param string $stdout (optional) Reference to variable to hold stdout. -# @param string $test (optional) Test title -# @param string $failcmd (optional, default "unresolved") Failure command -# @see assert_bash_exec() -proc assert_exec {cmd {stdout ''} {test ''} {failcmd "unresolved"}} { - if {$test == ""} {set test "$cmd should execute successfully"} - upvar $stdout results - set status [catch {eval exec $cmd} results] - if {$status == 0} { - set result true - } else { - set result false - # Command not found (POSIX/ENOENT = no such file or directory)? - if {[lindex $::errorCode 0] == "POSIX" && [lindex $::errorCode 1] == "ENOENT"} { - # Yes, command not found; - # Indicate test is unsupported - unsupported "$test" - } else { - $failcmd "$test" - } - } - return $result -} - - # Check that no completion is attempted on a certain command. # Params: # @cmd The command to attempt to complete. @@ -584,24 +551,6 @@ 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. @@ -680,26 +629,6 @@ proc get_hosts_avahi {} { } -# Get signals -# This function is written in analogy to the bash function `_signals()' in -# `bash_completion'. -# @param prefix -# @return list Signals starting with `SIG', but with the `SIG' prefix removed. -proc get_signals {{prefix ""}} { - set signals {} - foreach signal [exec bash -c {compgen -A signal}] { - # Does signal start with `SIG'? - if {[string range $signal 0 [expr [string length "SIG"] - 1]] == "SIG"} { - # Remove `SIG' prefix - set signal [string range $signal 3 end] - # Add signal (with dash (-) prefix) to list - lappend signals $prefix$signal - } - } - return $signals -} - - # Initialize tcl globals with bash variables proc init_tcl_bash_globals {} { global BASH_VERSINFO BASH_VERSION COMP_WORDBREAKS LC_CTYPE @@ -717,7 +646,7 @@ proc init_tcl_bash_globals {} { # @return boolean True (1) if completion is installed, False (0) if not. proc assert_install_completion_for {command} { set test "$command should have completion installed in bash" - set cmd "__load_completion $command ; complete -p $command &> /dev/null && echo -n 0 || echo -n 1" + set cmd "__load_completion $command ; complete -p $command &>/dev/null && echo -n 0 || echo -n 1" send "$cmd\r" expect "$cmd\r\n" expect { @@ -811,27 +740,6 @@ proc match_items {items {args {}}} { } - -# Get real command. -# - arg: $1 Command -# - return: Command found, empty string if not found -proc realcommand {cmd} { - set result "" - if [string length [set path [auto_execok $cmd]]] { - if {[string length [auto_execok realpath]]} { - set result [exec realpath $path] - } elseif {[string length [auto_execok greadlink]]} { - set result [exec greadlink -f $path] - } elseif {[string length [auto_execok readlink]]} { - set result [exec readlink -f $path] - } else { - set result $path - } - } - return $result -} - - # Generate filename to save environment to. # @param string $file File-basename to save environment to. If the file has a # `.exp' suffix, it is removed. E.g.: @@ -1043,10 +951,11 @@ proc start_interactive_test {} { 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 + if {![info exists OPT_BUFFER_SIZE]} { + set OPT_BUFFER_SIZE 20000 } + 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 |