160 Commits

Author SHA1 Message Date
Freddy Vulto
736fa43e9f (testsuite) Fix comment 2009-12-12 12:08:07 +01:00
Ville Skyttä
b8ffa2dc48 Add some unit tests for _count_args. 2009-12-11 00:14:02 +02:00
Ville Skyttä
d1da93448f Comment spelling fixes. 2009-12-10 23:53:22 +02:00
Freddy Vulto
b1e58b1a0e Fix __reassemble_comp_words_by_ref()
If a word is made up of multiple word separator characters:

   $ a b::<TAB>  # CWORDS are: a, b, and :: (correct)

__reassemble_comp_words_by_ref() couldn't handle this.  It assumed CWORDS were:

   $ a b::<TAB>  # CWORDS: a, b, : and : (but they're not)

Added test case for this.  To run the automated tests:

   ./runUnit _get_cword.exp
2009-12-10 21:28:24 +01:00
Freddy Vulto
6fe53ef0e6 Fixed completing perl modules containing colons
The solution for bash-4 is to remove the colon from COMP_WORDBREAKS:

   COMP_WORDBREAKS=${COMP_WORDBREAKS//:}

The workaround for bash-3, or bash-4 with a colon in COMP_WORDBREAKS,
is to call:

  __ltrim_colon_completions "$cur"

after completions have been put in COMPREPLY.

See also: E13) Why does filename completion misbehave if a colon appears
in the filename? - Bash FAQ, http://tiswww.case.edu/php/chet/bash/FAQ
2009-12-09 22:13:56 +01:00
Freddy Vulto
08c5878483 Merged __get_cword3 & __get_cword4 to _get_cword
Actually enhanced __get_cword3 to _get_cword, and removed __get_cword4.
__get_cword4 could handle chars to exclude from COMP_WORDBREAKS, but
failed with partial quoted arguments (e.g. "a 'b c|", | = cursor
position).  This was no problem till bash-4.0.35, because bash < 4.0.35
also returned partial quoted arguments incorrectly.  See also:
http://www.mail-archive.com/bug-bash@gnu.org/msg06094.html

Now that bash-4.0.35 returns quoted arguments ok, __get_cword3 is
enhanced to also handle chars to exclude from COMP_WORDBREAKS.  Because
__get_cword3 also handles partial quoted arguments correctly, this makes
__get_cword3 suitable for bash-4 as well.
2009-12-06 23:16:31 +01:00
Freddy Vulto
8a70568066 (testsuite) Centralized test start functions
Code in `unit_start()' and `completion_start()' is merged and put central in
lib/library.exp:
- start_bash()
- source_bash_completion()
- init_tcl_bash_globals()

Global string variable `bash_versinfo_0' is replaced with list variable
`BASH_VERSINFO'.
2009-12-05 14:53:47 +01:00
Freddy Vulto
c4f3e907cd (testsuite) Fix screen test
Completing directories after `screen -c' passes on bash-4 now that
_filedir does a `compopt -o filenames'.
The test yields an expected failure on bash-3.
2009-12-04 22:12:54 +01:00
Freddy Vulto
932a4db5df (testsuite) Fix scp completions
match_items() now does a better job at maintaining a tcl list, that's
probably why the double escaping at scp isn't necessary anymore.
2009-12-03 18:44:30 +01:00
Freddy Vulto
eb860b7b9f Added helper function __expand_tilde_by_ref()
Expands only tilde (~), if first char, in variable.
This function displays bash's capabilities of passing a variable by
reference (variable indirection) which allows us to avoid using a
subshell.  As far as I can see it works surprisingly well?

To run the automated test:

    ./runUnit __expand_tilde_by_ref.exp

