[Bash-completion-commits] [SCM] bash-completion branch, master, updated. f733e71e1f8d63c072a402346d8162f9c6b63ae2
Freddy Vulto
fvulto at gmail.com
Sun Sep 20 12:13:25 UTC 2009
The following commit has been merged in the master branch:
commit fcf2bf91c95270d5dc3fc613254e434d22f9b955
Author: Freddy Vulto <fvulto at gmail.com>
Date: Sun Sep 20 13:07:04 2009 +0200
(testsuite) Added `stdout' to assert_bash_exec()
Added support to assert_bash_exec() to retrieve bash output within
tcl/expect.
diff --git a/test/lib/library.exp b/test/lib/library.exp
index cf92d65..107a9ab 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -13,14 +13,26 @@ package require textutil::string
# checked; specify `title' to adorn the error message.
# @param string $title (optional) Command title. If empty, `cmd' is used.
# @param string $prompt (optional) Bash prompt. Default is "/@"
-proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@}} {
+# @param string $stdout (optional) Reference to variable to hold stdout.
+proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {stdout ''}} {
+ upvar $stdout results
if {[string length $aCmd] != 0} {
send "$aCmd\r"
expect -ex "$aCmd\r\n"
}; # if
if {[string length $title] == 0} {set title $aCmd}
expect -ex $prompt
- set out $expect_out(buffer); # Catch (non-expected) output
+ set results $expect_out(buffer); # Catch output
+ # Remove $prompt suffix from output
+ set results [
+ string range $results 0 [
+ expr [string length $results] - [string length "/@"] - 1
+ ]
+ ]
+
+
+
+
set cmd "echo $?"
send "$cmd\r"
expect {
@@ -222,7 +234,7 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} {
# Prepare sed script
# Escape special bash characters ("\)
- regsub -all {([\"\\])} $sed {\\\1} sed
+ regsub -all {([\"\\])} $sed {\\\1} sed; #"# (fix Vim syntax highlighting)
# Escape newlines
regsub -all {\n} [string trim $sed] "\r\n" sed
@@ -468,4 +480,4 @@ proc wd {} {
global TESTDIR
# Remove `$TESTDIR' prefix from current working directory
set wd [string replace [pwd] 0 [expr [string length $TESTDIR] - 1]]/
-}
+}; # wd()
--
bash-completion
More information about the Bash-completion-commits
mailing list