summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
authorDavid Paleino <dapal@debian.org>2012-06-17 20:09:53 +0200
committerDavid Paleino <dapal@debian.org>2012-06-17 20:09:53 +0200
commit30649a02707d24744853f84946f744fdcf7c2757 (patch)
tree97d1a69318079910c4bdc1bbed8a2ba2f58aea7f /test/lib
parentc3d398fcc6e400be546c28eb1fc25abfa5816eac (diff)
downloadbash-completion-30649a02707d24744853f84946f744fdcf7c2757.tar.gz
Imported Upstream version 2.0upstream/2.0
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/completions/acpi.exp18
-rw-r--r--test/lib/completions/hwclock.exp18
-rw-r--r--test/lib/completions/insmod.exp2
-rw-r--r--test/lib/completions/modinfo.exp35
-rw-r--r--test/lib/completions/modprobe.exp49
-rw-r--r--test/lib/completions/pwd.exp18
-rw-r--r--test/lib/completions/rmmod.exp18
-rw-r--r--test/lib/completions/slapt-get.exp6
-rw-r--r--test/lib/completions/ssh-add.exp20
-rw-r--r--test/lib/completions/su.exp18
-rw-r--r--test/lib/completions/sudo.exp9
-rw-r--r--test/lib/completions/vmstat.exp18
-rw-r--r--test/lib/library.exp2
13 files changed, 230 insertions, 1 deletions
diff --git a/test/lib/completions/acpi.exp b/test/lib/completions/acpi.exp
new file mode 100644
index 00000000..278cdceb
--- /dev/null
+++ b/test/lib/completions/acpi.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "acpi -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/hwclock.exp b/test/lib/completions/hwclock.exp
new file mode 100644
index 00000000..b12951a9
--- /dev/null
+++ b/test/lib/completions/hwclock.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "hwclock -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/insmod.exp b/test/lib/completions/insmod.exp
index a312c894..ca7c30f6 100644
--- a/test/lib/completions/insmod.exp
+++ b/test/lib/completions/insmod.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "insmod in"
+assert_complete_any "insmod "
sync_after_int
diff --git a/test/lib/completions/modinfo.exp b/test/lib/completions/modinfo.exp
new file mode 100644
index 00000000..bd8f965c
--- /dev/null
+++ b/test/lib/completions/modinfo.exp
@@ -0,0 +1,35 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+set test "in<TAB> should complete modulename"
+assert_complete_any "modinfo in" $test
+
+
+sync_after_int
+
+
+set test "should not complete anything for non-existent kernel"
+assert_no_complete "modinfo -k you-dont-have-such-kernel in" $test
+
+
+sync_after_int
+
+
+set test "should complete filepaths"
+assert_complete "/tmp/" "modinfo /tm" $test -nospace
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/modprobe.exp b/test/lib/completions/modprobe.exp
new file mode 100644
index 00000000..a1cd6987
--- /dev/null
+++ b/test/lib/completions/modprobe.exp
@@ -0,0 +1,49 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+set test "--remov<TAB> should complete \"--remove\""
+assert_complete "--remove" "modprobe --remov" $test
+
+
+sync_after_int
+
+
+set test "in<TAB> should complete modulename"
+assert_complete_any "modprobe in" $test
+
+
+sync_after_int
+
+
+set test "should not complete anything for non-existent kernel"
+assert_no_complete "modprobe -S you-dont-have-such-kernel in" $test
+
+
+sync_after_int
+
+
+set test "should not complete anything for non-existent module"
+assert_no_complete "modprobe you-dont-have-such-module " $test
+
+
+sync_after_int
+
+
+set test "should complete filepaths"
+assert_complete "/tmp/" "modprobe /tm" $test -nospace
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pwd.exp b/test/lib/completions/pwd.exp
new file mode 100644
index 00000000..f40fdb99
--- /dev/null
+++ b/test/lib/completions/pwd.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_no_complete "pwd "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rmmod.exp b/test/lib/completions/rmmod.exp
new file mode 100644
index 00000000..6c563211
--- /dev/null
+++ b/test/lib/completions/rmmod.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "rmmod -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/slapt-get.exp b/test/lib/completions/slapt-get.exp
index 70afc666..7f5375a4 100644
--- a/test/lib/completions/slapt-get.exp
+++ b/test/lib/completions/slapt-get.exp
@@ -24,6 +24,12 @@ assert_complete "--update --upgrade" "slapt-get --up" $test
sync_after_int
+set test "--install should not complete anything if config doesn't exist"
+assert_no_complete "slapt-get -c non-existent-file --install " $test
+
+
+sync_after_int
+
set test "--install should complete available packages"
set config $::srcdir/fixtures/slackware/etc/slapt-get/slapt-getrc
diff --git a/test/lib/completions/ssh-add.exp b/test/lib/completions/ssh-add.exp
new file mode 100644
index 00000000..2fb2a9b4
--- /dev/null
+++ b/test/lib/completions/ssh-add.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "ssh-add "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/su.exp b/test/lib/completions/su.exp
new file mode 100644
index 00000000..55dd80d1
--- /dev/null
+++ b/test/lib/completions/su.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+assert_complete_any "su "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp
index 6108ddce..5fdb97f1 100644
--- a/test/lib/completions/sudo.exp
+++ b/test/lib/completions/sudo.exp
@@ -32,6 +32,15 @@ assert_complete_dir "default/" "sudo mount /dev/sda1 def" $::srcdir/fixtures/sha
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} {
diff --git a/test/lib/completions/vmstat.exp b/test/lib/completions/vmstat.exp
new file mode 100644
index 00000000..f749322a
--- /dev/null
+++ b/test/lib/completions/vmstat.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+assert_complete_any "vmstat -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/library.exp b/test/lib/library.exp
index b2233258..75bf921c 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -799,6 +799,8 @@ proc realcommand {cmd} {
if [string length [set path [auto_execok $cmd]]] {
if {[string length [auto_execok realpath]]} {
set result [exec realpath $path]
+ } elseif {[string length [auto_execok greadlink]]} {
+ set result [exec greadlink -f $path]
} elseif {[string length [auto_execok readlink]]} {
set result [exec readlink -f $path]
} else {