Also fixed some testsuite issues regarding list splitting.
2009-12-02 22:38:30 +01:00
Freddy Vulto
048e27bf28 Merge branch 'master' of git+ssh://fvu-guest@git.debian.org/git/bash-completion/bash-completion 2009-12-02 21:15:50 +01:00
Freddy Vulto
c920661b5e (testsuite) Fix ssh test with colon completions
Function `assert_complete()' is becoming hairy but let's wait untill
other completions with other special characters come along before
refactoring.
2009-12-02 21:12:40 +01:00
Ville Skyttä
a6f79a9a69 Add jarsigner, pack200, and unpack200 completions. 2009-11-30 23:01:32 +02:00
Freddy Vulto
a07b5c5ffd Fix expanding quoted tilde in _known_hosts_real.
- Added unit test "Files starting with tilde (~) should work" to
  unit/_known_hosts_real.exp
2009-11-29 14:42:42 +01:00
Freddy Vulto
511b7c7f35 (testsuite) Fix `assert_complete_partial()'
Make sure items are unique before assembling list of completions.
2009-11-29 14:40:46 +01:00
Freddy Vulto
0209fbde2c (testsuite) Detailed _known_hosts_real test for consecutive spaces 2009-11-28 17:35:01 +01:00
Freddy Vulto
a9717be57b (testsuite) Moved location of making-list-unique
Moved making-expected-list-unique out of `match_items()' & `get_hosts()'
into `assert_complete()' because the former are low level functions and
items need not necessarily be unique.  They only need to be unique when
we're actually testing *completions*.
2009-11-25 22:31:29 +01:00
Freddy Vulto
8c94bf6944 (testsuite) Fix superfluous `&&' in get_hosts_avahi() 2009-11-25 21:47:58 +01:00
Ville Skyttä
ef025a78ab Try to install/test arch completion only for the mailman one, not coreutils/util-linux-ng. 2009-11-23 00:29:16 +02:00
Freddy Vulto
75969454c0 (testsuite) Make expected lists unique 2009-11-21 10:18:54 +01:00
Freddy Vulto
2a506ec3f7 (testsuite) Set TERM=dummy only for non-cron
Err, TERM=linux also causes errors when tests are run via cron.
Reset TERM=dummy.
Workaround is to do a CRON=running from within the cron job and only set
TERM=dummy when not run via cron.
2009-11-18 23:45:16 +01:00
Ville Skyttä
2888874fa9 Testsuite: don't use pidof to check if avahi-daemon is running, cf. commit bb8912b06ff09f8fed253e7e5b14916e38a48733. 2009-11-18 23:33:06 +02:00
Freddy Vulto
1bb351e227 (testsuite) Set TERM=linux
The TERM=dummy setting causes backspaces (^H) to appear in stdout when running
from cron.  Changing to TERM=linux should fix the ^H's in stdout AND the bug of
`meta_on' or `meta_off' escape sequences in stdout, caused by a bug in
supposedly libreadline5:

http://old.nabble.com/-PATCH-:-fix-libreadline5-linked-applications-sending-meta_on-or-meta_off-to-stdout-td25557585.html

Steps to reproduce output of ^H with TERM=dummy:

    $ batch
    warning: commands will be executed using /bin/sh
    at> ./runUnit _known_hosts_real.exp --debug < /dev/tty40
    at> ^D

NOTE: You need to connect a terminal (< /dev/tty..) to the test suite
      when running from cron.  See also doc/testing.txt, "Running tests via
      cron".
2009-11-15 21:51:46 +01:00
Ville Skyttä
571e2fb7e1 Testsuite: avoid readline escape junk at beginning of line.
See e.g. http://bugs.gentoo.org/246091
2009-11-10 20:45:59 +02:00
Freddy Vulto
8a80987373 (testsuite) Improved removing cword from cmd
- Refactored code to new function `_remove_cword_from_cmd()'
- Added `cword' parameter to `assert_complete()' and `assert_complete_dir()':

    @param string $cword  (optional) Last argument of $cmd which is an
        argument-to-complete and to be replaced with the longest common
        prefix of $expected.  If empty string (default), `assert_complete'
        autodetects if the last argument is an argument-to-complete by
        checking if $cmd doesn't end with whitespace.  Specifying `cword'
        is only necessary if this autodetection fails, e.g.  when the last
        whitespace is escaped or quoted, e.g. "finger foo\ " or
        "finger 'foo "
2009-11-07 09:57:11 +01:00
Freddy Vulto
573844daa2 (testsuite) Test lftpget only if available 2009-11-07 09:28:14 +01:00
Ville Skyttä
1ff30048fa Add trivial test cases for abook, lftpget, and wtf. 2009-11-03 22:47:35 +02:00
Ville Skyttä
93060b4133 Add k3b completion. 2009-11-03 22:24:41 +02:00
Ville Skyttä
4790b1a0c6 sed usage portability fixes: avoid \+ 2009-11-03 22:04:46 +02:00
Ville Skyttä
a17b2dbc73 Don't assume that apt-get, dpkg-deb, and dpkg-reconfigure are available. 2009-11-03 21:58:22 +02:00
Freddy Vulto
79cffa2d79 (testsuite) Make `configure' test pass 2009-11-02 19:42:03 +01:00
Freddy Vulto
6925ad5081 Mutt fixes
- Added support for `-F configfile'.  This enables using a specially
  crafted muttrc for automated testing.
- Centralized call to _get_cword
- Used _get_pword
- Specified non-wordbreak characters to _get_cword() & _get_pword() for
  bash-4.
- Added automated tests for -f and -A
- Fixed test suite's assert_complete() (test/library.exp) to drop only
  the last element
