96 lines
2.5 KiB
Plaintext
96 lines
2.5 KiB
Plaintext
proc setup {} {
|
|
save_env
|
|
}
|
|
|
|
|
|
proc teardown {} {
|
|
assert_env_unmodified {/OLDPWD/d}
|
|
}
|
|
|
|
|
|
setup
|
|
|
|
|
|
assert_complete_dir foo.d/ "sudo cd fo" $::srcdir/fixtures/shared/default \
|
|
"" -nospace
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
assert_complete_dir fixtures/ "sudo sh fix" $::srcdir "" -nospace
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
# test that `mount` and `sudo mount` behave the same way
|
|
set test "sudo mount /dev/sda1 def should complete directory name"
|
|
assert_complete_dir "default/" "sudo mount /dev/sda1 def" $::srcdir/fixtures/shared $test -nospace
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "sudo -e should complete filenames and directories"
|
|
set dir $::srcdir/fixtures/shared/default
|
|
set files {foo foo.d/}
|
|
assert_complete_dir $files "sudo -e -u root bar foo" $dir $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
# Find user/group suitable for testing.
|
|
set failed_find_unique_completion 0
|
|
foreach ug {user group} {
|
|
# compgen -A is used because it's a bash builtin and available everywhere.
|
|
# The || true part prevents exec from throwing an exception if nothing is
|
|
# found (very very unlikely).
|
|
set list [split [exec bash -c "compgen -A $ug || true"] "\n"]
|
|
if {![find_unique_completion_pair $list part$ug full$ug]} {
|
|
untested "Not running complex chown tests; no suitable test $ug found."
|
|
set failed_find_unique_completion 1
|
|
}
|
|
}
|
|
|
|
# These tests require an unique completion.
|
|
if {!$failed_find_unique_completion} {
|
|
assert_complete $fulluser "sudo chown $partuser"
|
|
sync_after_int
|
|
|
|
assert_complete $fulluser:$fullgroup "sudo chown $fulluser:$partgroup"
|
|
sync_after_int
|
|
|
|
assert_complete "dot.user:$fullgroup" "sudo chown dot.user:$partgroup"
|
|
sync_after_int
|
|
|
|
foreach prefix {
|
|
"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 "sudo chown $prefix$partgroup" $test
|
|
sync_after_int
|
|
}
|
|
|
|
# Check that we give up in degenerate cases instead of spewing various junk.
|
|
|
|
assert_no_complete "sudo chown $fulluser\\\\:$partgroup"
|
|
sync_after_int
|
|
|
|
assert_no_complete "sudo chown $fulluser\\\\\\:$partgroup"
|
|
sync_after_int
|
|
|
|
assert_no_complete "sudo chown $fulluser\\\\\\\\:$partgroup"
|
|
sync_after_int
|
|
|
|
# Colons in user/groupnames are not usually allowed.
|
|
assert_no_complete "sudo chown foo:bar:$partgroup"
|
|
sync_after_int
|
|
}
|
|
|
|
|
|
teardown
|