259 lines
5.8 KiB
Plaintext
259 lines
5.8 KiB
Plaintext
proc setup {} {
|
|
assert_bash_exec {unset COMPREPLY cur}
|
|
assert_bash_exec {unset -f _f}
|
|
save_env
|
|
# Declare bash completion function `_f'
|
|
assert_bash_exec { \
|
|
_f() { local cur=$(_get_cword); unset COMPREPLY; _filedir; }; \
|
|
complete -F _f f \
|
|
}
|
|
# Declare bash completion function `_f2' with `-o filenames' active.
|
|
assert_bash_exec { \
|
|
complete -F _f -o filenames f2 \
|
|
}
|
|
# Declare bash completion function `_g' to complete on `.e1' files
|
|
assert_bash_exec { \
|
|
_g() { local cur=$(_get_cword); unset COMPREPLY; _filedir e1; }; \
|
|
complete -F _g g \
|
|
}
|
|
# Create directories `a*b' and `a\b' only when not running on Cygwin/Windows;
|
|
# directories containing `*' or `\' aren't allowed on Cygwin/Windows
|
|
if {! [is_cygwin]} {
|
|
# Create directory `a*b'
|
|
assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\*b ] && mkdir a\*b && touch a\*b/j || true)}
|
|
# Create directory `a\b'
|
|
assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\\b ] && mkdir a\\b && touch a\\b/g || true)}
|
|
}
|
|
}
|
|
|
|
|
|
proc teardown {} {
|
|
if {! [is_cygwin]} {
|
|
assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\\b/g && rmdir a\\b/ || true)}
|
|
assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\*b/j && rmdir a\*b/ || true)}
|
|
}
|
|
assert_bash_exec {unset COMPREPLY cur}
|
|
assert_bash_exec {unset -f _f _g}
|
|
assert_bash_exec {complete -r f g}
|
|
assert_env_unmodified {
|
|
/OLDPWD/d
|
|
/OLD_CTYPE/d
|
|
}
|
|
}
|
|
|
|
|
|
setup
|
|
|
|
|
|
set test "_filedir should run without errors"
|
|
assert_bash_exec {_filedir > /dev/null} $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
foreach name {f f2} {
|
|
|
|
set test "completing $name ab/ should return e"
|
|
set cmd "$name ab/"
|
|
assert_complete_dir e $cmd "$::srcdir/fixtures/_filedir" $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "completing $name a\\ b/ should return i"
|
|
set cmd "$name a\\ b/"
|
|
assert_complete_dir i $cmd "$::srcdir/fixtures/_filedir" $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "completing $name a\\\'b/ should return c"
|
|
set cmd "$name a\\\'b/"
|
|
assert_complete_dir c $cmd "$::srcdir/fixtures/_filedir" $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "completing $name a\\\"b/ should return d"; #"
|
|
set cmd "$name a\\\"b/"; #"
|
|
assert_complete_dir d $cmd "$::srcdir/fixtures/_filedir" $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "completing $name a\\\$b/ should return h"
|
|
set cmd "$name a\\\$b/"
|
|
assert_complete_dir "\b\b\b\b\b$::srcdirabs/fixtures/_filedir/a\\\\\$b/h" \
|
|
$cmd "$::srcdir/fixtures/_filedir" $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
# Execute these tests only when not running on Cygwin/Windows, because
|
|
# directories containing asterisk (*) or backslash (\) aren't allowed on
|
|
# Cygwin/Windows
|
|
if {! [is_cygwin]} {
|
|
set test "completing $name a\\\\b/ should return g"
|
|
set cmd "$name a\\\\b/"
|
|
assert_complete_dir g $cmd "$TESTDIR/tmp" $test
|
|
|
|
|
|
sync_after_int
|
|
}
|
|
|
|
|
|
set test "completing $name a\\&b/ should return f"
|
|
set cmd "$name a\\&b/"
|
|
assert_complete_dir f $cmd "$::srcdir/fixtures/_filedir" $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "completing $name a\$ should return a\\\$b/"
|
|
set cmd "$name a\$"
|
|
assert_complete_dir "\b\\\\\$b/" $cmd "$::srcdir/fixtures/_filedir" $test -nospace
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name 'ab/"
|
|
assert_complete_dir {e'} $cmd "$::srcdir/fixtures/_filedir"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name 'a b/"
|
|
assert_complete_dir {i'} $cmd "$::srcdir/fixtures/_filedir"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name 'a\"b/"; #"
|
|
assert_complete_dir {d'} $cmd "$::srcdir/fixtures/_filedir"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name 'a\$b/"
|
|
assert_complete_dir {h'} $cmd "$::srcdir/fixtures/_filedir"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
# Execute these tests only when not running on Cygwin/Windows, because
|
|
# directories containing `*' or `\' aren't allowed on Cygwin/Windows
|
|
if {! [is_cygwin]} {
|
|
set cmd "$name '$TESTDIR/tmp/a\\b/"
|
|
assert_complete_dir {g'} $cmd "$TESTDIR/tmp"
|
|
|
|
|
|
sync_after_int
|
|
}
|
|
|
|
|
|
set cmd "$name 'a&b/"
|
|
assert_complete_dir {f'} $cmd "$::srcdir/fixtures/_filedir"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"ab/"; #"
|
|
assert_complete_dir {e"} $cmd "$::srcdir/fixtures/_filedir"; #"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"a b/"; #"
|
|
assert_complete_dir {i"} $cmd "$::srcdir/fixtures/_filedir"; #"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"a'b/"; #"
|
|
assert_complete_dir {c"} $cmd "$::srcdir/fixtures/_filedir"; #"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"a\\\"b/"; #"
|
|
assert_complete_dir {d"} $cmd "$::srcdir/fixtures/_filedir"; #"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"a\\\$b/"; #"
|
|
assert_complete_dir "\b\b\b\b\b$::srcdirabs/fixtures/_filedir/a\\\\\$b/h\\\"" $cmd "$::srcdir/fixtures/_filedir"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"a\\b/"; #"
|
|
assert_complete_dir "\b\b\bb/e\\\"" $cmd "$::srcdir/fixtures/_filedir"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"a\\\\b/"; #"
|
|
assert_complete_dir {g"} $cmd "$TESTDIR/tmp"; #"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set cmd "$name \"a&b/"; #"
|
|
assert_complete_dir {f"} $cmd "$::srcdir/fixtures/_filedir"; #"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
}; # foreach
|
|
|
|
|
|
set test "completing with filter '.e1' should show completions"
|
|
assert_complete_dir {ee.e1 foo/ gg.e1 ii.E1} "g " "$::srcdir/fixtures/_filedir/ext" $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "completing f aé should return g"
|
|
# Execute this test only with LC_CTYPE matching *UTF-8*
|
|
# See also: http://www.mail-archive.com/bash-completion-devel\
|
|
# @lists.alioth.debian.org/msg02265.html
|
|
# Don't execute this test on expect-5.44 cause it will segfault
|
|
# See also: Alioth #312792
|
|
if {
|
|
[string first "UTF-8" $::LC_CTYPE] != -1 &&
|
|
[string first 5.44 [exp_version]] != 0
|
|
} {
|
|
assert_complete_dir g "f aé/" "$::srcdir/fixtures/_filedir"
|
|
} else {
|
|
unsupported "$test"
|
|
}
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
teardown
|