(testsuite) Unset COMP_ variables at setup()

The COMP_ settings of the last test of _count_args() were falling through to
the first test of _get_cword(), causing it to fail.

Unset COMP_ variables within the unit tests setup & teardown.

Fixed last test at `_count_args.exp' by solving conflicting settings of
COMP_CWORD and COMP_POINT.

Steps to reproduce the problem:

    $ ./runUnit _count_args.exp _get_cword.exp
    ...
    Running ./unit/_count_args.exp ...
    Running ./unit/_get_cword.exp ...
    ERROR Unexpected output from bash command "_get_cword should run without errors":
    bash: $index: substring expression < 0
    ...
This commit is contained in:
Freddy Vulto 2009-12-12 12:36:38 +01:00
parent 736fa43e9f
commit 359d242a49
2 changed files with 5 additions and 10 deletions

View File

@ -1,15 +1,12 @@
proc setup {} {
assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
save_env
}; # setup()
proc teardown {} {
assert_bash_exec {unset args COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
assert_env_unmodified {
/args=/d
/COMP_CWORD=/d
/COMP_LINE=/d
/COMP_POINT=/d
/COMP_WORDS=/d
# Delete 'COMP_WORDBREAKS' occupying two lines
/COMP_WORDBREAKS=/{N
d}
@ -60,7 +57,7 @@ sync_after_int
set test "a b -c| d should set args to 2"; # | = cursor position
set cmd {COMP_WORDS=(a b -c d); COMP_CWORD=3; COMP_LINE='a b -c d'; COMP_POINT=6; _count_args; echo -n $args}
set cmd {COMP_WORDS=(a b -c d); COMP_CWORD=2; COMP_LINE='a b -c d'; COMP_POINT=6; _count_args; echo -n $args}
assert_bash_list 2 $cmd $test

View File

@ -1,14 +1,12 @@
proc setup {} {
assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
save_env
}; # setup()
proc teardown {} {
assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
assert_env_unmodified {
/COMP_CWORD=/d
/COMP_LINE=/d
/COMP_POINT=/d
/COMP_WORDS=/d
# Delete 'COMP_WORDBREAKS' occupying two lines
/COMP_WORDBREAKS=/{N
d}