diff options
Diffstat (limited to 'test/lib/completions/mount.exp')
-rw-r--r-- | test/lib/completions/mount.exp | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp index 9e40803e..bcb95ba4 100644 --- a/test/lib/completions/mount.exp +++ b/test/lib/completions/mount.exp @@ -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 {} { save_env -}; + setup_dummy_mnt +} proc teardown {} { + teardown_dummy_mnt assert_env_unmodified -}; +} setup @@ -30,4 +57,23 @@ assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH} 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 |