[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 8a70568066b882fd1d1c49079e8aefc86526aca9
Freddy Vulto
fvulto at gmail.com
Sat Dec 5 13:54:49 UTC 2009
The following commit has been merged in the master branch:
commit 8a70568066b882fd1d1c49079e8aefc86526aca9
Author: Freddy Vulto <fvulto at gmail.com>
Date: Sat Dec 5 14:53:47 2009 +0100
(testsuite) Centralized test start functions
Code in `unit_start()' and `completion_start()' is merged and put central in
lib/library.exp:
- start_bash()
- source_bash_completion()
- init_tcl_bash_globals()
Global string variable `bash_versinfo_0' is replaced with list variable
`BASH_VERSINFO'.
diff --git a/test/lib/completion.exp b/test/lib/completion.exp
index c7efff6..03b6403 100644
--- a/test/lib/completion.exp
+++ b/test/lib/completion.exp
@@ -8,25 +8,12 @@ proc completion_exit {} {
proc completion_start {} {
- global bash_versinfo_0 COMP_WORDBREAKS TESTDIR TOOL_EXECUTABLE spawn_id
- set test "completion_start"
- set TESTDIR [pwd]
-
- # Start bash and load bash-completion
-
- # If `--tool_exec' option not specified, use "bash"
- if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash}
- exp_spawn $TOOL_EXECUTABLE --rcfile config/bashrc
- assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile config/bashrc"
- assert_bash_exec {BASH_COMPLETION_DIR=$(cd ..; pwd)/contrib}
- assert_bash_exec {BASH_COMPLETION=$(cd ..; pwd)/bash_completion}
- assert_bash_exec {source $BASH_COMPLETION}
- # Fill global var `bash_versinfo_0' with bash major version number
- assert_bash_exec {printf "%s" "${BASH_VERSINFO[0]}"} "" /@ bash_versinfo_0
- assert_bash_exec {printf "%s" "$COMP_WORDBREAKS"} "" /@ COMP_WORDBREAKS
+ start_bash
+ source_bash_completion
+ init_tcl_bash_globals
}; # completion_start()
proc completion_version {} {
- puts "bash-completion-git"
+ puts "$::TESTDIR, bash-$::BASH_VERSION"
}
diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp
index e68a29c..4203b5e 100644
--- a/test/lib/completions/scp.exp
+++ b/test/lib/completions/scp.exp
@@ -109,7 +109,7 @@ if {[match_items [lsort -unique $expected] $test]} {
} else {
# Expected failure (known bug) because of bash-4 bug in quoted words:
# http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html
- if {$bash_versinfo_0 >= 4} {xfail "$test"} {fail "$test"}
+ if {[lindex $::BASH_VERSINFO 0] >= 4} {xfail "$test"} {fail "$test"}
}; # if
sync_after_int $prompt
assert_bash_exec "cd \$TESTDIR"
diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp
index 1cc74ff..a9d239e 100644
--- a/test/lib/completions/screen.exp
+++ b/test/lib/completions/screen.exp
@@ -31,7 +31,7 @@ expect {
# _filedir only works if `-o filenames' is in effect, which isn't the
# case for `screen' on bash-3, so an expected failure (xfail)
-re "\r\nbar\\s+bar bar.d\\s+foo\\s+foo.d" {
- if {$bash_versinfo_0 < 4} {xfail "$test"} {fail "$test"}
+ if {[lindex $BASH_VERSINFO 0] < 4} {xfail "$test"} {fail "$test"}
}
-re $prompt { unresolved "$test at prompt" }
default { unresolved "$test" }
diff --git a/test/lib/library.exp b/test/lib/library.exp
index 3fa1f8e..9517071 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -298,8 +298,8 @@ proc _ltrim_colon_completions {cword items} {
# or bash-version >= 4 and COMP_WORDBREAKS contains a colon
if {
[string first : $cword_out] > -1 && (
- $::bash_versinfo_0 < 4 ||
- ($::bash_versinfo_0 >= 4 && [string first ":" $::COMP_WORDBREAKS] > -1)
+ [lindex $::BASH_VERSINFO 0] < 4 ||
+ ([lindex $::BASH_VERSINFO 0] >= 4 && [string first ":" $::COMP_WORDBREAKS] > -1)
)
} {
for {set i 0} {$i < [llength $items_out]} {incr i} {
@@ -468,6 +468,17 @@ proc bash_sort {items} {
}; # bash_sort()
+# Initialize tcl globals with bash variables
+proc init_tcl_bash_globals {} {
+ global BASH_VERSINFO BASH_VERSION COMP_WORDBREAKS
+ assert_bash_exec {printf "%s" "$COMP_WORDBREAKS"} {} /@ COMP_WORDBREAKS
+ assert_bash_exec {printf "%s " "${BASH_VERSINFO[@]}"} "" /@ BASH_VERSINFO
+ set BASH_VERSINFO [eval list $BASH_VERSINFO]
+ assert_bash_exec {printf "%s" "$BASH_VERSION"} "" /@ BASH_VERSION
+ assert_bash_exec {printf "%s" "$TESTDIR"} "" /@ TESTDIR
+}; # init_tcl_bash_globals()
+
+
# Expect items.
# Break items into chunks because `expect' seems to have a limited buffer size
# @param list $items
@@ -566,6 +577,31 @@ proc _save_env {{file ""}} {
}; # save_env()
+# Source bash_completion package
+proc source_bash_completion {} {
+ assert_bash_exec {BASH_COMPLETION_DIR=$(cd $TESTDIR/..; pwd)/contrib}
+ assert_bash_exec {BASH_COMPLETION=$(cd $TESTDIR/..; pwd)/bash_completion}
+ assert_bash_exec {source $BASH_COMPLETION}
+}; # source_bash_completion()
+
+
+# Start bash running as test environment.
+proc start_bash {} {
+ global TESTDIR TOOL_EXECUTABLE spawn_id
+ set TESTDIR [pwd]
+ # If `--tool_exec' option not specified, use "bash"
+ if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash}
+ exp_spawn $TOOL_EXECUTABLE --rcfile config/bashrc
+ assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile config/bashrc"
+ # Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS
+ # whenever a shopt setting is sourced or eval'ed. Disabling 'history'
+ # makes it not show in tests "Environment should not be modified"
+ # for bash < 3.2.41.
+ # -- FVu, Tue Sep 15 22:52:00 CEST 2009
+ assert_bash_exec {is_bash_version_minimal 3 2 41 || set +o history}
+}; # start_bash()
+
+
# Interrupt completion and sync with prompt.
# Send signals QUIT & INT.
# @param string $prompt (optional) Bash prompt. Default is "/@"
diff --git a/test/lib/unit.exp b/test/lib/unit.exp
index 36096c0..c413c5a 100644
--- a/test/lib/unit.exp
+++ b/test/lib/unit.exp
@@ -8,31 +8,12 @@ proc unit_exit {} {
proc unit_start {} {
- global bash_versinfo_0 COMP_WORDBREAKS TESTDIR TOOL_EXECUTABLE spawn_id
- set test "unit_start"
- set TESTDIR [pwd]
-
- # Start bash and load bash-completion
-
- # If `--tool_exec' option not specified, use "bash"
- if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash}
- exp_spawn $TOOL_EXECUTABLE --rcfile config/bashrc
- assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile config/bashrc"
- assert_bash_exec {BASH_COMPLETION_DIR=$(cd ..; pwd)/contrib}
- assert_bash_exec {BASH_COMPLETION=$(cd ..; pwd)/bash_completion}
- # Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS
- # whenever a shopt setting is sourced or eval'ed. Disabling 'history'
- # makes it not show in tests "Environment should not be modified"
- # for bash < 3.2.41.
- # -- FVu, Tue Sep 15 22:52:00 CEST 2009
- assert_bash_exec {is_bash_version_minimal 3 2 41 || set +o history}
- assert_bash_exec {source $BASH_COMPLETION}
- # Fill global var `bash_versinfo_0' with bash major version number
- assert_bash_exec {printf "%s" "${BASH_VERSINFO[0]}"} "" /@ bash_versinfo_0
- assert_bash_exec {printf "%s" "$COMP_WORDBREAKS"} {} /@ COMP_WORDBREAKS
+ start_bash
+ source_bash_completion
+ init_tcl_bash_globals
}; # unit_start()
proc unit_version {} {
- puts "bash-completion-git"
+ puts "$::TESTDIR, bash-$::BASH_VERSION"
}
diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp
index 5d032eb..1339324 100644
--- a/test/unit/_get_cword.exp
+++ b/test/unit/_get_cword.exp
@@ -82,7 +82,7 @@ sync_after_int
# See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=474094 for useful ideas
# to make this test pass.
set test {a 'b c| should return 'b c}; # | = cursor position
-if {$bash_versinfo_0 <= 3} {
+if {[lindex $::BASH_VERSINFO 0] <= 3} {
set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1}
} else {
set cmd {COMP_WORDS=(a "'" b c); COMP_CWORD=3}
@@ -115,7 +115,7 @@ sync_after_int
set test {a b:c| should return b:c (bash-3) or c (bash-4)}; # | = cursor position
-if {$bash_versinfo_0 <= 3} {
+if {[lindex $::BASH_VERSINFO 0] <= 3} {
set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
set expected b:c
} else {
@@ -130,7 +130,7 @@ sync_after_int
set test {a b:c| with WORDBREAKS -= : should return b:c}; # | = cursor position
-if {$bash_versinfo_0 <= 3} {
+if {[lindex $::BASH_VERSINFO 0] <= 3} {
set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
} else {
set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
@@ -161,7 +161,7 @@ sync_after_int
set test {a b=c| should return b=c (bash-3) or c (bash-4)}; # | = cursor position
-if {$bash_versinfo_0 <= 3} {
+if {[lindex $::BASH_VERSINFO] <= 3} {
set cmd {COMP_WORDS=(a "b=c"); COMP_CWORD=1}
set expected b=c
} else {
--
bash-completion
More information about the Bash-completion-commits
mailing list