176 Commits

Author SHA1 Message Date
Freddy Vulto
bdca37a7bf Improve _get_comp_words_by_ref to return words' and cword'
Usage: _get_comp_words_by_ref [OPTIONS] [VARNAMES]
Available VARNAMES:
    cur         Return cur within varname "cur"
    prev        Return prev within varname "prev"
    words       Return words within varname "words"
    cword       Return cword within varname "cword"

Available OPTIONS:
    -n EXCLUDE  Characters out of $COMP_WORDBREAKS which should NOT be
                considered word breaks. This is useful for things like scp
                where we want to return host:path and not only path, so we
                would pass the colon (:) as -n option in this case.  Bash-3
                doesn't do word splitting, so this ensures we get the same
                word on both bash-3 and bash-4.
    -c VARNAME  Return cur within specified VARNAME
    -p VARNAME  Return prev within specified VARNAME
    -w VARNAME  Return words within specified VARNAME
    -i VARNAME  Return words within specified VARNAME

Example usage:

   $ _get_comp_words_by_ref -n : cur prev
2010-03-14 11:07:13 +01:00
Freddy Vulto
2cd91420d2 Merge branch 'fvu' 2010-02-07 15:21:44 +01:00
Freddy Vulto
b529cee550 Added _get_comp_words_by_ref()
This solves the following problems:
- now one function call suffices instead of two (_get_cword; _get_pword) if
  subsequent words need to be retrieved.  Also more than two words can be
  retrieved at once, e.g.: _get_comp_words_by_ref cur prev prev2 prev3
  Also this prevents passing of `wordbreakchars' to differ in calls to
  `_get_cword' and `_get_pword', e.g.: _get_comp_words_by_ref -n : cur prev
- passing by reference, no subshell call necessary anymore
- _get_pword now also takes into account the cursor position

Added testsuite proc `assert_no_output()'

Word of caution:

The passing-arguments-by-ref system in bash doesn't work if the new variable is
also declared local.  For example:

    t() {
        local a
        # ...
        eval $1=b
    }
    a=c; t a; echo $a  # Outputs "c", should be "b"
                       # Variable "a" is 'forbidden'

To make name collissions like this less likely to happen, but make the real
function still use readable variables, I've wrapped the `*_by_ref'
functions within an additional layer using variables prefixed with double
underscores (__).  For example:

    _t() {
        # Readable variables can still be used here
        local a
        # ...
        eval $1=b
    }
    t() {
        local __a
        _t __a
        eval $1=\$__a
    }
    a=c; t a; echo $a  # Outputs "b"
                       # Variable "__a" is 'forbidden'

Now only more obfuscated variables (starting with double prefix (__)) are
forbidden to use.
2010-02-07 15:18:58 +01:00
Crestez Dan Leonard
c72e20b42f Merge branch 'find-unique-completion-pair' 2010-02-07 01:09:17 +02:00
Ville Skyttä
6810e55645 (testsuite) Fix chown basic user completion test on systems with lots of users. 2010-02-05 22:44:04 +02:00
Ville Skyttä
35ebc8aec8 (testsuite) Add lftp hostname completion testing fixture. 2010-02-05 22:19:34 +02:00
Freddy Vulto
dc4d28bc11 (testsuite) mv fixture1 fixtures/shared/default 2010-02-05 15:16:19 +01:00
Freddy Vulto
c70c1ecb31 (testsuite) Added helper functions
- assert_source_completions()
- is_bash_completion_installed_for()

This allows for cleaner invocation of tests in `lib/completions/'.  For
example, `completion/perldoc.exp' now just contains:

    assert_source_completions perldoc

Skeleton test files for a command can be generated with:

    $ ./generate <command>
