diff options
author | Freddy Vulto <fvulto@gmail.com> | 2010-01-29 23:23:30 +0100 |
---|---|---|
committer | Freddy Vulto <fvulto@gmail.com> | 2010-01-29 23:23:30 +0100 |
commit | d866854066fb3b6711cf6fc92ff648a0a12ee9d8 (patch) | |
tree | 45fdbfa5885c37c47dedd6d7453a82bc81bf3297 /test/lib/completions | |
parent | dc8af65161fecc37d2d2ab15c02d8f529d27c3b5 (diff) | |
download | bash-completion-d866854066fb3b6711cf6fc92ff648a0a12ee9d8.tar.gz |
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
Diffstat (limited to 'test/lib/completions')
-rw-r--r-- | test/lib/completions/chown.exp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp new file mode 100644 index 00000000..cc56149b --- /dev/null +++ b/test/lib/completions/chown.exp @@ -0,0 +1,70 @@ +proc setup {} { + save_env +}; # setup() + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "chown " +sync_after_int + + +# All the tests use the root:root user and group. They're assumed to exist. +set fulluser "root" +set fullgroup "root" + +# Partial username is assumed to be unambiguous. +set partuser "roo" +set partgroup "roo" + +# Skip tests if root:root not available or if roo:roo matches multiple +# users/groups +if {[exec bash -c "compgen -A user $partuser" | wc -l] > 1 || + [exec bash -c "compgen -A user $fulluser" | wc -l] != 1 || + [exec bash -c "compgen -A group $partgroup" | wc -l] > 1 || + [exec bash -c "compgen -A group $fullgroup" | wc -l] != 1} { + untested "Not running complex chown tests." +} else { + assert_complete $fulluser "chown $partuser" + sync_after_int + + assert_complete $fulluser:$fullgroup "chown $fulluser:$partgroup" + sync_after_int + + # One slash should work correctly (doubled here for tcl). + assert_complete $fulluser\\:$fullgroup "chown $fulluser\\:$partgroup" + sync_after_int + + foreach prefix { + "funky\\ user:" "funky\\ user\\:" "funky.user:" "funky\\.user:" "fu\\ nky.user\\:" + "f\\ o\\ o\\.\\bar:" "foo\\_b\\ a\\.r\\ :" + } { + set test "Check preserve special chars in $prefix$partgroup<TAB>" + #assert_complete_into "chown $prefix$partgroup" "chown $prefix$fullgroup " $test + assert_complete $prefix$fullgroup "chown $prefix$partgroup" $test + sync_after_int + } + + # Check that we give up in degenerate cases instead of spewing various junk. + + assert_no_complete "chown $fulluser\\\\:$partgroup" + sync_after_int + + assert_no_complete "chown $fulluser\\\\\\:$partgroup" + sync_after_int + + assert_no_complete "chown $fulluser\\\\\\\\:$partgroup" + sync_after_int + + # Colons in user/groupnames are not usually allowed. + assert_no_complete "chown foo:bar:$partgroup" + sync_after_int +} + + +teardown |