bash-completion/test/unit/compgen.exp
2010-06-18 17:21:38 +02:00

53 lines
1.1 KiB
Plaintext

proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified {/OLDPWD/d}
}
setup
if {[lindex $::BASH_VERSINFO 0] <= 3} {
set test {compgen -f a\\\\\\\'b/ on bash-3 should return a\'b/c};
set cmd {compgen -f a\\\\\\\'b/}
} else {
set test {compgen -f a\\\'b/ on bash-4 should return a\'b/c};
set cmd {compgen -f a\\\'b/}
}
set dir fixtures/compgen
set prompt "/$dir/@"
assert_bash_exec "cd $dir" "" $prompt
send "$cmd\r"
expect -ex "$cmd\r\n"
expect {
-re {a\\\'b/c} {
# On bash-3.2, compgen returns inconsequent output
if {
[lindex $::BASH_VERSINFO 0] >= 4 || (
[lindex $::BASH_VERSINFO 0] == 3 &&
[lindex $::BASH_VERSINFO 1] == 2
)
} {pass $test} else {fail $test}
}
-re {a'b/c} {
if {[lindex $::BASH_VERSINFO 0] <= 3 } \
{pass $test} else {fail $test}
}
-re $prompt { pass "$test" }
-re eof { unresolved "eof" }
}
sync_after_int $prompt
assert_bash_exec {cd "$TESTDIR"}
#assert_bash_list_dir {a\\\'b/c} $cmd fixtures/compgen
sync_after_int
teardown