2009-11-01 10:04:06 +01:00
Freddy Vulto
a55d311ae2 (testsuite) Moved unsetting COMPREPLY 2009-10-31 08:32:58 +01:00
Freddy Vulto
820b7c2602 (testsuite) Fix _known_hosts_real
Clear COMPREPLY after test now that _known_hosts_real is appending
instead of setting COMPREPLY.
2009-10-30 17:18:43 +01:00
Guillaume Rousse
b56a8dfaae fix conflicts 2009-10-04 19:46:01 +02:00
Guillaume Rousse
506e1cb3eb new indentation policy 2009-10-04 19:42:50 +02:00
Freddy Vulto
bb47efd9b6 (testsuite) Allow trailing space on one completion
Within `match_items', if only one completion is generated, an (optional)
trailing space is allowed, because -o nospace might not be in effect.
2009-10-04 18:18:29 +02:00
Freddy Vulto
1be84710d2 Silence completing scp/sftp/ssh -F '' on bash-4
This fixes a bug under bash-4 where completing:

   scp -F 'spaced  conf' <TAB>

causes `dequote' to yield errors:

    bash: eval: line 1: unexpected EOF while looking for matching `''
    bash: eval: line 2: syntax error: unexpected end of file

The bug occurs because of a bug in bash-4.0, where quoted words are split
unintended, see: http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html

Workaround is now to silence `dequote' in case of errors and wait for bash-4 to
be fixed...
2009-10-04 18:14:16 +02:00
Freddy Vulto
9c53f0d6e6 (testsuite) Added empty directories to git
Empty directories are ignored by git.  By putting an empty .gitignore in
the directory, the directory can be added to git.
2009-10-03 09:39:55 +02:00
Freddy Vulto
9eb0ee2851 (test suite) Added global var `bash_versinfo_0'
This variable was introduced by unit/_get_cword.exp but is now upgraded
to a global var.
2009-10-02 16:39:11 +02:00
Freddy Vulto
d2c6b1ede0 (test suite) Added test for dd
Added test "option should be suffixed with ="
This test exhibits the bug (expected failure) that `dd if<TAB>' gets completed
with `\=' instead of `='.
2009-10-02 16:13:46 +02:00
Freddy Vulto
453a55e9c8 (testsuite) Fix assert_bash_exec to match prompt
Added documentation to "Testing" chapter:
- Running tests via cron
- Specifying bash binary
2009-10-02 10:53:00 +02:00
Ville Skyttä
369980bf93 Tell *Emacs to indent comments (sh-indent-comment: t).
Also move indentation settings to end of files and expand *Emacs ones to
local variables block to avoid overflowing 80 char lines.
2009-10-01 20:54:51 +03:00
Freddy Vulto
9501c0fa90 (testsuite) Fix assert_bash_exec output parameter
Changed `out' parameter of `assert_bash_exec()' to accept also -1 and 0:

@param mixed $out  (optional) Reference to variable to hold output.
    If variable equals -1 (default) the bash command is
    expected to return no output.  If variable equals 0,
    any output from the bash command is disregarded.

This fixes the situation of commit cfcf9fa where contrib/ri was causing
invisible errors when running the test suite.
2009-09-26 11:00:02 +02:00
Freddy Vulto
b66425e8cf (testsuite) Remove test with non-portable filenames
Files containing a star (*) aren't support on FAT, thus Cygwin.
Closes Alioth #311979.
2009-09-25 20:28:00 +02:00
Freddy Vulto
f733e71e1f Split _get_cword into bash-3/4 versions
- Added code comments to _get_cword, __get_cword3 & __get_cword4
- (testsuite) Added tests for _get_cword
- (testsuite) Bugfixes assert_bash_exec() && match_items()

Bash-4 splits COMP_WORDS using characters from COMP_WORDBREAKS, but has
a bug where quoted words are also splitted, see:
http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html

__get_cword3 is used for bash-2/3 and __get_cword4 is used for bash-4.
__get_cword4 handles well temporarily disabling of COMP_WORDBREAK
characters, but fails quoted words (a 'b c) and subshells (a $(b c).
See the expected failures when running the automated tests.
__get_cword3 does a better job of returning quoted words.

To run the automated tests on bash-3/4:

    $ ./runUnit _get_cword.exp [--tool_exec <path to bash-3/4 binary>]
2009-09-20 14:11:26 +02:00
Freddy Vulto
fcf2bf91c9 (testsuite) Added `stdout' to assert_bash_exec()
Added support to assert_bash_exec() to retrieve bash output within
tcl/expect.
2009-09-20 13:07:04 +02:00
Freddy Vulto
fc3f65e6dd (testsuite) Supported specifying bash binary
Using option `--tool_exec' you can now specify which bash binary you
want to use:

    $ ./runUnit --tool_exec /opt/bash-4/bin/bash
    $ ./runCompletion --tool_exec /opt/bash-4/bin/bash

If not specified, current `bash' as found in the tcl path (/bin/bash)
will be used.
2009-09-20 12:59:08 +02:00
Freddy Vulto
046f2abc6f (testsuite) Tighten `match_items()'
An item now must match at the beginning of the line, to prevent
mismatches.
2009-09-16 23:17:56 +02:00
Freddy Vulto
171fc0e3c6 (testsuite) Added more tests for _get_cword
To run the tests:

   cd test && ./runUnit _get_cword.exp
2009-09-16 22:20:15 +02:00