2010-02-05 14:35:45 +01:00
Freddy Vulto
9b9bbab1ff (testsuite) Fix ssh test
Fix ssh test "First argument shouldn't complete with commands" if one
has hosts starting with "bas" in known hosts. (Alioth #312292)
2010-02-05 08:45:44 +01:00
Crestez Dan Leonard
ce624f7983 Use find_unique_completion_pair in chown test 2010-02-03 14:09:31 +02:00
Crestez Dan Leonard
2ad9001556 Add a find_unique_completion_pair proc.
Given a list of items this proc finds a (part, full) pair so that when
completing from $part $full will be the only option.
2010-02-03 14:08:55 +02:00
Leonard Crestez
61f83856fb (testsuite) Fix chown test "crash" if root user/group is N/A (Alioth: 312306). 2010-02-01 21:29:47 +02:00
Freddy Vulto
d358036572 (testsuite) Fix assert_bash_type perldoc > perl
Make `assert_bash_type' reflect bash-side where `have perl' is checked,
and not perldoc, to determine whether `perldoc' completion should be
installed.
2010-01-31 11:37:29 +01:00
Ville Skyttä
db9c42340c (testsuite) Sync fmt test with other longopt only tests. 2010-01-30 15:04:02 +02:00
Ville Skyttä
8f4111d5a4 (testsuite) Don't fail long option tests if command has no long options.
Many basic commands do not have long options on non-GNU systems, mark such
tests as unsupported (if the command doesn't respond to --help) instead of
failing.

Implemented with the new $failcmd parameter to assert_exec().
2010-01-30 14:56:39 +02:00
Ville Skyttä
b996ff01cb (testsuite) Add java -jar test. 2010-01-30 12:36:29 +02:00
Ville Skyttä
050fb91d40 (testsuite) Add some java classpath tests. 2010-01-30 12:25:13 +02:00
Freddy Vulto
1061876bbc Merge branch 'fvu' 2010-01-29 23:24:58 +01:00
Freddy Vulto
d866854066 Fix _usergroup, cpio and chown completions
Improve test suite.
Thanks to Leonard Crestez (Alioth: #311396, Debian: #511788).

`assert_complete' is improved.  It proved difficult to tell tcl to ignore
backslash escapes, e.g. the `\b' is no BACKSPACE but a literal `b'.  The added
function `split_words_bash' should to the trick now.

Added function `assert_no_complete' which can also be reached by calling
`assert_complete' with an empty `expected' argument:

    assert_complete "" qwerty
2010-01-29 23:23:30 +01:00
Ville Skyttä
e7d7ae81ef (testsuite) Add missing assert_env_unmodified tests. 2010-01-28 01:07:44 +02:00
Ville Skyttä
f3b791baeb (testsuite) Always look for command availability before testing completion. 2010-01-28 01:00:20 +02:00
Ville Skyttä
f579b38410 (testsuite) Include shopt states in saved environment. 2010-01-28 00:58:17 +02:00
Ville Skyttä
dc8af65161 (testsuite) Use kern instead of fs to test sysctl completion.
FreeBSD does not have fs.* (has vfs.* instead).  Linux has kernel.*,
FreeBSD kern.*.
2010-01-24 23:58:46 +02:00
Ville Skyttä
c0d57b0bea (testsuite) Use File::Path instead of HTML::Parser to test perldoc.
HTML::Parser is not a "core" Perl module.
2010-01-24 23:36:01 +02:00
Ville Skyttä
5c6f45d5bb (testsuite) Add cvs roots completion test. 2010-01-24 23:35:32 +02:00
Ville Skyttä
89e52de0c5 (testsuite) Fix cvsps non-option completion test, add test for options.
"cvsps " completion failed when there was nothing in ~/.cvspass,
create a fixture for generic cvs use containing one, and use it.
2010-01-24 23:32:19 +02:00
Leonard Crestez
c5951118e9 Fix NFS mounts completion (Alioth: #312285). 2010-01-24 19:27:15 +02:00
Freddy Vulto
dde071d009 (testsuite) Fixed finger test
Added test suite function `get_known_hosts' which calls bash's `_known_hosts_real'.

Also the `finger' test "Tab should complete partial hostname" now skips hosts starting with character in COMP_WORDBREAKS leaving that to test for another test case.

See also: https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312220&group_id=100114
2010-01-24 10:32:41 +01:00
Ville Skyttä
7e03431ed7 (testsuite) Add basic tests for make. 2010-01-19 23:13:14 +02:00
Ville Skyttä
42b839e817 (testsuite) Enable cvs test. 2010-01-19 23:12:07 +02:00
Ville Skyttä
5d9e4f0c69 (testsuite) Enable gzip and bzip2 tests. 2010-01-18 19:20:40 +02:00
Ville Skyttä
556d1304d0 (testsuite) Add check for awk with POSIX character classes. 2010-01-17 15:36:01 +02:00
Ville Skyttä
942b916aa1 (testsuite) Don't fail dcop test if a DCOP server is not running. 2010-01-16 17:30:26 +02:00
Ville Skyttä
f8eec776e2 Weed out look completions not starting with current word.
Some versions of the default word list for look may return
non-completable entries (e.g. due to sort order mismatch -- dictionary
vs non-dictionary one, case sensitivity etc -- between sort order in
default word list and look's defaults).  As a side effect, fixes also
the test case when a lot of words are returned.
2010-01-16 17:30:02 +02:00
Ville Skyttä
f0c717b2be (testsuite) cd to correct top level dir first in runLint. 2010-01-16 15:54:28 +02:00
Ville Skyttä
8d6570670a (testsuite) It's not the empty alternative that's unportable with sed, it's \|. 2010-01-16 15:17:35 +02:00
Ville Skyttä
45698f2ae8 (testsuite) Add simple "lint" script for finding common issues.
Currently flags one potential awk issue in wireless-tools, but that
should be a non-issue because wireless-tools is a Linux thing.
2010-01-16 13:55:00 +02:00
Ville Skyttä
6a7a838310 (testsuite) Check rpm -q completion against actual installed packages.
While at it, drop --eval completion test because I couldn't get it to
work with assert_complete (probably because I couldn't escape the
command properly here, see --eval|-E completion in contrib/rpm), and
no longer needed match_max fiddling.
2010-01-16 12:59:21 +02:00
Ville Skyttä
ef7f9dc89e (testsuite) Allow possibly leading whitespace in match_items() chunks > 1.
Thanks to Freddy Vulto.
2010-01-16 12:56:29 +02:00
Adrian Friedli
e8f6edc5af Add ipv6calc completion. 2010-01-14 21:19:09 +02:00
Ville Skyttä
51a772f99f (testsuite) assert_exec() default test title grammar fix. 2010-01-14 20:19:52 +02:00
Ville Skyttä
9f49a10117 (testsuite) Escape more regexp metacharacters. 2010-01-09 12:46:49 +02:00
Ville Skyttä
66f5c11ab7 (testsuite) Add simple rpm completion tests. 2010-01-09 12:24:19 +02:00
Ville Skyttä
eb70bc8431 (testsuite) Fix ypmatch test case.
Completion is done for ypmatch's 2nd arg only at the moment.
2010-01-06 13:20:28 +02:00
Ville Skyttä
77dee3a323 (testsuite) FreeBSD and Solaris sed compatibility fixes.
The linefeed between the final "d" and "}" seems to be significant for
these versions of sed.  And they are quite anal about comments, so
move them outside of the sed statement here.
2010-01-03 23:49:19 +02:00
Ville Skyttä
25a0fcf1b4 Hook up openssl tests, do env modification checks. 2010-01-03 16:25:33 +02:00
Ville Skyttä
360b3dbe19 (testsuite) Indentation fixes. 2010-01-03 15:56:00 +02:00
Ville Skyttä
3d43cdfd2b (testsuite) Remove some obsolete comments. 2010-01-03 15:52:18 +02:00
Ville Skyttä
ec3227366a (testsuite) Make diff_env() compatible with Solaris sed.
It appears to tolerate comments only at beginning of line.
2010-01-03 15:42:32 +02:00
Guillaume Rousse
38516ee431 Merge branch 'master' of git+ssh://git.debian.org/git/bash-completion/bash-completion 2009-12-31 17:36:20 +01:00