(testsuite) mount.exp: Create a mount-line completion which reads from a file instead of global fstab.

This commit is contained in:
Crestez Dan Leonard 2010-02-04 19:02:18 +02:00
parent 1096dadc26
commit bfb55ddf32
2 changed files with 68 additions and 2 deletions

20
test/fixtures/mount/test-fstab vendored Normal file
View File

@ -0,0 +1,20 @@
proc /proc proc defaults 0 0
none /debug debugfs defaults,noauto 0 0
# Test octal escapes
# Contains ' ' and '-'
/mnt/nice\040test\055path /dev/null auto ro,noauto 0 0
# Contains '$' and '-'
/mnt/nice\044test\055path /dev/null auto ro,noauto 0 0
# Contains ' ' and '\\'
/mnt/nice\040test\134path /dev/null auto ro,noauto 0 0
# Contains '\n' and '\ '
/mnt/nice\012test\040path /dev/null auto ro,noauto 0 0
# Test some labels
LABEL=Ubuntu\040Karmic /mnt/ubuntu auto no,noauto 0 0
LABEL=Fedora /mnt/fedora auto ro,noauto 0 0
LABEL=Debian-it's\040awesome /mnt/debian auto ro,noauto 0 0
#/dev/null /mnt/nice'testxxxpath auto ro,noauto 0 0

View File

@ -1,11 +1,38 @@
# 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}
}
proc setup {} { proc setup {} {
save_env save_env
}; setup_dummy_mnt
}
proc teardown {} { proc teardown {} {
teardown_dummy_mnt
assert_env_unmodified assert_env_unmodified
}; }
setup setup
@ -30,4 +57,23 @@ assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
sync_after_int 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
assert_complete {/mnt/nice\ test\\path} {mnt /mnt/nice\ test\\p}
sync_after_int
assert_complete {/mnt/nice\ test-path} {mnt /mnt/nice\ }
sync_after_int
assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$}
sync_after_int
assert_complete {'/mnt/nice\ test-path'} {mnt '/mnt/nice\ }
sync_after_int
teardown teardown