73 Commits

Author SHA1 Message Date
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
Freddy Vulto
f321c377af (testsuite) Delete directory fixtures/_filedir/a\b
Directories `a\b' and `a*b' are now created run-time on a
non-Cygwin/Windows system only.  Tests concerning these directories will
also be run only on a non-Cygwin/Windows system.
(Alioth #312191)
2009-12-30 14:48:17 +01:00
Guillaume Rousse
3d584c94cb set BASH_COMPLETION_COMPAT_DIR to BASH_COMPLETION_DIR, to avoid sourcing actual /etc/completion.d directory before tests 2009-12-29 23:07:06 +01:00
Freddy Vulto
fec41f3c74 (testsuite) Added function `assert_bash_list_dir' 2009-12-24 09:41:22 +01:00
Ville Skyttä
8caddc47cf Protect grep invocations from user aliases (Alioth: 312143). 2009-12-15 23:48:10 +02:00
Ville Skyttä
d1da93448f Comment spelling fixes. 2009-12-10 23:53:22 +02: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
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
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
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
Freddy Vulto
75969454c0 (testsuite) Make expected lists unique 2009-11-21 10:18:54 +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
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
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
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
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