[Bash-completion-devel] [Bash-completion-commits] e7d7ae81 (testsuite) Always look for command availability before testing completion.

Freddy Vulto fvulto at gmail.com
Sun Jan 31 10:31:52 UTC 2010


On 100131 00:29, Crestez Dan Leonard wrote:
> I don't understand why every test has two files.

The two-files system stem from bash-completion-lib
(http://code.google.com/p/bash-completion-lib/, which I hope we can implement
soon) where tests are run twice per completion; once before dynamic loading and
a second time after to confirm that all dynamic loading has gone well.

For example (http://code.google.com/p/bash-completion-lib/source/browse/trunk/test/completionLib/awk.exp):

---8<-------------------------------------------------------------------
set test "Completion via comp_load() should be installed"
set cmd "complete -p awk"
send "$cmd\r"
expect {
    -re "^$cmd\r\ncomplete -o filenames -F comp_load awk\r\n/@$" { pass "$test" }
    -re /@ { fail "$test at prompt" }
}; # expect


source "lib/completions/awk.exp"


set test "Completion via _longopt() should be installed"
set cmd "complete -p awk"
send "$cmd\r"
expect {
    -re "^$cmd\r\ncomplete -o filenames -F _longopt awk\r\n/@$" { pass "$test" }
    -re /@ { fail "$test at prompt" }
}; # expect


source "lib/completions/awk.exp"
---8<-------------------------------------------------------------------

Looking to tests from a broader perspective, every test for a command has two
stages which are now reflected in the two files:
1. Tests concerning the command completions' environment (typically in test/completion/foo)
2. Tests invoking actual command completion (typically in test/lib/completions/foo)


I agree with your first point though, some completions work without calling the
actual command, so it's not always necessary to test if the command is really
available.

I think the tests in `completion/foo' for now should reflect the use of `have
<command> && ...' on the bash-side.  For example, because `contrib/perl' on the
bash-side contains `have *perl*':

    have perl && {
        complete .. perl
        complete .. perldoc
    }

, the test `completion/perldoc' should test for the availibility of *perl* and
not *perldoc* (as it does now..., having my signature, changing it right
away ;-)

    if {[assert_bash_type perl]} {
        source "lib/completions/perldoc.exp"
    }; # if


Regards,

Freddy Vulto
http://fvue.nl




More information about the Bash-completion-devel mailing list