90 Commits

Author SHA1 Message Date
Ville Skyttä
dbb93ae77b (testsuite) Save shell variables when saving env (Alioth: #314720) 2014-07-01 22:23:35 +03:00
Damien Nadé
16361c873b (testsuite) Use 'set' command posix behaviour when saving env (Alioth: #314720) 2014-07-01 22:22:17 +03:00
Ville Skyttä
32f223963a _realcommand: Try greadlink before readlink (Alioth: #313659).
Some systems' readlink does not have -f, but may have the GNU readlink
which does installed as greadlink.
2012-05-30 23:56:58 +03:00
Ville Skyttä
3a7f1d3de3 testsuite/assert_complete_dir: Add note about OLDPWD filtering. 2011-11-26 23:32:24 +02:00
Ville Skyttä
f486ae26a0 testsuite/assert_complete_dir: Fix passing $args to assert_complete. 2011-11-26 23:26:03 +02:00
Ville Skyttä
6e08dc5504 testsuite/assert_source_completions: Test for command availability too.
We now install (_minimal) completions for just about everything, but
that doesn't mean we can sanely test everything if the command is not
available.
2011-10-26 21:24:56 +03:00
Ville Skyttä
099b47c66d kill, killall: Add some option and argument completions, simplify _signals. 2011-10-26 21:01:18 +03:00
Igor Murzov
3ac922e4a6 testsuite: Remove unused -expect-cmd-full option from assert_complete*
This option is implicitly enabled by default, so drop it to avoid confusion
2011-06-05 22:06:29 +04:00
Ville Skyttä
1126c831b8 testsuite: Don't define $BASH_COMPLETION here either. 2011-05-03 09:33:18 +03:00
David Paleino
00a6abb136 Also get rid of BASH_COMPLETION_DIR in the testsuite 2011-05-02 18:41:36 +02:00
Ville Skyttä
6589a0d61b Drop support for bash < 4.1, clean up no longer needed low hanging cruft. 2011-04-21 12:20:59 +03:00
Ville Skyttä
c398b1c56f (testsuite) Fix get_hosts option docs. 2011-03-29 23:27:51 +03:00
Freddy Vulto
68e9a8e6eb (testsuite) Add -unsorted option to _get_hosts()
_known_hosts_real tests were failing after commit 81794a9:

   FAIL: Hosts should be put in COMPREPLY
   FAIL: Hosts should have username prefix and colon suffix

This is because tcl's get_hosts() is now doing a unique sort, but bash
_known_hosts_real() IS returning duplicates relying on bash's compgen/complete
to remove the duplicates).  Fixed by calling _get_hosts -unsorted.
2011-03-27 23:12:14 +02:00
Ville Skyttä
81794a9dcf (testsuite) Avoid duplicates in get_hosts() return value. 2011-02-05 12:27:35 +02:00
Ville Skyttä
a0e7299717 (testsuite) assert_complete_one() fixes, revealed by ssh.exp. 2010-11-23 09:17:53 +02:00
Freddy Vulto
5a38f828d4 (testsuite) Split assert_complete() into
assert_complete_many() and assert_complete_one().
Fix ssh completion now that match_items() also matches on prompt.
2010-11-22 22:57:00 +01:00
Freddy Vulto
11da957e45 (testsuite) `match_items()' matches on bash-prompt
Also made `match_items()' more strict about matching
space/newline/prompt after the last item.

Added options to match_items():
- end-newline
- end-prompt
- end-space
and transferred them to other functions.

Function `assert_complete()' now has a `-nospace' option to explicitly
disallow a space after a completion...

Function `assert_bash_list()' now expects a single item to be followed
by a newline.
2010-11-17 23:36:58 +01:00
Freddy Vulto
69f9c7c77e (testsuite) Fix _count_args tests to output newline
assert_bash_list() expects a newline terminated list

Plus small fixes to assert_bash_list_dir()
2010-11-16 23:06:13 +01:00
Freddy Vulto
c86b336769 (testuite) Fix tests to run with autotools' make distcheck
File locations are prefixed with `$::srcdir' so that `make distcheck' can
execute the test suite using a relative path.

The current working directory is removed from the test-suite-bash-prompt.

Furthermore, no more dynamic creation of files in dir $::srcdir/fixtures since
this dir is read-only during `make distcheck'.  Instead create dynamic files in
$TESTDIR/tmp

The test suite uses these "directory" variables

   tcl            bash          description
   ------------   -----------   ------------------------------------
   $::srcdir      $SRCDIR       where `fixtures' reside, relative
   $::srcdirabs   $SRCDIRABS    where `fixtures' reside, absolute
   $::TESTDIR     $TESTDIR      where `runtest' is invoked, absolute
2010-11-12 23:35:36 +01:00
Freddy Vulto
de51dd3a89 (testsuite) Prepend relative files with $::srcdir
in an attempt to be able to run the tests successfully from within
autotools' `make distcheck'.
2010-11-05 21:28:48 +01:00
Freddy Vulto
0367d0bf57 (testsuite) Moved tool_start() code to tool_init()
${tool}_start was called from within `config/default_exp', but this
proves to be error-prone, because DejaGnu isn't fully initialized at
that point, causing an error when calling one of the DejaGnu methods
pass/fail/unsupported/xfail/unresolved/untested:

    can't read "multipass_name": no such variable

The right way seems to be calling ${tool}_start() from
${tool}_init().
2010-11-05 21:11:57 +01:00
Freddy Vulto
83bcd69557 (testsuite) Fix _parse_help for LANG=POSIX
Steps to reproduce the problem:

    $ LANG=POSIX ./run unit/_parse_help.exp
    ...
    Running ./unit/_parse_help.exp ...
    FAIL: short + long
    FAIL: short + long, slash separated

Cause:
When comparing list items, `assert_bash_list()' expects the real list to be
sorted, whereas the output of `_parse_help' is unsorted.
These particular two tests were failing because they suffered the
following LANG-dependant sort-difference:

    $ cat t.txt
    -m
    --n
    $ LANG=en_US.UTF-8 sort t.txt
    -m
    --n
    $ LANG=POSIX sort t.txt
    --n
    -m

Solution:
Made to default for `assert_bash_list' more-intuitive: unsorted, and added an
option `-sort' to explicitly enable sorting.

I felt uncomfortable adding yet another optional argument, so I seized this
opportunity to move subsequent optional arguments to single optional arguments.
E.g.:

    assert_bash_list {expected cmd {test ""} {prompt /@} {size 20}} {

has now become:

    # ...
    # @param list $args  Options:
    #     -nosort         Compare list unsorted.  Default is sorted
    #     -prompt         Bash prompt.  Default is `/@'
    #     -chunk-size N   Compare list N items at a time.  Default
    #                     is 20.
    assert_bash_list {expected cmd test {args {}}

(and the `test' argument has become mandatory).
2010-10-31 17:51:14 +01:00
Freddy Vulto
37f51b9df2 (testsuite) Removed changing locale within 'expect'
Changing the locale within an `expect' session might cause bash to exit.
See: http://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg02265.html
2010-10-18 22:29:59 +02:00
Freddy Vulto
ba419108b7 (testsuite) Comment multipass_name 2010-09-20 22:54:22 +02:00
Guillaume Rousse
796f77ef22 rename 'contrib' directory to 'completions' 2010-09-12 16:44:39 +02:00
Freddy Vulto
51b3e20ebc (testsuite) Drop ending block comments
Instead of writing `}; # if', write just `}' as was discussed here:

    http://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01815.html
2010-06-18 17:21:38 +02:00
Freddy Vulto
827ad88ebb (testsuite) Expand PATH with 'sbin' directories
This allows for testing completions of system administrator commands,
which are installed via the same PATH expansion in
`bash_completion.have()'
2010-04-22 22:22:50 +02:00
Freddy Vulto
96a936443e (testsuite) Run tests for superuser commands only if command is available
Case was /usr/sbin/grub.
Added check to `assert_source_completions()' if command is really
available for current user.
2010-04-17 08:16:37 +02:00
Crestez Dan Leonard
0f49bb1e3c (testsuite) Add a --timeout option to test/run to override the default expect timeout. 2010-02-21 05:44:39 +02:00
Crestez Dan Leonard
f9177e5286 (testsuite) Add a --debug-xtrace option to run.
Cleanup test/run scripts and add a --debug-xtrace option.
2010-02-20 22:54:13 +02:00
Freddy Vulto
99e550c3a8 (testsuite) fix indent/comment sync_after_int 2010-02-11 23:12:04 +01:00
Freddy Vulto
9f107370c4 (testsuite) Added `sleep .1' after sending QUIT/INT to bash
See also: http://lists.alioth.debian.org/pipermail/bash-completion-devel/2010-February/002566.html
2010-02-11 23:09:46 +01:00
Crestez Dan Leonard
ebdd9cefdc Merge branch 'space-fix': Fix tests when BASH_COMPLETION or TESTDIR contain
spaces.

Conflicts:
	CHANGES
2010-02-09 15:45:40 +02: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
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
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
Crestez Dan Leonard
c3bb4416d7 Fixed tests when BASH_COMPLETION or TESTDIR contain spaces. 2010-02-02 11:16:29 +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
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ä
f579b38410 (testsuite) Include shopt states in saved environment. 2010-01-28 00:58:17 +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ä
ef7f9dc89e (testsuite) Allow possibly leading whitespace in match_items() chunks > 1.
Thanks to Freddy Vulto.
2010-01-16 12:56:29 +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ä
3d43cdfd2b (testsuite) Remove some obsolete comments. 2010-01-03 15:52:18 +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