25 Commits

Author SHA1 Message Date
Ville Skyttä
b8ffa2dc48 Add some unit tests for _count_args. 2009-12-11 00:14:02 +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
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
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
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
0209fbde2c (testsuite) Detailed _known_hosts_real test for consecutive spaces 2009-11-28 17:35:01 +01:00
Freddy Vulto
a55d311ae2 (testsuite) Moved unsetting COMPREPLY 2009-10-31 08:32:58 +01: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
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
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
Freddy Vulto
e20a4cb06e Added unit tests for _get_cword
These are the tests (| = cursor position):
1.  a b| should return b
2.  a | should return nothing
3.  a b|c should return b
4.  a b\ c| should return b\ c
5.  a 'b c| should return 'b c
6.  a "b c| should return "b c
7.  a b:c| should return c
8.  a b:c| with WORDBREAKS -= : should return b:c
9.  a -n| should return -n

Tests 5 & 6 yield "expected failures", see bugreport:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=474094 .  At a first glance
this bugreport contains useful ideas, so anyone willing to try to make tests 5 &
6 pass, be sure to have a look there first.

To run the automated tests:

    $ cd test && ./runUnit _get_cword.exp
2009-09-07 00:26:27 +02:00
Freddy Vulto
de585f387d Fix _known_hosts_real() to not glob awk script
See also bugreport Alioth #311614.

Added tests for the awk script processing IP numbers.  To run the tests:

   cd test
   ./runUnit _known_hosts_real.exp
   ./runCompletion ssh.exp scp.exp sftp.exp
2009-09-04 23:08:56 +02:00
Freddy Vulto
31f03cfb82 Fix for known_host files containing * character
Quote sed output ("\1") retrieving "GlobalKnownHostsFile/UserKnownHostsFile" to
prevent bash globbing of special characters, e.g. '*'.

Added unit test "Config file containing star (*) should work".
Added test library function `assert_bash_list()'.
To run unit tests:

    cd test && ./runUnit _known_hosts_real.exp
2009-08-23 09:38:19 +02:00
Freddy Vulto
9af88e6bd4 Fix unit test _known_hosts_real
Test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE" now
includes hosts reported by avahi.
2009-08-18 21:28:43 +02:00
Freddy Vulto
2e87bd4c01 Added setting COMP_KNOWN_HOSTS_WITH_HOSTFILE
`_known_hosts_real' will add hosts from HOSTFILE (compgen -A hostname), unless
`COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.

To run the unit tests:

   $ cd test && ./runUnit _known_hosts_real.exp
2009-08-12 22:20:56 +02:00
Freddy Vulto
3fe193f81a Fix completing multiple hosts (Debian: #535585)
Fixed `_known_hosts_real' to allow for multiple patterns in ssh config, e.g.:

    Host foo.example.net bar.example.net

IFS was set to just newline (\n), whereas `compgen -W' relies on IFS
being space-tab-newline ( \t\n) to expand hostnames which are separated
by whitespace.
Tests are updated as well (added host `jar' to config).  To run the tests:

    ./runUnit _known_hosts_real.exp
2009-07-07 23:05:03 +02:00
Freddy Vulto
25e4eb6df3 Gave _known_hosts_real mandatory argument CWORD
The option `-h hostname' to `_known_hosts_real' is removed.
2009-07-03 22:28:13 +02:00
Freddy Vulto
c769eeaf8c (testsuite) Centralized tcl function `get_hosts' 2009-06-19 14:56:36 +02:00
Freddy Vulto
362090a160 Updated test _known_hosts_real.
Added hosts retrieved by avahi-browse.
2009-06-19 12:33:50 +02:00
Freddy Vulto
b1d869cbf2 Renamed unit test _known_hosts > _known_hosts_real 2009-06-13 08:42:22 +02:00
Freddy Vulto
cd2b62bd62 Fix quotes _known_hosts calling _known_hosts_real
This fixes test "Config file containing space should work".  See test:

   ./runUnit _known_hosts.exp
2009-06-11 21:26:43 +02:00
Freddy Vulto
b74997084e Added unit test for _get_cword 2009-06-09 23:52:47 +02:00
Freddy Vulto
e847d57e50 Improved test suite from bash-completion-lib
Run the tests with:
$ cd test
$ ./runCompletionUnit
$ ./runCompletionCompletion

The last test of unit/_known_hosts gives UNRESOLVED and needs fixing.
2009-06-09 22:49:53 +02:00