_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.
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.
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
${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().
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).
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.
- 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>
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().
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
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