2010-02-04 19:02:18 +02:00
|
|
|
# mount completion from fstab can't be tested directly because it
|
|
|
|
# (correctly) uses absolute paths. So we create a custom completion which
|
|
|
|
# reads from a file in our text fixture instead.
|
|
|
|
proc setup_dummy_mnt {} {
|
|
|
|
assert_bash_exec {unset COMPREPLY cur}
|
|
|
|
assert_bash_exec {unset -f _mnt}
|
|
|
|
|
|
|
|
global TESTDIR
|
|
|
|
assert_bash_exec { \
|
|
|
|
_mnt() { \
|
|
|
|
local cur=$(_get_cword); \
|
|
|
|
_linux_fstab < "$TESTDIR/fixtures/mount/test-fstab"; \
|
|
|
|
}; \
|
|
|
|
complete -F _mnt mnt \
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
proc teardown_dummy_mnt {} {
|
|
|
|
assert_bash_exec {unset COMPREPLY cur}
|
|
|
|
assert_bash_exec {unset -f _mnt}
|
|
|
|
assert_bash_exec {complete -r mnt}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-24 19:25:16 +02:00
|
|
|
proc setup {} {
|
|
|
|
save_env
|
2010-02-04 19:02:18 +02:00
|
|
|
setup_dummy_mnt
|
|
|
|
}
|
2010-01-24 19:25:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
proc teardown {} {
|
2010-02-04 19:02:18 +02:00
|
|
|
teardown_dummy_mnt
|
2010-01-24 19:25:16 +02:00
|
|
|
assert_env_unmodified
|
2010-02-04 19:02:18 +02:00
|
|
|
}
|
2010-01-24 19:25:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
setup
|
|
|
|
|
|
|
|
|
|
|
|
assert_complete_any "mount "
|
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
|
|
|
set test "Check completing nfs mounts"
|
|
|
|
set expected [list /test/path /test/path2 /second/path]
|
|
|
|
set cmd "mount mocksrv:/"
|
|
|
|
assert_bash_exec {OLDPATH="$PATH"; PATH="$TESTDIR/fixtures/mount/bin:$PATH";}
|
|
|
|
# This needs an explicit cword param or will output "unresolved".
|
|
|
|
assert_complete $expected $cmd $test "/@" 20 "/"
|
|
|
|
sync_after_int
|
|
|
|
assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
|
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
2010-02-08 06:52:20 +02:00
|
|
|
assert_complete {/mnt/nice-test-path} {mnt /mnt/nice-test-p}
|
|
|
|
sync_after_int
|
|
|
|
|
2010-02-04 19:02:18 +02:00
|
|
|
assert_complete {/mnt/nice\ test-path} {mnt /mnt/nice\ test-p}
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$test-p}
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
assert_complete {/mnt/nice\ test\\path} {mnt /mnt/nice\ test\\p}
|
|
|
|
sync_after_int
|
|
|
|
|
2010-02-08 06:52:20 +02:00
|
|
|
assert_complete {{/mnt/nice\ test\\path} {/mnt/nice\ test-path}} \
|
|
|
|
{mnt /mnt/nice\ } "" /@ 20 {/mnt/nice\ }
|
2010-02-04 19:02:18 +02:00
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$}
|
|
|
|
sync_after_int
|
|
|
|
|
2010-02-08 09:50:39 +02:00
|
|
|
assert_complete {/mnt/nice\'test-path} {mnt /mnt/nice\'}
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
assert_complete {/mnt/other\'test\ path} {mnt /mnt/other}
|
|
|
|
sync_after_int
|
|
|
|
|
2010-02-08 08:35:46 +02:00
|
|
|
# This does not work. Proper support for this requires smarter parsing of
|
|
|
|
# $COMP_LINE and it's not worth doing just for mount.
|
|
|
|
#assert_complete {$'/mnt/nice\ntest-path'} {mnt $'/mnt/nice\n}
|
|
|
|
#sync_after_int
|
2010-02-04 19:02:18 +02:00
|
|
|
|
|
|
|
|
2010-01-24 19:25:16 +02:00
|
|
|
teardown
|