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

Freddy Vulto fvulto at gmail.com
Tue Feb 2 17:41:25 UTC 2010


On 01:02, Ville Skyttä wrote:
> On Sunday 31 January 2010, Freddy Vulto wrote:
> > I think the tests in `completion/foo' for now should reflect the use of
> >  `have <command> && ...' on the bash-side.
> 
> Wouldn't it be more appropriate to check "do we have completion for command 
> foo installed" instead of checking "do we have command foo installed" before 
> invoking the tests?  There are some other considerations besides command 
> availability (uname, userland, maybe others) in the equation.  For example 
> look for "complete -p foo" exit status to see if we have completion for 
> command foo installed.
> 
> > , the test `completion/perldoc' should test for the availibility of *perl*
> >  and not *perldoc*
> 
> Well, IMHO both contrib/perl and test/completion/perldoc should check for both 
> perl and perldoc availability... no need to define _perldoc() if perldoc is 
> not installed.

Yes, you're right.  Checking if a command exists in the test suite is
not the right way.  Testing if the completion is really installed, like
you propose, seems to make more sense.  Maybe we can wrap `complete -p
<cmd>' in the test suite like:

    assert_bash_complete <cmd>

So for `test/completion/perldoc' we would then do:

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

For simple cases, maybe it's useful to wrap this further into a
`source_if_installed', so we can just say:

    source_if_installed perldoc


Freddy Vulto
http://fvue.nl



More information about the Bash-completion-devel mailing list