summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/completion.exp16
-rw-r--r--test/lib/completions/a2ps.exp20
-rw-r--r--test/lib/completions/abook.exp20
-rw-r--r--test/lib/completions/acroread.exp22
-rw-r--r--test/lib/completions/add_members.exp20
-rw-r--r--test/lib/completions/alias.exp43
-rw-r--r--test/lib/completions/animate.exp20
-rw-r--r--test/lib/completions/ant.exp20
-rw-r--r--test/lib/completions/apache2ctl.exp20
-rw-r--r--test/lib/completions/apt-build.exp20
-rw-r--r--test/lib/completions/apt-cache.exp20
-rw-r--r--test/lib/completions/apt-get.exp22
-rw-r--r--test/lib/completions/aptitude.exp20
-rw-r--r--test/lib/completions/arch.exp21
-rw-r--r--test/lib/completions/arpspoof.exp20
-rw-r--r--test/lib/completions/aspell.exp20
-rw-r--r--test/lib/completions/autoconf.exp20
-rw-r--r--test/lib/completions/automake.exp20
-rw-r--r--test/lib/completions/autorpm.exp20
-rw-r--r--test/lib/completions/awk.exp20
-rw-r--r--test/lib/completions/bash.exp20
-rw-r--r--test/lib/completions/bc.exp20
-rw-r--r--test/lib/completions/bison.exp20
-rw-r--r--test/lib/completions/bk.exp20
-rw-r--r--test/lib/completions/brctl.exp20
-rw-r--r--test/lib/completions/btdownloadcurses.py.exp20
-rw-r--r--test/lib/completions/btdownloadgui.py.exp20
-rw-r--r--test/lib/completions/btdownloadheadless.py.exp20
-rw-r--r--test/lib/completions/bzip2.exp20
-rw-r--r--test/lib/completions/c++.exp21
-rw-r--r--test/lib/completions/cancel.exp31
-rw-r--r--test/lib/completions/cardctl.exp20
-rw-r--r--test/lib/completions/cat.exp20
-rw-r--r--test/lib/completions/cc.exp20
-rw-r--r--test/lib/completions/cd.exp47
-rw-r--r--test/lib/completions/cdrecord.exp20
-rw-r--r--test/lib/completions/change_pw.exp20
-rw-r--r--test/lib/completions/check_db.exp20
-rw-r--r--test/lib/completions/check_perms.exp20
-rw-r--r--test/lib/completions/chgrp.exp20
-rw-r--r--test/lib/completions/chkconfig.exp20
-rw-r--r--test/lib/completions/chown.exp72
-rw-r--r--test/lib/completions/chsh.exp26
-rw-r--r--test/lib/completions/ci.exp20
-rw-r--r--test/lib/completions/civclient.exp20
-rw-r--r--test/lib/completions/civserver.exp20
-rw-r--r--test/lib/completions/cksfv.exp20
-rw-r--r--test/lib/completions/cleanarch.exp20
-rw-r--r--test/lib/completions/clisp.exp20
-rw-r--r--test/lib/completions/clone_member.exp20
-rw-r--r--test/lib/completions/co.exp20
-rw-r--r--test/lib/completions/composite.exp20
-rw-r--r--test/lib/completions/config_list.exp20
-rw-r--r--test/lib/completions/configure.exp20
-rw-r--r--test/lib/completions/convert.exp20
-rw-r--r--test/lib/completions/cowsay.exp20
-rw-r--r--test/lib/completions/cp.exp20
-rw-r--r--test/lib/completions/cpio.exp26
-rw-r--r--test/lib/completions/createdb.exp20
-rw-r--r--test/lib/completions/cryptsetup.exp20
-rw-r--r--test/lib/completions/csplit.exp20
-rw-r--r--test/lib/completions/cut.exp20
-rw-r--r--test/lib/completions/cvs.exp36
-rw-r--r--test/lib/completions/cvsps.exp36
-rw-r--r--test/lib/completions/date.exp20
-rw-r--r--test/lib/completions/dcop.exp22
-rw-r--r--test/lib/completions/dd.exp33
-rw-r--r--test/lib/completions/df.exp20
-rw-r--r--test/lib/completions/dhclient.exp20
-rw-r--r--test/lib/completions/dict.exp20
-rw-r--r--test/lib/completions/diff.exp20
-rw-r--r--test/lib/completions/dir.exp20
-rw-r--r--test/lib/completions/display.exp41
-rw-r--r--test/lib/completions/dnsspoof.exp20
-rw-r--r--test/lib/completions/dpkg-deb.exp20
-rw-r--r--test/lib/completions/dpkg-reconfigure.exp20
-rw-r--r--test/lib/completions/dpkg-source.exp20
-rw-r--r--test/lib/completions/dpkg.exp29
-rw-r--r--test/lib/completions/dropdb.exp20
-rw-r--r--test/lib/completions/dselect.exp20
-rw-r--r--test/lib/completions/dsniff.exp20
-rw-r--r--test/lib/completions/du.exp20
-rw-r--r--test/lib/completions/dumpdb.exp20
-rw-r--r--test/lib/completions/enscript.exp20
-rw-r--r--test/lib/completions/env.exp22
-rw-r--r--test/lib/completions/evince.exp35
-rw-r--r--test/lib/completions/expand.exp22
-rw-r--r--test/lib/completions/filesnarf.exp20
-rw-r--r--test/lib/completions/find.exp80
-rw-r--r--test/lib/completions/find_member.exp20
-rw-r--r--test/lib/completions/finger.exp57
-rw-r--r--test/lib/completions/fmt.exp22
-rw-r--r--test/lib/completions/fold.exp22
-rw-r--r--test/lib/completions/g++.exp20
-rw-r--r--test/lib/completions/g4.exp20
-rw-r--r--test/lib/completions/g77.exp20
-rw-r--r--test/lib/completions/gcc.exp20
-rw-r--r--test/lib/completions/gcj.exp20
-rw-r--r--test/lib/completions/gcl.exp20
-rw-r--r--test/lib/completions/gdb.exp20
-rw-r--r--test/lib/completions/genaliases.exp20
-rw-r--r--test/lib/completions/getent.exp20
-rw-r--r--test/lib/completions/gkrellm.exp20
-rw-r--r--test/lib/completions/gmplayer.exp20
-rw-r--r--test/lib/completions/gnatmake.exp20
-rw-r--r--test/lib/completions/gpc.exp20
-rw-r--r--test/lib/completions/gperf.exp20
-rw-r--r--test/lib/completions/gpg.exp20
-rw-r--r--test/lib/completions/gprof.exp22
-rw-r--r--test/lib/completions/grep.exp20
-rw-r--r--test/lib/completions/grub.exp20
-rw-r--r--test/lib/completions/gzip.exp28
-rw-r--r--test/lib/completions/hcitool.exp20
-rw-r--r--test/lib/completions/head.exp22
-rw-r--r--test/lib/completions/iconv.exp20
-rw-r--r--test/lib/completions/id.exp20
-rw-r--r--test/lib/completions/identify.exp20
-rw-r--r--test/lib/completions/ifdown.exp20
-rw-r--r--test/lib/completions/ifup.exp20
-rw-r--r--test/lib/completions/indent.exp20
-rw-r--r--test/lib/completions/info.exp20
-rw-r--r--test/lib/completions/inject.exp20
-rw-r--r--test/lib/completions/insmod.exp20
-rw-r--r--test/lib/completions/invoke-rc.d.exp20
-rw-r--r--test/lib/completions/ipsec.exp20
-rw-r--r--test/lib/completions/ipv6calc.exp26
-rw-r--r--test/lib/completions/irb.exp20
-rw-r--r--test/lib/completions/isql.exp23
-rw-r--r--test/lib/completions/iwconfig.exp20
-rw-r--r--test/lib/completions/iwlist.exp20
-rw-r--r--test/lib/completions/iwpriv.exp20
-rw-r--r--test/lib/completions/iwspy.exp20
-rw-r--r--test/lib/completions/jar.exp20
-rw-r--r--test/lib/completions/jarsigner.exp20
-rw-r--r--test/lib/completions/java.exp46
-rw-r--r--test/lib/completions/javac.exp20
-rw-r--r--test/lib/completions/javadoc.exp20
-rw-r--r--test/lib/completions/k3b.exp20
-rw-r--r--test/lib/completions/kdvi.exp27
-rw-r--r--test/lib/completions/kill.exp26
-rw-r--r--test/lib/completions/killall.exp26
-rw-r--r--test/lib/completions/kldload.exp20
-rw-r--r--test/lib/completions/kldunload.exp24
-rw-r--r--test/lib/completions/kpdf.exp26
-rw-r--r--test/lib/completions/kplayer.exp20
-rw-r--r--test/lib/completions/larch.exp20
-rw-r--r--test/lib/completions/ld.exp20
-rw-r--r--test/lib/completions/ldd.exp20
-rw-r--r--test/lib/completions/less.exp20
-rw-r--r--test/lib/completions/lftp.exp24
-rw-r--r--test/lib/completions/lftpget.exp20
-rw-r--r--test/lib/completions/lilo.exp20
-rw-r--r--test/lib/completions/links.exp20
-rw-r--r--test/lib/completions/lisp.exp20
-rw-r--r--test/lib/completions/list_admins.exp20
-rw-r--r--test/lib/completions/list_lists.exp20
-rw-r--r--test/lib/completions/list_members.exp20
-rw-r--r--test/lib/completions/list_owners.exp20
-rw-r--r--test/lib/completions/ln.exp20
-rw-r--r--test/lib/completions/look.exp22
-rw-r--r--test/lib/completions/ls.exp22
-rw-r--r--test/lib/completions/lvchange.exp20
-rw-r--r--test/lib/completions/lvcreate.exp20
-rw-r--r--test/lib/completions/lvdisplay.exp20
-rw-r--r--test/lib/completions/lvextend.exp20
-rw-r--r--test/lib/completions/lvm.exp20
-rw-r--r--test/lib/completions/lvmdiskscan.exp20
-rw-r--r--test/lib/completions/lvreduce.exp20
-rw-r--r--test/lib/completions/lvremove.exp20
-rw-r--r--test/lib/completions/lvrename.exp20
-rw-r--r--test/lib/completions/lvresize.exp20
-rw-r--r--test/lib/completions/lvs.exp20
-rw-r--r--test/lib/completions/lvscan.exp20
-rw-r--r--test/lib/completions/lzma.exp26
-rw-r--r--test/lib/completions/lzop.exp20
-rw-r--r--test/lib/completions/m4.exp22
-rw-r--r--test/lib/completions/macof.exp20
-rw-r--r--test/lib/completions/mailmanctl.exp20
-rw-r--r--test/lib/completions/mailsnarf.exp20
-rw-r--r--test/lib/completions/make.exp20
-rw-r--r--test/lib/completions/man.exp20
-rw-r--r--test/lib/completions/mc.exp20
-rw-r--r--test/lib/completions/mcrypt.exp20
-rw-r--r--test/lib/completions/md5sum.exp20
-rw-r--r--test/lib/completions/mdecrypt.exp20
-rw-r--r--test/lib/completions/mencoder.exp20
-rw-r--r--test/lib/completions/minicom.exp20
-rw-r--r--test/lib/completions/mkdir.exp20
-rw-r--r--test/lib/completions/mkfifo.exp20
-rw-r--r--test/lib/completions/mkinitrd.exp20
-rw-r--r--test/lib/completions/mkisofs.exp48
-rw-r--r--test/lib/completions/mknod.exp20
-rw-r--r--test/lib/completions/mmsitepass.exp20
-rw-r--r--test/lib/completions/module.exp20
-rw-r--r--test/lib/completions/mogrify.exp20
-rw-r--r--test/lib/completions/montage.exp20
-rw-r--r--test/lib/completions/mount.exp121
-rw-r--r--test/lib/completions/mplayer.exp20
-rw-r--r--test/lib/completions/msgsnarf.exp20
-rw-r--r--test/lib/completions/mtx.exp20
-rw-r--r--test/lib/completions/mutt.exp33
-rw-r--r--test/lib/completions/muttng.exp20
-rw-r--r--test/lib/completions/mv.exp20
-rw-r--r--test/lib/completions/mysqladmin.exp20
-rw-r--r--test/lib/completions/ncftp.exp20
-rw-r--r--test/lib/completions/netstat.exp20
-rw-r--r--test/lib/completions/newlist.exp20
-rw-r--r--test/lib/completions/nl.exp20
-rw-r--r--test/lib/completions/nm.exp20
-rw-r--r--test/lib/completions/ntpdate.exp20
-rw-r--r--test/lib/completions/objcopy.exp20
-rw-r--r--test/lib/completions/objdump.exp20
-rw-r--r--test/lib/completions/od.exp20
-rw-r--r--test/lib/completions/openssl.exp28
-rw-r--r--test/lib/completions/p4.exp20
-rw-r--r--test/lib/completions/pack200.exp20
-rw-r--r--test/lib/completions/paste.exp20
-rw-r--r--test/lib/completions/patch.exp20
-rw-r--r--test/lib/completions/perl.exp95
-rw-r--r--test/lib/completions/perldoc.exp38
-rw-r--r--test/lib/completions/pgrep.exp20
-rw-r--r--test/lib/completions/pine.exp20
-rw-r--r--test/lib/completions/ping.exp20
-rw-r--r--test/lib/completions/pkg-config.exp20
-rw-r--r--test/lib/completions/pkg_deinstall.exp22
-rw-r--r--test/lib/completions/pkg_delete.exp20
-rw-r--r--test/lib/completions/pkg_info.exp20
-rw-r--r--test/lib/completions/pkill.exp20
-rw-r--r--test/lib/completions/portinstall.exp22
-rw-r--r--test/lib/completions/portupgrade.exp21
-rw-r--r--test/lib/completions/povray.exp20
-rw-r--r--test/lib/completions/pr.exp20
-rw-r--r--test/lib/completions/psql.exp20
-rw-r--r--test/lib/completions/ptx.exp20
-rw-r--r--test/lib/completions/pvchange.exp20
-rw-r--r--test/lib/completions/pvcreate.exp20
-rw-r--r--test/lib/completions/pvdisplay.exp20
-rw-r--r--test/lib/completions/pvmove.exp20
-rw-r--r--test/lib/completions/pvremove.exp20
-rw-r--r--test/lib/completions/pvs.exp20
-rw-r--r--test/lib/completions/pvscan.exp20
-rw-r--r--test/lib/completions/python.exp20
-rw-r--r--test/lib/completions/qrunner.exp20
-rw-r--r--test/lib/completions/querybts.exp20
-rw-r--r--test/lib/completions/rcs.exp20
-rw-r--r--test/lib/completions/rcsdiff.exp20
-rw-r--r--test/lib/completions/rdict.exp20
-rw-r--r--test/lib/completions/readelf.exp20
-rw-r--r--test/lib/completions/readonly.exp20
-rw-r--r--test/lib/completions/remove_members.exp20
-rw-r--r--test/lib/completions/removepkg.exp20
-rw-r--r--test/lib/completions/renice.exp42
-rw-r--r--test/lib/completions/reportbug.exp20
-rw-r--r--test/lib/completions/ri.exp20
-rw-r--r--test/lib/completions/rlog.exp20
-rw-r--r--test/lib/completions/rm.exp20
-rw-r--r--test/lib/completions/rmdir.exp20
-rw-r--r--test/lib/completions/rmlist.exp20
-rw-r--r--test/lib/completions/rpcdebug.exp20
-rw-r--r--test/lib/completions/rpm.exp29
-rw-r--r--test/lib/completions/rsync.exp20
-rw-r--r--test/lib/completions/rtcwake.exp20
-rw-r--r--test/lib/completions/sbcl-mt.exp20
-rw-r--r--test/lib/completions/sbcl.exp20
-rw-r--r--test/lib/completions/scp.exp121
-rw-r--r--test/lib/completions/screen.exp52
-rw-r--r--test/lib/completions/sed.exp22
-rw-r--r--test/lib/completions/seq.exp20
-rw-r--r--test/lib/completions/service.exp20
-rw-r--r--test/lib/completions/set.exp20
-rw-r--r--test/lib/completions/sftp.exp77
-rw-r--r--test/lib/completions/sha1sum.exp20
-rw-r--r--test/lib/completions/shar.exp20
-rw-r--r--test/lib/completions/sitecopy.exp20
-rw-r--r--test/lib/completions/smartctl.exp20
-rw-r--r--test/lib/completions/snownews.exp20
-rw-r--r--test/lib/completions/sort.exp20
-rw-r--r--test/lib/completions/split.exp22
-rw-r--r--test/lib/completions/spovray.exp20
-rw-r--r--test/lib/completions/ssh.exp93
-rw-r--r--test/lib/completions/sshmitm.exp20
-rw-r--r--test/lib/completions/sshow.exp20
-rw-r--r--test/lib/completions/strace.exp20
-rw-r--r--test/lib/completions/strip.exp20
-rw-r--r--test/lib/completions/sudo.exp20
-rw-r--r--test/lib/completions/svk.exp20
-rw-r--r--test/lib/completions/svn.exp20
-rw-r--r--test/lib/completions/svnadmin.exp20
-rw-r--r--test/lib/completions/svnlook.exp20
-rw-r--r--test/lib/completions/sync_members.exp20
-rw-r--r--test/lib/completions/sysctl.exp22
-rw-r--r--test/lib/completions/tac.exp20
-rw-r--r--test/lib/completions/tail.exp22
-rw-r--r--test/lib/completions/tar.exp20
-rw-r--r--test/lib/completions/tcpkill.exp20
-rw-r--r--test/lib/completions/tcpnice.exp20
-rw-r--r--test/lib/completions/tee.exp20
-rw-r--r--test/lib/completions/texindex.exp20
-rw-r--r--test/lib/completions/tightvncviewer.exp20
-rw-r--r--test/lib/completions/time.exp20
-rw-r--r--test/lib/completions/touch.exp22
-rw-r--r--test/lib/completions/tr.exp22
-rw-r--r--test/lib/completions/unace.exp20
-rw-r--r--test/lib/completions/uname.exp22
-rw-r--r--test/lib/completions/unexpand.exp22
-rw-r--r--test/lib/completions/uniq.exp22
-rw-r--r--test/lib/completions/units.exp22
-rw-r--r--test/lib/completions/unpack200.exp20
-rw-r--r--test/lib/completions/unrar.exp20
-rw-r--r--test/lib/completions/unset.exp20
-rw-r--r--test/lib/completions/unshunt.exp20
-rw-r--r--test/lib/completions/update-alternatives.exp20
-rw-r--r--test/lib/completions/update-rc.d.exp20
-rw-r--r--test/lib/completions/urlsnarf.exp20
-rw-r--r--test/lib/completions/vdir.exp20
-rw-r--r--test/lib/completions/vgcfgbackup.exp20
-rw-r--r--test/lib/completions/vgcfgrestore.exp20
-rw-r--r--test/lib/completions/vgchange.exp20
-rw-r--r--test/lib/completions/vgck.exp20
-rw-r--r--test/lib/completions/vgconvert.exp20
-rw-r--r--test/lib/completions/vgcreate.exp20
-rw-r--r--test/lib/completions/vgdisplay.exp20
-rw-r--r--test/lib/completions/vgexport.exp20
-rw-r--r--test/lib/completions/vgextend.exp20
-rw-r--r--test/lib/completions/vgimport.exp20
-rw-r--r--test/lib/completions/vgmerge.exp20
-rw-r--r--test/lib/completions/vgmknodes.exp20
-rw-r--r--test/lib/completions/vgreduce.exp20
-rw-r--r--test/lib/completions/vgremove.exp20
-rw-r--r--test/lib/completions/vgrename.exp20
-rw-r--r--test/lib/completions/vgs.exp20
-rw-r--r--test/lib/completions/vgscan.exp20
-rw-r--r--test/lib/completions/vgsplit.exp20
-rw-r--r--test/lib/completions/vncviewer.exp22
-rw-r--r--test/lib/completions/wc.exp22
-rw-r--r--test/lib/completions/webmitm.exp20
-rw-r--r--test/lib/completions/wget.exp20
-rw-r--r--test/lib/completions/who.exp22
-rw-r--r--test/lib/completions/withlist.exp20
-rw-r--r--test/lib/completions/wol.exp29
-rw-r--r--test/lib/completions/wtf.exp20
-rw-r--r--test/lib/completions/wvdial.exp20
-rw-r--r--test/lib/completions/xhost.exp100
-rw-r--r--test/lib/completions/xmllint.exp20
-rw-r--r--test/lib/completions/xmlwf.exp20
-rw-r--r--test/lib/completions/xmms.exp20
-rw-r--r--test/lib/completions/xpovray.exp20
-rw-r--r--test/lib/completions/xrandr.exp20
-rw-r--r--test/lib/completions/xsltproc.exp20
-rw-r--r--test/lib/completions/xvnc4viewer.exp45
-rw-r--r--test/lib/completions/xz.exp33
-rw-r--r--test/lib/completions/ypcat.exp20
-rw-r--r--test/lib/completions/ypmatch.exp20
-rw-r--r--test/lib/completions/yum-arch.exp20
-rw-r--r--test/lib/completions/yum.exp20
-rw-r--r--test/lib/library.exp908
-rw-r--r--test/lib/library.sh75
-rw-r--r--test/lib/unit.exp17
358 files changed, 9211 insertions, 0 deletions
diff --git a/test/lib/completion.exp b/test/lib/completion.exp
new file mode 100644
index 00000000..ea2a3d8d
--- /dev/null
+++ b/test/lib/completion.exp
@@ -0,0 +1,16 @@
+source ${srcdir}/lib/library.exp
+
+
+proc completion_exit {} {
+ send "\rexit\r"
+}
+
+
+proc completion_start {} {
+ start_interactive_test
+}
+
+
+proc completion_version {} {
+ puts "$::TESTDIR, bash-$::BASH_VERSION"
+}
diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/a2ps.exp
new file mode 100644
index 00000000..796e14cc
--- /dev/null
+++ b/test/lib/completions/a2ps.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "a2ps "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/abook.exp b/test/lib/completions/abook.exp
new file mode 100644
index 00000000..3f4e301f
--- /dev/null
+++ b/test/lib/completions/abook.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "abook "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/acroread.exp b/test/lib/completions/acroread.exp
new file mode 100644
index 00000000..4f11f905
--- /dev/null
+++ b/test/lib/completions/acroread.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+ assert_bash_exec "touch fixtures/shared/default/t.pdf"; # Create temporary files
+}; # setup()
+
+
+proc teardown {} {
+ assert_bash_exec "rm fixtures/shared/default/t.pdf"; # Remove temporary files
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete {"bar bar.d/" foo.d/ t.pdf} "acroread fixtures/shared/default/"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/add_members.exp b/test/lib/completions/add_members.exp
new file mode 100644
index 00000000..02cd762d
--- /dev/null
+++ b/test/lib/completions/add_members.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "add_members -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/alias.exp b/test/lib/completions/alias.exp
new file mode 100644
index 00000000..e6b88d00
--- /dev/null
+++ b/test/lib/completions/alias.exp
@@ -0,0 +1,43 @@
+proc setup {} {
+ assert_bash_exec "unalias -a"; # Remove all aliases
+ assert_bash_exec "alias foo=bar"
+ assert_bash_exec "alias bar='foo foo'"
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_bash_exec "unalias -a"; # Remove all aliases
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete alias"
+ # Try completion
+set cmd "alias "
+assert_complete {bar foo} $cmd $test
+
+
+sync_after_int
+
+
+set test "Tab should complete alias at cursor position"
+ # Try completion
+set cmd "alias foo"
+append cmd \002\002\002; # \002 = ^B = Move cursor left in bash emacs mode
+send "$cmd\t"
+expect {
+ -re "^alias foo\b\b\b\r\nbar +foo *\r\n/@alias foo\b\b\b$" { pass "$test" }
+ -re "^alias foo\b\b\bfoo=foo\b\b\b$" { fail "$test: Wrong cursor position" }
+ -re /@ { unresolved "$test" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/animate.exp b/test/lib/completions/animate.exp
new file mode 100644
index 00000000..26065d25
--- /dev/null
+++ b/test/lib/completions/animate.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "animate "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ant.exp b/test/lib/completions/ant.exp
new file mode 100644
index 00000000..81294439
--- /dev/null
+++ b/test/lib/completions/ant.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ant -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/apache2ctl.exp b/test/lib/completions/apache2ctl.exp
new file mode 100644
index 00000000..e63abb16
--- /dev/null
+++ b/test/lib/completions/apache2ctl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "apache2ctl "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/apt-build.exp b/test/lib/completions/apt-build.exp
new file mode 100644
index 00000000..fd09d0eb
--- /dev/null
+++ b/test/lib/completions/apt-build.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "apt-build "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/apt-cache.exp b/test/lib/completions/apt-cache.exp
new file mode 100644
index 00000000..5336beab
--- /dev/null
+++ b/test/lib/completions/apt-cache.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "apt-cache "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/apt-get.exp b/test/lib/completions/apt-get.exp
new file mode 100644
index 00000000..6bd0f3a2
--- /dev/null
+++ b/test/lib/completions/apt-get.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set commands {autoclean autoremove build-dep check clean dist-upgrade
+ dselect-upgrade install purge remove source update upgrade}
+assert_complete $commands "apt-get "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/aptitude.exp b/test/lib/completions/aptitude.exp
new file mode 100644
index 00000000..dde6d26e
--- /dev/null
+++ b/test/lib/completions/aptitude.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "aptitude "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/arch.exp b/test/lib/completions/arch.exp
new file mode 100644
index 00000000..9f7114c4
--- /dev/null
+++ b/test/lib/completions/arch.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set options {--wipe -s --start= -e --end= -q --quiet -h --help}
+assert_complete $options "arch -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/arpspoof.exp b/test/lib/completions/arpspoof.exp
new file mode 100644
index 00000000..7db79f50
--- /dev/null
+++ b/test/lib/completions/arpspoof.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "arpspoof -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/aspell.exp b/test/lib/completions/aspell.exp
new file mode 100644
index 00000000..4edeb03b
--- /dev/null
+++ b/test/lib/completions/aspell.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "aspell "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/autoconf.exp b/test/lib/completions/autoconf.exp
new file mode 100644
index 00000000..4a44b651
--- /dev/null
+++ b/test/lib/completions/autoconf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "autoconf "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/automake.exp b/test/lib/completions/automake.exp
new file mode 100644
index 00000000..cf27364a
--- /dev/null
+++ b/test/lib/completions/automake.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "automake "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/autorpm.exp b/test/lib/completions/autorpm.exp
new file mode 100644
index 00000000..99b743ca
--- /dev/null
+++ b/test/lib/completions/autorpm.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "autorpm "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/awk.exp b/test/lib/completions/awk.exp
new file mode 100644
index 00000000..4288adbf
--- /dev/null
+++ b/test/lib/completions/awk.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "awk "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/bash.exp b/test/lib/completions/bash.exp
new file mode 100644
index 00000000..4caf58fc
--- /dev/null
+++ b/test/lib/completions/bash.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "bash --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/bc.exp b/test/lib/completions/bc.exp
new file mode 100644
index 00000000..c437d037
--- /dev/null
+++ b/test/lib/completions/bc.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "bc --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/bison.exp b/test/lib/completions/bison.exp
new file mode 100644
index 00000000..a3dea1e0
--- /dev/null
+++ b/test/lib/completions/bison.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "bison --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/bk.exp b/test/lib/completions/bk.exp
new file mode 100644
index 00000000..4915136e
--- /dev/null
+++ b/test/lib/completions/bk.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "bk "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/brctl.exp b/test/lib/completions/brctl.exp
new file mode 100644
index 00000000..d87002a2
--- /dev/null
+++ b/test/lib/completions/brctl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "brctl "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/btdownloadcurses.py.exp b/test/lib/completions/btdownloadcurses.py.exp
new file mode 100644
index 00000000..9dc0ba5a
--- /dev/null
+++ b/test/lib/completions/btdownloadcurses.py.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "btdownloadcurses.py "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/btdownloadgui.py.exp b/test/lib/completions/btdownloadgui.py.exp
new file mode 100644
index 00000000..03897a53
--- /dev/null
+++ b/test/lib/completions/btdownloadgui.py.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "btdownloadgui.py "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/btdownloadheadless.py.exp b/test/lib/completions/btdownloadheadless.py.exp
new file mode 100644
index 00000000..69c62950
--- /dev/null
+++ b/test/lib/completions/btdownloadheadless.py.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "btdownloadheadless.py "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/bzip2.exp b/test/lib/completions/bzip2.exp
new file mode 100644
index 00000000..e5389a2a
--- /dev/null
+++ b/test/lib/completions/bzip2.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "bzip2 "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/c++.exp b/test/lib/completions/c++.exp
new file mode 100644
index 00000000..1fe4bb13
--- /dev/null
+++ b/test/lib/completions/c++.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete"
+assert_complete_any "c++ "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cancel.exp b/test/lib/completions/cancel.exp
new file mode 100644
index 00000000..24ca47c4
--- /dev/null
+++ b/test/lib/completions/cancel.exp
@@ -0,0 +1,31 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+ # Adding a print job is successful?
+if {[assert_exec {lp -H hold fixtures/shared/default/foo} job "" "untested"]} {
+ # Yes, adding a print-job is successful;
+ # Retrieve job-id, so we can cancel the job after the test
+ set job_id [lindex [split $job] 3]
+ # Retrieve list of all current print jobs
+ assert_exec {lpstat | cut -d\040 -f1} jobs
+ # Completion should show all print jobs
+ assert_complete $jobs "cancel "
+ # Remove/cancel the test print job
+ assert_exec "cancel $job_id"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cardctl.exp b/test/lib/completions/cardctl.exp
new file mode 100644
index 00000000..b5d7e88d
--- /dev/null
+++ b/test/lib/completions/cardctl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cardctl "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cat.exp b/test/lib/completions/cat.exp
new file mode 100644
index 00000000..46e8775f
--- /dev/null
+++ b/test/lib/completions/cat.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cat "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cc.exp b/test/lib/completions/cc.exp
new file mode 100644
index 00000000..1d63d006
--- /dev/null
+++ b/test/lib/completions/cc.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cc "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cd.exp b/test/lib/completions/cd.exp
new file mode 100644
index 00000000..58233575
--- /dev/null
+++ b/test/lib/completions/cd.exp
@@ -0,0 +1,47 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete"
+assert_complete {"bar bar.d/" foo.d/} "cd fixtures/shared/default/" $test
+
+
+sync_after_int
+
+
+set test "Tab should complete cd at cursor position"
+ # Try completion
+set cmd "cd fixtures/shared/default/foo"
+append cmd \002\002\002; # \002 = ^B = Move cursor left in bash emacs mode
+#append cmd \033\0133D; # Escape-[-D = Cursor left
+send "$cmd\t"
+expect {
+ -re "cd fixtures/shared/default/foo\b\b\b\r\n(\.svn/ +|)bar bar.d/ +foo.d/ *(\.svn/ *|)\r\n/@cd fixtures/shared/default/foo\b\b\b$" { pass "$test" }
+ -re "^cd fixtures/shared/default/foo\b\b\bfoo.d/foo\b\b\b$" { fail "$test: Wrong cursor position" }
+ -re /@ { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "Tab should complete CDPATH"
+ # Set CDPATH
+assert_bash_exec "CDPATH=\$PWD";
+assert_complete "fixtures/shared/default/foo.d/" "cd fixtures/shared/default/fo" $test
+sync_after_int
+ # Reset CDPATH
+assert_bash_exec "unset CDPATH"
+
+
+teardown
diff --git a/test/lib/completions/cdrecord.exp b/test/lib/completions/cdrecord.exp
new file mode 100644
index 00000000..d369f79d
--- /dev/null
+++ b/test/lib/completions/cdrecord.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cdrecord -d"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/change_pw.exp b/test/lib/completions/change_pw.exp
new file mode 100644
index 00000000..ca9bcdbd
--- /dev/null
+++ b/test/lib/completions/change_pw.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "change_pw -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/check_db.exp b/test/lib/completions/check_db.exp
new file mode 100644
index 00000000..ca59a715
--- /dev/null
+++ b/test/lib/completions/check_db.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "check_db -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/check_perms.exp b/test/lib/completions/check_perms.exp
new file mode 100644
index 00000000..a58995b0
--- /dev/null
+++ b/test/lib/completions/check_perms.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "check_perms -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/chgrp.exp b/test/lib/completions/chgrp.exp
new file mode 100644
index 00000000..8dfeea79
--- /dev/null
+++ b/test/lib/completions/chgrp.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "chgrp "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/chkconfig.exp b/test/lib/completions/chkconfig.exp
new file mode 100644
index 00000000..e7469b34
--- /dev/null
+++ b/test/lib/completions/chkconfig.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "chkconfig "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp
new file mode 100644
index 00000000..953b2b02
--- /dev/null
+++ b/test/lib/completions/chown.exp
@@ -0,0 +1,72 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set users [exec bash -c "compgen -A user"]
+assert_complete $users "chown "
+
+
+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 "chown $partuser"
+ sync_after_int
+
+ assert_complete $fulluser:$fullgroup "chown $fulluser:$partgroup"
+ sync_after_int
+
+ # One slash should work correctly (doubled here for tcl).
+ assert_complete $fulluser\\:$fullgroup "chown $fulluser\\:$partgroup"
+ sync_after_int
+
+ foreach prefix {
+ "funky\\ user:" "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 "chown $prefix$partgroup" $test
+ sync_after_int
+ }
+
+ # Check that we give up in degenerate cases instead of spewing various junk.
+
+ assert_no_complete "chown $fulluser\\\\:$partgroup"
+ sync_after_int
+
+ assert_no_complete "chown $fulluser\\\\\\:$partgroup"
+ sync_after_int
+
+ assert_no_complete "chown $fulluser\\\\\\\\:$partgroup"
+ sync_after_int
+
+ # Colons in user/groupnames are not usually allowed.
+ assert_no_complete "chown foo:bar:$partgroup"
+ sync_after_int
+}
+
+
+teardown
diff --git a/test/lib/completions/chsh.exp b/test/lib/completions/chsh.exp
new file mode 100644
index 00000000..99262a2c
--- /dev/null
+++ b/test/lib/completions/chsh.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "chsh -s "
+
+
+sync_after_int
+
+
+assert_complete [exec bash -c "compgen -A user"] "chsh "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ci.exp b/test/lib/completions/ci.exp
new file mode 100644
index 00000000..09105eec
--- /dev/null
+++ b/test/lib/completions/ci.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ci "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/civclient.exp b/test/lib/completions/civclient.exp
new file mode 100644
index 00000000..8159c2bc
--- /dev/null
+++ b/test/lib/completions/civclient.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "civclient -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/civserver.exp b/test/lib/completions/civserver.exp
new file mode 100644
index 00000000..df459688
--- /dev/null
+++ b/test/lib/completions/civserver.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "civserver -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cksfv.exp b/test/lib/completions/cksfv.exp
new file mode 100644
index 00000000..a40a5023
--- /dev/null
+++ b/test/lib/completions/cksfv.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cksfv -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cleanarch.exp b/test/lib/completions/cleanarch.exp
new file mode 100644
index 00000000..e3145e81
--- /dev/null
+++ b/test/lib/completions/cleanarch.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cleanarch -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/clisp.exp b/test/lib/completions/clisp.exp
new file mode 100644
index 00000000..2bc599ac
--- /dev/null
+++ b/test/lib/completions/clisp.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "clisp "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/clone_member.exp b/test/lib/completions/clone_member.exp
new file mode 100644
index 00000000..34b4db57
--- /dev/null
+++ b/test/lib/completions/clone_member.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "clone_member -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/co.exp b/test/lib/completions/co.exp
new file mode 100644
index 00000000..49fe3a64
--- /dev/null
+++ b/test/lib/completions/co.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "co "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/composite.exp b/test/lib/completions/composite.exp
new file mode 100644
index 00000000..e39ce72f
--- /dev/null
+++ b/test/lib/completions/composite.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "composite "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/config_list.exp b/test/lib/completions/config_list.exp
new file mode 100644
index 00000000..5246c860
--- /dev/null
+++ b/test/lib/completions/config_list.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "config_list -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/configure.exp b/test/lib/completions/configure.exp
new file mode 100644
index 00000000..74afba1b
--- /dev/null
+++ b/test/lib/completions/configure.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "configure --prefix "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/convert.exp b/test/lib/completions/convert.exp
new file mode 100644
index 00000000..d8a77e35
--- /dev/null
+++ b/test/lib/completions/convert.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "convert "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cowsay.exp b/test/lib/completions/cowsay.exp
new file mode 100644
index 00000000..dfbefe1a
--- /dev/null
+++ b/test/lib/completions/cowsay.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cowsay "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cp.exp b/test/lib/completions/cp.exp
new file mode 100644
index 00000000..9fe46537
--- /dev/null
+++ b/test/lib/completions/cp.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cp "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cpio.exp b/test/lib/completions/cpio.exp
new file mode 100644
index 00000000..b02f2719
--- /dev/null
+++ b/test/lib/completions/cpio.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cpio --"
+
+
+sync_after_int
+
+
+assert_complete [exec bash -c "compgen -A user"] "cpio -R "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/createdb.exp b/test/lib/completions/createdb.exp
new file mode 100644
index 00000000..1e5cdbe7
--- /dev/null
+++ b/test/lib/completions/createdb.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "createdb "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cryptsetup.exp b/test/lib/completions/cryptsetup.exp
new file mode 100644
index 00000000..e94c3ac1
--- /dev/null
+++ b/test/lib/completions/cryptsetup.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cryptsetup "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/csplit.exp b/test/lib/completions/csplit.exp
new file mode 100644
index 00000000..3a66a627
--- /dev/null
+++ b/test/lib/completions/csplit.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "csplit "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cut.exp b/test/lib/completions/cut.exp
new file mode 100644
index 00000000..b9bcf6c5
--- /dev/null
+++ b/test/lib/completions/cut.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cut "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cvs.exp b/test/lib/completions/cvs.exp
new file mode 100644
index 00000000..2a26da8e
--- /dev/null
+++ b/test/lib/completions/cvs.exp
@@ -0,0 +1,36 @@
+proc setup {} {
+ save_env
+ assert_bash_exec {OLDHOME=$HOME ; HOME=$TESTDIR/fixtures/cvs}
+}; # setup()
+
+
+proc teardown {} {
+ assert_bash_exec {HOME=$OLDHOME}
+ assert_env_unmodified {
+ /OLDHOME=/d
+ }
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cvs "
+
+
+sync_after_int
+
+
+set test "-d should complete CVS roots"
+set cmd "cvs -d "
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\n.*:pserver:.*\r\n/@$cmd:pserver:.*$" { pass "$test" }
+ default { fail "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/cvsps.exp b/test/lib/completions/cvsps.exp
new file mode 100644
index 00000000..1fd4a0a9
--- /dev/null
+++ b/test/lib/completions/cvsps.exp
@@ -0,0 +1,36 @@
+proc setup {} {
+ save_env
+ assert_bash_exec {OLDHOME=$HOME ; HOME=$TESTDIR/fixtures/cvs}
+}; # setup()
+
+
+proc teardown {} {
+ assert_bash_exec {HOME=$OLDHOME}
+ assert_env_unmodified {
+ /OLDHOME=/d
+ }
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "cvsps -"
+
+
+sync_after_int
+
+
+set test "No arguments should complete CVS roots"
+set cmd "cvsps "
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\n.*:pserver:.*\r\n/@$cmd:pserver:.*$" { pass "$test" }
+ default { fail "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/date.exp b/test/lib/completions/date.exp
new file mode 100644
index 00000000..9d75f5f3
--- /dev/null
+++ b/test/lib/completions/date.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "date "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dcop.exp b/test/lib/completions/dcop.exp
new file mode 100644
index 00000000..6ed800c5
--- /dev/null
+++ b/test/lib/completions/dcop.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {dcop} words]} {
+ assert_complete $words "dcop "
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dd.exp b/test/lib/completions/dd.exp
new file mode 100644
index 00000000..400dd143
--- /dev/null
+++ b/test/lib/completions/dd.exp
@@ -0,0 +1,33 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dd --"
+
+
+sync_after_int
+
+
+set test "option should be suffixed with ="
+set cmd "dd if"
+send "$cmd\t"
+expect -ex "$cmd"
+expect {
+ -re "^=$" { pass $test }
+ -re {^\\=$} { xfail $test }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/df.exp b/test/lib/completions/df.exp
new file mode 100644
index 00000000..487d70a9
--- /dev/null
+++ b/test/lib/completions/df.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "df "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dhclient.exp b/test/lib/completions/dhclient.exp
new file mode 100644
index 00000000..42c14c82
--- /dev/null
+++ b/test/lib/completions/dhclient.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dhclient -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dict.exp b/test/lib/completions/dict.exp
new file mode 100644
index 00000000..32fb4988
--- /dev/null
+++ b/test/lib/completions/dict.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dict -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/diff.exp b/test/lib/completions/diff.exp
new file mode 100644
index 00000000..c009f640
--- /dev/null
+++ b/test/lib/completions/diff.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "diff --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dir.exp b/test/lib/completions/dir.exp
new file mode 100644
index 00000000..6e20d37d
--- /dev/null
+++ b/test/lib/completions/dir.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dir "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/display.exp b/test/lib/completions/display.exp
new file mode 100644
index 00000000..9a9d6901
--- /dev/null
+++ b/test/lib/completions/display.exp
@@ -0,0 +1,41 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "display "
+
+
+sync_after_int
+
+
+set test "- should complete options"
+set options {
+ -alpha -antialias -authenticate -auto-orient -backdrop -background -border
+ -bordercolor -borderwidth -channel -clip -clip-path -coalesce -colormap
+ -colors -colorspace -comment -compress -contrast -crop -debug -decipher
+ -define -delay -density -depth -despeckle -display -dispose -dither -edge
+ -endian -enhance -extract -filter -flatten -flip -flop -font -foreground
+ -format -frame -gamma -geometry -help -iconGeometry -iconic -identify
+ -immutable -interlace -interpolate -label -limit -list -log -loop -map
+ -mattecolor -monitor -monochrome -name -negate -page -profile -quality
+ -quantize -quiet -raise -regard-warnings -remote -repage -resample -resize
+ -respect-parenthesis -roll -rotate -sample -sampling-factor -scenes -seed
+ -segment -set -shared-memory -sharpen -size -strip -texture -title
+ -transparent-color -treedepth -trim -update -usePixmap -verbose -version
+ -virtual-pixel -visual -window -window-group -write }
+assert_complete $options "display -" $test
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dnsspoof.exp b/test/lib/completions/dnsspoof.exp
new file mode 100644
index 00000000..3223a349
--- /dev/null
+++ b/test/lib/completions/dnsspoof.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dnsspoof -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dpkg-deb.exp b/test/lib/completions/dpkg-deb.exp
new file mode 100644
index 00000000..c8656610
--- /dev/null
+++ b/test/lib/completions/dpkg-deb.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dpkg-deb --c"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dpkg-reconfigure.exp b/test/lib/completions/dpkg-reconfigure.exp
new file mode 100644
index 00000000..267594be
--- /dev/null
+++ b/test/lib/completions/dpkg-reconfigure.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dpkg-reconfigure --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dpkg-source.exp b/test/lib/completions/dpkg-source.exp
new file mode 100644
index 00000000..a21eff45
--- /dev/null
+++ b/test/lib/completions/dpkg-source.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dpkg-source -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dpkg.exp b/test/lib/completions/dpkg.exp
new file mode 100644
index 00000000..2bd1fb6e
--- /dev/null
+++ b/test/lib/completions/dpkg.exp
@@ -0,0 +1,29 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dpkg --c"
+
+
+sync_after_int
+
+
+ # Build list of installed packages
+if {[assert_exec {dpkg --get-selections | command grep \[\[:space:\]\]install$ | cut -f1} packages]} {
+ assert_complete $packages "dpkg -L "
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dropdb.exp b/test/lib/completions/dropdb.exp
new file mode 100644
index 00000000..e78a2ba7
--- /dev/null
+++ b/test/lib/completions/dropdb.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dropdb "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dselect.exp b/test/lib/completions/dselect.exp
new file mode 100644
index 00000000..f6257294
--- /dev/null
+++ b/test/lib/completions/dselect.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dselect "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dsniff.exp b/test/lib/completions/dsniff.exp
new file mode 100644
index 00000000..a0cc43ac
--- /dev/null
+++ b/test/lib/completions/dsniff.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dsniff -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/du.exp b/test/lib/completions/du.exp
new file mode 100644
index 00000000..d1ffa8ca
--- /dev/null
+++ b/test/lib/completions/du.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "du "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dumpdb.exp b/test/lib/completions/dumpdb.exp
new file mode 100644
index 00000000..240214b3
--- /dev/null
+++ b/test/lib/completions/dumpdb.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "dumpdb "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/enscript.exp b/test/lib/completions/enscript.exp
new file mode 100644
index 00000000..7fefabdd
--- /dev/null
+++ b/test/lib/completions/enscript.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "enscript --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/env.exp b/test/lib/completions/env.exp
new file mode 100644
index 00000000..f03f5395
--- /dev/null
+++ b/test/lib/completions/env.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {env --help} "" "" "unsupported"]} {
+ assert_complete_any "env --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/evince.exp b/test/lib/completions/evince.exp
new file mode 100644
index 00000000..22279a26
--- /dev/null
+++ b/test/lib/completions/evince.exp
@@ -0,0 +1,35 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {/OLDPWD=/d}
+}; # teardown()
+
+
+setup
+
+
+# NOTE: The directory `fixtures/evince' contains an additional subdir `foo'
+# (should be visible as completion) and an additional file `.txt'
+# (shouldn't be visible as completion)
+set files {
+ foo/
+ .bmp .BMP .cbr .CBR .cbz .CBZ .djv .DJV .djvu .DJVU
+ .dvi .DVI .dvi.bz2 .dvi.BZ2 .DVI.bz2 .DVI.BZ2 .dvi.gz .dvi.GZ .DVI.gz .DVI.GZ
+ .eps .EPS .eps.bz2 .eps.BZ2 .EPS.bz2 .EPS.BZ2 .eps.gz .eps.GZ .EPS.gz .EPS.GZ
+ .gif .GIF .ico .ICO .jpeg .JPEG .jpg .JPG .miff .MIFF .pbm .PBM .pcx .PCX
+ .pdf .PDF .pdf.bz2 .pdf.BZ2 .PDF.bz2 .PDF.BZ2 .pdf.gz .pdf.GZ .PDF.gz .PDF.GZ
+ .pgm .PGM .png .PNG .pnm .PNM .ppm .PPM
+ .ps .PS .ps.bz2 .ps.BZ2 .PS.bz2 .PS.BZ2 .ps.gz .ps.GZ .PS.gz .PS.GZ
+ .tga .TGA .tif .TIF .tiff .TIFF
+ .xpm .XPM .xwd .XWD
+}
+assert_complete_dir $files "evince " "fixtures/evince"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/expand.exp b/test/lib/completions/expand.exp
new file mode 100644
index 00000000..d5cd6b17
--- /dev/null
+++ b/test/lib/completions/expand.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {expand --help} "" "" "unsupported"]} {
+ assert_complete_any "expand --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/filesnarf.exp b/test/lib/completions/filesnarf.exp
new file mode 100644
index 00000000..53cf01e4
--- /dev/null
+++ b/test/lib/completions/filesnarf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "filesnarf -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/find.exp b/test/lib/completions/find.exp
new file mode 100644
index 00000000..4b1728dc
--- /dev/null
+++ b/test/lib/completions/find.exp
@@ -0,0 +1,80 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {/OLDPWD=/d}
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "find "
+
+
+sync_after_int
+
+
+assert_complete_any "find -fstype "
+
+
+sync_after_int
+
+
+set options [list -daystart -depth -follow -help \
+ -ignore_readdir_race -maxdepth -mindepth -mindepth -mount \
+ -noignore_readdir_race -noleaf -regextype -version -warn -nowarn \
+ -xdev \
+ -amin -anewer -atime -cmin -cnewer -ctime -empty -executable -false \
+ -fstype -gid -group -ilname -iname -inum -ipath -iregex -iwholename \
+ -links -lname -mmin -mtime -name -newer -nogroup -nouser -path -perm \
+ -readable -regex -samefile -size -true -type -uid -used -user \
+ -wholename -writable -xtype -context \
+ -delete -exec -execdir -fls -fprint -fprint0 -fprintf -ls -ok -okdir \
+ -print -print0 -printf -prune -quit]
+assert_complete $options {find -}
+
+
+sync_after_int
+
+
+set test "-wholename should complete files/dirs"
+set dir fixtures/shared/default
+set files [split [exec bash -c "cd $dir && ls -p"] "\n"]
+assert_complete_dir $files "find -wholename " $dir
+
+
+sync_after_int
+
+
+set test "-uid should complete uids"
+ # Complete
+set cmd "find -uid "
+send "$cmd\t"
+expect {
+ -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "-gid should complete gids"
+ # Complete
+set cmd "find -gid "
+send "$cmd\t"
+expect {
+ -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/find_member.exp b/test/lib/completions/find_member.exp
new file mode 100644
index 00000000..58fac7d2
--- /dev/null
+++ b/test/lib/completions/find_member.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "find_member -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp
new file mode 100644
index 00000000..30f2b080
--- /dev/null
+++ b/test/lib/completions/finger.exp
@@ -0,0 +1,57 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete usernames"
+# Build string list of usernames
+set users {}
+foreach u [exec bash -c "compgen -A user"] {
+ lappend users $u
+}; # foreach
+assert_complete $users "finger " $test
+
+
+sync_after_int
+
+
+set test "Tab should complete partial username"
+assert_complete_partial [exec bash -c "compgen -A user"] "finger"
+
+
+sync_after_int
+
+
+set test "Tab should complete partial hostname"
+# Build string list of hostnames, starting with the character of the first
+# host, unless host starts with a COMP_WORDBREAKS character, e.g. a colon (:).
+# Hosts starting with a COMP_WORDBREAKS character are left out because these
+# are exceptional cases, requiring specific tests.
+set hosts {}
+set char ""
+foreach h [get_known_hosts] {
+ set first [string range $h 0 0]
+ if {$char == "" && [string first $first $COMP_WORDBREAKS] == -1} {set char $first}
+ if {$char != ""} {
+ # Only append unique hostnames starting with $char
+ if {$first == $char && [lsearch -exact $hosts "test@$h"] == -1} {
+ # Prefix hosts with username 'test@'
+ lappend hosts "test@$h"
+ }; # if
+ }; # if
+}; # foreach
+assert_complete $hosts "finger test@$char" $test
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/fmt.exp b/test/lib/completions/fmt.exp
new file mode 100644
index 00000000..28570682
--- /dev/null
+++ b/test/lib/completions/fmt.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {fmt --help} "" "" "unsupported"]} {
+ assert_complete_any "fmt -"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/fold.exp b/test/lib/completions/fold.exp
new file mode 100644
index 00000000..a5230b03
--- /dev/null
+++ b/test/lib/completions/fold.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {fold --help} "" "" "unsupported"]} {
+ assert_complete_any "fold --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/g++.exp b/test/lib/completions/g++.exp
new file mode 100644
index 00000000..4dc2591a
--- /dev/null
+++ b/test/lib/completions/g++.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "g++ "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/g4.exp b/test/lib/completions/g4.exp
new file mode 100644
index 00000000..203de061
--- /dev/null
+++ b/test/lib/completions/g4.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "g4 "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/g77.exp b/test/lib/completions/g77.exp
new file mode 100644
index 00000000..8802aca9
--- /dev/null
+++ b/test/lib/completions/g77.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "g77 "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gcc.exp b/test/lib/completions/gcc.exp
new file mode 100644
index 00000000..8e52a120
--- /dev/null
+++ b/test/lib/completions/gcc.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gcc "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gcj.exp b/test/lib/completions/gcj.exp
new file mode 100644
index 00000000..db52d59a
--- /dev/null
+++ b/test/lib/completions/gcj.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gcj "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gcl.exp b/test/lib/completions/gcl.exp
new file mode 100644
index 00000000..7cead846
--- /dev/null
+++ b/test/lib/completions/gcl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gcl "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gdb.exp b/test/lib/completions/gdb.exp
new file mode 100644
index 00000000..982f0878
--- /dev/null
+++ b/test/lib/completions/gdb.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gdb - "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/genaliases.exp b/test/lib/completions/genaliases.exp
new file mode 100644
index 00000000..064eb386
--- /dev/null
+++ b/test/lib/completions/genaliases.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "genaliases -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/getent.exp b/test/lib/completions/getent.exp
new file mode 100644
index 00000000..121f3b38
--- /dev/null
+++ b/test/lib/completions/getent.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "getent "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gkrellm.exp b/test/lib/completions/gkrellm.exp
new file mode 100644
index 00000000..f8b0dd4d
--- /dev/null
+++ b/test/lib/completions/gkrellm.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gkrellm -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gmplayer.exp b/test/lib/completions/gmplayer.exp
new file mode 100644
index 00000000..d9032698
--- /dev/null
+++ b/test/lib/completions/gmplayer.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gmplayer "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gnatmake.exp b/test/lib/completions/gnatmake.exp
new file mode 100644
index 00000000..902aa062
--- /dev/null
+++ b/test/lib/completions/gnatmake.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gnatmake "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gpc.exp b/test/lib/completions/gpc.exp
new file mode 100644
index 00000000..6c4d0383
--- /dev/null
+++ b/test/lib/completions/gpc.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gpc "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gperf.exp b/test/lib/completions/gperf.exp
new file mode 100644
index 00000000..aa24333e
--- /dev/null
+++ b/test/lib/completions/gperf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gperf --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gpg.exp b/test/lib/completions/gpg.exp
new file mode 100644
index 00000000..29fd2244
--- /dev/null
+++ b/test/lib/completions/gpg.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "gpg "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gprof.exp b/test/lib/completions/gprof.exp
new file mode 100644
index 00000000..592786af
--- /dev/null
+++ b/test/lib/completions/gprof.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {gprof --help} "" "" "unsupported"]} {
+ assert_complete_any "gprof --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/grep.exp b/test/lib/completions/grep.exp
new file mode 100644
index 00000000..3814df71
--- /dev/null
+++ b/test/lib/completions/grep.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "grep --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/grub.exp b/test/lib/completions/grub.exp
new file mode 100644
index 00000000..9578e789
--- /dev/null
+++ b/test/lib/completions/grub.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "grub --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gzip.exp b/test/lib/completions/gzip.exp
new file mode 100644
index 00000000..f212c61a
--- /dev/null
+++ b/test/lib/completions/gzip.exp
@@ -0,0 +1,28 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete"
+ # Try completion
+set cmd "gzip "
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\n.*$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/hcitool.exp b/test/lib/completions/hcitool.exp
new file mode 100644
index 00000000..9283adff
--- /dev/null
+++ b/test/lib/completions/hcitool.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "hcitool "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/head.exp b/test/lib/completions/head.exp
new file mode 100644
index 00000000..0d4f6a20
--- /dev/null
+++ b/test/lib/completions/head.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {head --help} "" "" "unsupported"]} {
+ assert_complete_any "head --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/iconv.exp b/test/lib/completions/iconv.exp
new file mode 100644
index 00000000..420e923c
--- /dev/null
+++ b/test/lib/completions/iconv.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "iconv -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/id.exp b/test/lib/completions/id.exp
new file mode 100644
index 00000000..155af52c
--- /dev/null
+++ b/test/lib/completions/id.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "id -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/identify.exp b/test/lib/completions/identify.exp
new file mode 100644
index 00000000..8f38ae47
--- /dev/null
+++ b/test/lib/completions/identify.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "identify -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ifdown.exp b/test/lib/completions/ifdown.exp
new file mode 100644
index 00000000..68225bb9
--- /dev/null
+++ b/test/lib/completions/ifdown.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ifdown "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ifup.exp b/test/lib/completions/ifup.exp
new file mode 100644
index 00000000..9d717178
--- /dev/null
+++ b/test/lib/completions/ifup.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ifup "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/indent.exp b/test/lib/completions/indent.exp
new file mode 100644
index 00000000..e8fc32b1
--- /dev/null
+++ b/test/lib/completions/indent.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "indent --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/info.exp b/test/lib/completions/info.exp
new file mode 100644
index 00000000..ed769f1a
--- /dev/null
+++ b/test/lib/completions/info.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "info "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/inject.exp b/test/lib/completions/inject.exp
new file mode 100644
index 00000000..7c093146
--- /dev/null
+++ b/test/lib/completions/inject.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "inject "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/insmod.exp b/test/lib/completions/insmod.exp
new file mode 100644
index 00000000..8e83f0b4
--- /dev/null
+++ b/test/lib/completions/insmod.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "insmod in"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/invoke-rc.d.exp b/test/lib/completions/invoke-rc.d.exp
new file mode 100644
index 00000000..4dc9f1d8
--- /dev/null
+++ b/test/lib/completions/invoke-rc.d.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "invoke-rc.d "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ipsec.exp b/test/lib/completions/ipsec.exp
new file mode 100644
index 00000000..15617a16
--- /dev/null
+++ b/test/lib/completions/ipsec.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ipsec "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ipv6calc.exp b/test/lib/completions/ipv6calc.exp
new file mode 100644
index 00000000..74ce95f7
--- /dev/null
+++ b/test/lib/completions/ipv6calc.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ipv6calc -"
+
+
+sync_after_int
+
+
+assert_complete_any "ipv6calc --in "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/irb.exp b/test/lib/completions/irb.exp
new file mode 100644
index 00000000..81bea6d2
--- /dev/null
+++ b/test/lib/completions/irb.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "irb "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/isql.exp b/test/lib/completions/isql.exp
new file mode 100644
index 00000000..87e16bca
--- /dev/null
+++ b/test/lib/completions/isql.exp
@@ -0,0 +1,23 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {/ODBCINI=/d}
+}; # teardown()
+
+
+setup
+
+
+assert_bash_exec {OLDODBCINI=$ODBCINI; ODBCINI=$TESTDIR/fixtures/isql/odbc.ini}
+assert_complete_any "isql "
+sync_after_int
+assert_bash_exec {ODBCINI=$OLDODBCINI; unset -v OLDODBCINI}
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/iwconfig.exp b/test/lib/completions/iwconfig.exp
new file mode 100644
index 00000000..f09719d7
--- /dev/null
+++ b/test/lib/completions/iwconfig.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "iwconfig --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/iwlist.exp b/test/lib/completions/iwlist.exp
new file mode 100644
index 00000000..80a2c367
--- /dev/null
+++ b/test/lib/completions/iwlist.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "iwlist --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/iwpriv.exp b/test/lib/completions/iwpriv.exp
new file mode 100644
index 00000000..f3102cc5
--- /dev/null
+++ b/test/lib/completions/iwpriv.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "iwpriv --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/iwspy.exp b/test/lib/completions/iwspy.exp
new file mode 100644
index 00000000..5fa0bee5
--- /dev/null
+++ b/test/lib/completions/iwspy.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_env_unmodified "iwspy --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/jar.exp b/test/lib/completions/jar.exp
new file mode 100644
index 00000000..0e11f684
--- /dev/null
+++ b/test/lib/completions/jar.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "jar "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/jarsigner.exp b/test/lib/completions/jarsigner.exp
new file mode 100644
index 00000000..075e0263
--- /dev/null
+++ b/test/lib/completions/jarsigner.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "jarsigner "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/java.exp b/test/lib/completions/java.exp
new file mode 100644
index 00000000..14610b2f
--- /dev/null
+++ b/test/lib/completions/java.exp
@@ -0,0 +1,46 @@
+proc setup {} {
+ assert_bash_exec {CLASSPATH=$TESTDIR/fixtures/java/a:$TESTDIR/fixtures/java/bashcomp.jar}
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "java -"
+
+
+sync_after_int
+
+
+assert_complete "b bashcomp.jarred toplevel" "java "
+
+
+sync_after_int
+
+
+assert_complete "bashcomp.jarred toplevel" \
+ "java -cp fixtures/java/bashcomp.jar "
+
+
+sync_after_int
+
+
+assert_no_complete "java -cp \"\" "
+
+
+sync_after_int
+
+
+assert_complete "a/ bashcomp.jar" "java -jar fixtures/java/"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/javac.exp b/test/lib/completions/javac.exp
new file mode 100644
index 00000000..6013de11
--- /dev/null
+++ b/test/lib/completions/javac.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "javac "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/javadoc.exp b/test/lib/completions/javadoc.exp
new file mode 100644
index 00000000..40c922ca
--- /dev/null
+++ b/test/lib/completions/javadoc.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "javadoc "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/k3b.exp b/test/lib/completions/k3b.exp
new file mode 100644
index 00000000..86942d67
--- /dev/null
+++ b/test/lib/completions/k3b.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "k3b "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/kdvi.exp b/test/lib/completions/kdvi.exp
new file mode 100644
index 00000000..0196049a
--- /dev/null
+++ b/test/lib/completions/kdvi.exp
@@ -0,0 +1,27 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {/OLDPWD=/d}
+}; # teardown()
+
+
+setup
+
+
+# NOTE: The directory `fixtures/kdvi' contains an additional subdir `foo'
+# (should be visible as completion) and an additional file `.txt'
+# (shouldn't be visible as completion)
+set files {
+ foo/
+ .dvi .DVI .dvi.bz2 .DVI.bz2 .dvi.gz .DVI.gz .dvi.Z .DVI.Z
+}
+assert_complete_dir $files "kdvi " "fixtures/kdvi"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/kill.exp b/test/lib/completions/kill.exp
new file mode 100644
index 00000000..ca02650c
--- /dev/null
+++ b/test/lib/completions/kill.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "kill 1"
+
+
+sync_after_int
+
+
+assert_complete [get_signals] "kill -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/killall.exp b/test/lib/completions/killall.exp
new file mode 100644
index 00000000..763c8e7d
--- /dev/null
+++ b/test/lib/completions/killall.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "killall "
+
+
+sync_after_int
+
+
+assert_complete [get_signals] "killall -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/kldload.exp b/test/lib/completions/kldload.exp
new file mode 100644
index 00000000..0493a10a
--- /dev/null
+++ b/test/lib/completions/kldload.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "kldload "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/kldunload.exp b/test/lib/completions/kldunload.exp
new file mode 100644
index 00000000..192159a5
--- /dev/null
+++ b/test/lib/completions/kldunload.exp
@@ -0,0 +1,24 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[catch {eval exec {kldstat | grep "\.ko$"}}] == 0} {
+ assert_complete_any "kldunload "
+} else {
+ assert_no_complete "kldunload "
+}
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/kpdf.exp b/test/lib/completions/kpdf.exp
new file mode 100644
index 00000000..010abcfb
--- /dev/null
+++ b/test/lib/completions/kpdf.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {/OLDPWD=/d}
+}; # teardown()
+
+
+setup
+
+
+# NOTE: The directory `fixtures/kpdf' contains an additional subdir `foo'
+# (should be visible as completion) and an additional file `.txt'
+# (shouldn't be visible as completion)
+set files {
+ foo/ .eps .ps .EPS .PS .pdf .PDF
+}
+assert_complete_dir $files "kpdf " "fixtures/kpdf"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/kplayer.exp b/test/lib/completions/kplayer.exp
new file mode 100644
index 00000000..34c9b3bf
--- /dev/null
+++ b/test/lib/completions/kplayer.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "kplayer "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/larch.exp b/test/lib/completions/larch.exp
new file mode 100644
index 00000000..076016f2
--- /dev/null
+++ b/test/lib/completions/larch.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "larch library-"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ld.exp b/test/lib/completions/ld.exp
new file mode 100644
index 00000000..60377991
--- /dev/null
+++ b/test/lib/completions/ld.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ld "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ldd.exp b/test/lib/completions/ldd.exp
new file mode 100644
index 00000000..e45d1df7
--- /dev/null
+++ b/test/lib/completions/ldd.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ldd "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/less.exp b/test/lib/completions/less.exp
new file mode 100644
index 00000000..269c9b5c
--- /dev/null
+++ b/test/lib/completions/less.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "less --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lftp.exp b/test/lib/completions/lftp.exp
new file mode 100644
index 00000000..a49a1935
--- /dev/null
+++ b/test/lib/completions/lftp.exp
@@ -0,0 +1,24 @@
+proc setup {} {
+ assert_bash_exec {HOME=$TESTDIR/fixtures/lftp}
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set expected [get_hosts]
+# `lftptest' is defined in ./fixtures/lftp/.lftp/bookmarks
+lappend expected lftptest
+assert_complete $expected "lftp "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lftpget.exp b/test/lib/completions/lftpget.exp
new file mode 100644
index 00000000..7d80216e
--- /dev/null
+++ b/test/lib/completions/lftpget.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lftpget -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lilo.exp b/test/lib/completions/lilo.exp
new file mode 100644
index 00000000..505a1470
--- /dev/null
+++ b/test/lib/completions/lilo.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lilo -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/links.exp b/test/lib/completions/links.exp
new file mode 100644
index 00000000..9f4896aa
--- /dev/null
+++ b/test/lib/completions/links.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "links "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lisp.exp b/test/lib/completions/lisp.exp
new file mode 100644
index 00000000..21663628
--- /dev/null
+++ b/test/lib/completions/lisp.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lisp "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/list_admins.exp b/test/lib/completions/list_admins.exp
new file mode 100644
index 00000000..e1c9c4dd
--- /dev/null
+++ b/test/lib/completions/list_admins.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "list_admins -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/list_lists.exp b/test/lib/completions/list_lists.exp
new file mode 100644
index 00000000..789ab1a8
--- /dev/null
+++ b/test/lib/completions/list_lists.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "list_lists -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/list_members.exp b/test/lib/completions/list_members.exp
new file mode 100644
index 00000000..c93b53d7
--- /dev/null
+++ b/test/lib/completions/list_members.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "list_members -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/list_owners.exp b/test/lib/completions/list_owners.exp
new file mode 100644
index 00000000..c96e0229
--- /dev/null
+++ b/test/lib/completions/list_owners.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "list_owners -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ln.exp b/test/lib/completions/ln.exp
new file mode 100644
index 00000000..34786071
--- /dev/null
+++ b/test/lib/completions/ln.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ln "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/look.exp b/test/lib/completions/look.exp
new file mode 100644
index 00000000..53a3c464
--- /dev/null
+++ b/test/lib/completions/look.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {look foo | grep ^foo} words]} {
+ assert_complete $words "look foo"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ls.exp b/test/lib/completions/ls.exp
new file mode 100644
index 00000000..db2d41d3
--- /dev/null
+++ b/test/lib/completions/ls.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {ls --help} "" "" "unsupported"]} {
+ assert_complete_any "ls --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvchange.exp b/test/lib/completions/lvchange.exp
new file mode 100644
index 00000000..ec3886b8
--- /dev/null
+++ b/test/lib/completions/lvchange.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvchange --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvcreate.exp b/test/lib/completions/lvcreate.exp
new file mode 100644
index 00000000..46dceb79
--- /dev/null
+++ b/test/lib/completions/lvcreate.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvcreate --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvdisplay.exp b/test/lib/completions/lvdisplay.exp
new file mode 100644
index 00000000..5a01a0e5
--- /dev/null
+++ b/test/lib/completions/lvdisplay.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvdisplay --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvextend.exp b/test/lib/completions/lvextend.exp
new file mode 100644
index 00000000..24a63853
--- /dev/null
+++ b/test/lib/completions/lvextend.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvextend --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvm.exp b/test/lib/completions/lvm.exp
new file mode 100644
index 00000000..1c67825e
--- /dev/null
+++ b/test/lib/completions/lvm.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvm pv"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvmdiskscan.exp b/test/lib/completions/lvmdiskscan.exp
new file mode 100644
index 00000000..27e566d4
--- /dev/null
+++ b/test/lib/completions/lvmdiskscan.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvmdiskscan --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvreduce.exp b/test/lib/completions/lvreduce.exp
new file mode 100644
index 00000000..edd5150d
--- /dev/null
+++ b/test/lib/completions/lvreduce.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvreduce --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvremove.exp b/test/lib/completions/lvremove.exp
new file mode 100644
index 00000000..1cd63150
--- /dev/null
+++ b/test/lib/completions/lvremove.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvremove --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvrename.exp b/test/lib/completions/lvrename.exp
new file mode 100644
index 00000000..51624222
--- /dev/null
+++ b/test/lib/completions/lvrename.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvrename --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvresize.exp b/test/lib/completions/lvresize.exp
new file mode 100644
index 00000000..830b9ab1
--- /dev/null
+++ b/test/lib/completions/lvresize.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvresize --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvs.exp b/test/lib/completions/lvs.exp
new file mode 100644
index 00000000..8b239f5d
--- /dev/null
+++ b/test/lib/completions/lvs.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvs --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lvscan.exp b/test/lib/completions/lvscan.exp
new file mode 100644
index 00000000..841fd0ed
--- /dev/null
+++ b/test/lib/completions/lvscan.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lvscan --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lzma.exp b/test/lib/completions/lzma.exp
new file mode 100644
index 00000000..79d78854
--- /dev/null
+++ b/test/lib/completions/lzma.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lzma "
+
+
+sync_after_int
+
+
+assert_complete "a/ bashcomp.lzma bashcomp.tlz" "lzma -d fixtures/xz/"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/lzop.exp b/test/lib/completions/lzop.exp
new file mode 100644
index 00000000..c33e814e
--- /dev/null
+++ b/test/lib/completions/lzop.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "lzop "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/m4.exp b/test/lib/completions/m4.exp
new file mode 100644
index 00000000..2cc884b3
--- /dev/null
+++ b/test/lib/completions/m4.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {m4 --help} "" "" "unsupported"]} {
+ assert_complete_any "m4 --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/macof.exp b/test/lib/completions/macof.exp
new file mode 100644
index 00000000..e21b1e77
--- /dev/null
+++ b/test/lib/completions/macof.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "macof -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mailmanctl.exp b/test/lib/completions/mailmanctl.exp
new file mode 100644
index 00000000..a69b7650
--- /dev/null
+++ b/test/lib/completions/mailmanctl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mailmanctl "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mailsnarf.exp b/test/lib/completions/mailsnarf.exp
new file mode 100644
index 00000000..df9981b7
--- /dev/null
+++ b/test/lib/completions/mailsnarf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mailsnarf -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/make.exp b/test/lib/completions/make.exp
new file mode 100644
index 00000000..90b9e68b
--- /dev/null
+++ b/test/lib/completions/make.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "make "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/man.exp b/test/lib/completions/man.exp
new file mode 100644
index 00000000..62c14c86
--- /dev/null
+++ b/test/lib/completions/man.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "man man"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mc.exp b/test/lib/completions/mc.exp
new file mode 100644
index 00000000..866161ba
--- /dev/null
+++ b/test/lib/completions/mc.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mc -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mcrypt.exp b/test/lib/completions/mcrypt.exp
new file mode 100644
index 00000000..bfc5d2d2
--- /dev/null
+++ b/test/lib/completions/mcrypt.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mcrypt "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/md5sum.exp b/test/lib/completions/md5sum.exp
new file mode 100644
index 00000000..25290b56
--- /dev/null
+++ b/test/lib/completions/md5sum.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "md5sum "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mdecrypt.exp b/test/lib/completions/mdecrypt.exp
new file mode 100644
index 00000000..4e49ae12
--- /dev/null
+++ b/test/lib/completions/mdecrypt.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mdecrypt "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mencoder.exp b/test/lib/completions/mencoder.exp
new file mode 100644
index 00000000..169dcb71
--- /dev/null
+++ b/test/lib/completions/mencoder.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mencoder "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/minicom.exp b/test/lib/completions/minicom.exp
new file mode 100644
index 00000000..935502f1
--- /dev/null
+++ b/test/lib/completions/minicom.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "minicom -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mkdir.exp b/test/lib/completions/mkdir.exp
new file mode 100644
index 00000000..43dfec7e
--- /dev/null
+++ b/test/lib/completions/mkdir.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mkdir "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mkfifo.exp b/test/lib/completions/mkfifo.exp
new file mode 100644
index 00000000..c6343f8d
--- /dev/null
+++ b/test/lib/completions/mkfifo.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mkfifo "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mkinitrd.exp b/test/lib/completions/mkinitrd.exp
new file mode 100644
index 00000000..cfb316e5
--- /dev/null
+++ b/test/lib/completions/mkinitrd.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mkinitrd "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mkisofs.exp b/test/lib/completions/mkisofs.exp
new file mode 100644
index 00000000..ad24ea06
--- /dev/null
+++ b/test/lib/completions/mkisofs.exp
@@ -0,0 +1,48 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mkisofs "
+
+
+sync_after_int
+
+
+set test "-uid should complete uids"
+ # Try completion
+set cmd "mkisofs -uid "
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\n\\d+.*$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "-gid should complete gids"
+ # Try completion
+set cmd "mkisofs -gid "
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\n\\d+.*$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mknod.exp b/test/lib/completions/mknod.exp
new file mode 100644
index 00000000..2c58cade
--- /dev/null
+++ b/test/lib/completions/mknod.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mknod "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mmsitepass.exp b/test/lib/completions/mmsitepass.exp
new file mode 100644
index 00000000..d69fa202
--- /dev/null
+++ b/test/lib/completions/mmsitepass.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mmsitepass "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/module.exp b/test/lib/completions/module.exp
new file mode 100644
index 00000000..a34667d4
--- /dev/null
+++ b/test/lib/completions/module.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "module "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mogrify.exp b/test/lib/completions/mogrify.exp
new file mode 100644
index 00000000..ef7e18ee
--- /dev/null
+++ b/test/lib/completions/mogrify.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mogrify "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/montage.exp b/test/lib/completions/montage.exp
new file mode 100644
index 00000000..736609a5
--- /dev/null
+++ b/test/lib/completions/montage.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "montage "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
new file mode 100644
index 00000000..38d93e3b
--- /dev/null
+++ b/test/lib/completions/mount.exp
@@ -0,0 +1,121 @@
+# 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 $(_get_pword) < "$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
+
+
+assert_complete_any "mount "
+
+
+sync_after_int
+
+
+assert_complete_any "mount -t "
+
+
+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
+
+
+set test "Testing internal __linux_fstab_unescape function for mount"
+# One round of slashes is for bash.
+assert_bash_exec {var=one\'two\\040three\\}
+assert_bash_exec {__linux_fstab_unescape var}
+set cmd {echo $var}
+send "$cmd\r"
+expect {
+ -ex "$cmd\r\none'two three\\" { pass $test }
+# default { fail $test }
+}
+sync_after_int
+assert_bash_exec {unset var}
+
+
+sync_after_int
+
+
+# Begin testing through mnt (see setup_dummy_mnt).
+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\ test\\p}
+sync_after_int
+
+assert_complete {{/mnt/nice\ test\\path} {/mnt/nice\ test-path}} \
+ {mnt /mnt/nice\ } "" /@ 20 {/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
+
+assert_complete {/mnt/other\'test\ path} {mnt /mnt/other}
+sync_after_int
+
+assert_complete {Ubuntu\ Karmic} {mnt -L Ubu}
+sync_after_int
+
+assert_complete {Debian-it\'s\ awesome} {mnt -L Deb}
+sync_after_int
+
+# 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
+
+
+teardown
diff --git a/test/lib/completions/mplayer.exp b/test/lib/completions/mplayer.exp
new file mode 100644
index 00000000..69e5d971
--- /dev/null
+++ b/test/lib/completions/mplayer.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mplayer "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/msgsnarf.exp b/test/lib/completions/msgsnarf.exp
new file mode 100644
index 00000000..74f458ff
--- /dev/null
+++ b/test/lib/completions/msgsnarf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "msgsnarf -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mtx.exp b/test/lib/completions/mtx.exp
new file mode 100644
index 00000000..a518d79f
--- /dev/null
+++ b/test/lib/completions/mtx.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mtx "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mutt.exp b/test/lib/completions/mutt.exp
new file mode 100644
index 00000000..6c727daf
--- /dev/null
+++ b/test/lib/completions/mutt.exp
@@ -0,0 +1,33 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {/OLDPWD=/d}
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mutt -"
+
+
+sync_after_int
+
+
+set test "mutt should complete mailboxes"
+set expected {foo/ bar/ muttrc}
+assert_complete_dir $expected "mutt -F muttrc -f =" fixtures/mutt
+
+
+set test "mutt should complete aliases"
+set expected {a1 a2}
+assert_complete_dir $expected "mutt -F muttrc -A " fixtures/mutt
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/muttng.exp b/test/lib/completions/muttng.exp
new file mode 100644
index 00000000..25a474ad
--- /dev/null
+++ b/test/lib/completions/muttng.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "muttng -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mv.exp b/test/lib/completions/mv.exp
new file mode 100644
index 00000000..f2576df7
--- /dev/null
+++ b/test/lib/completions/mv.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mv "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/mysqladmin.exp b/test/lib/completions/mysqladmin.exp
new file mode 100644
index 00000000..76381587
--- /dev/null
+++ b/test/lib/completions/mysqladmin.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "mysqladmin -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ncftp.exp b/test/lib/completions/ncftp.exp
new file mode 100644
index 00000000..ad71f226
--- /dev/null
+++ b/test/lib/completions/ncftp.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ncftp "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/netstat.exp b/test/lib/completions/netstat.exp
new file mode 100644
index 00000000..0e6414d6
--- /dev/null
+++ b/test/lib/completions/netstat.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "netstat "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/newlist.exp b/test/lib/completions/newlist.exp
new file mode 100644
index 00000000..bebf600d
--- /dev/null
+++ b/test/lib/completions/newlist.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "newlist "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/nl.exp b/test/lib/completions/nl.exp
new file mode 100644
index 00000000..02076dff
--- /dev/null
+++ b/test/lib/completions/nl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "nl "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/nm.exp b/test/lib/completions/nm.exp
new file mode 100644
index 00000000..551f49e9
--- /dev/null
+++ b/test/lib/completions/nm.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "nm "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ntpdate.exp b/test/lib/completions/ntpdate.exp
new file mode 100644
index 00000000..6a6456f4
--- /dev/null
+++ b/test/lib/completions/ntpdate.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ntpdate -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/objcopy.exp b/test/lib/completions/objcopy.exp
new file mode 100644
index 00000000..acb6539a
--- /dev/null
+++ b/test/lib/completions/objcopy.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "objcopy "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/objdump.exp b/test/lib/completions/objdump.exp
new file mode 100644
index 00000000..5eec35d6
--- /dev/null
+++ b/test/lib/completions/objdump.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "objdump "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/od.exp b/test/lib/completions/od.exp
new file mode 100644
index 00000000..5838218c
--- /dev/null
+++ b/test/lib/completions/od.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "od "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/openssl.exp b/test/lib/completions/openssl.exp
new file mode 100644
index 00000000..651e5e6d
--- /dev/null
+++ b/test/lib/completions/openssl.exp
@@ -0,0 +1,28 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete"
+ # Try completion
+set cmd "openssl "
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\n.*$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/p4.exp b/test/lib/completions/p4.exp
new file mode 100644
index 00000000..369d2c6b
--- /dev/null
+++ b/test/lib/completions/p4.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "p4 "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pack200.exp b/test/lib/completions/pack200.exp
new file mode 100644
index 00000000..f96eff13
--- /dev/null
+++ b/test/lib/completions/pack200.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pack200 "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/paste.exp b/test/lib/completions/paste.exp
new file mode 100644
index 00000000..3a4e93be
--- /dev/null
+++ b/test/lib/completions/paste.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "paste "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/patch.exp b/test/lib/completions/patch.exp
new file mode 100644
index 00000000..a44fa130
--- /dev/null
+++ b/test/lib/completions/patch.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "patch "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/perl.exp b/test/lib/completions/perl.exp
new file mode 100644
index 00000000..2199c994
--- /dev/null
+++ b/test/lib/completions/perl.exp
@@ -0,0 +1,95 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "perl "
+
+
+sync_after_int
+
+
+set test "Second argument should file complete"
+set cmd "perl foo fixtures/shared/default/f"
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\nfoo +foo.d/ *\r\n/@${cmd}oo$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}
+
+
+sync_after_int
+
+
+set test "-I without space should complete directories"
+set cmd "perl -Ifixtures/shared/default/"
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\nbar bar.d/ +foo.d/ *\r\n/@$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}
+
+
+sync_after_int
+
+
+set test "-I with space should complete directories"
+set cmd "perl -I fixtures/shared/default/"
+send "$cmd\t"
+expect {
+ -re "^$cmd\r\nbar bar.d/ +foo.d/ *\r\n/@$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}
+
+
+sync_after_int
+
+
+set test "-x without space should complete directories"
+set cmd "perl -xfixtures/shared/default/b"
+send "$cmd\t"
+expect {
+ -re "^${cmd}ar\\\\ bar.d/ *$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}
+
+
+sync_after_int
+
+
+set test "-x with space should complete directories"
+set cmd "perl -x fixtures/shared/default/b"
+send "$cmd\t"
+expect {
+ -re "^${cmd}ar\\\\ bar.d/ *$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}
+
+
+sync_after_int
+
+
+set test "- should complete options"
+set options {
+ -0 -a -c -C -d -D -e -F -h -i -I -l -m -M -n -p -P -s -S -T -u -U -v -V -w -W -x -X
+}
+assert_complete $options "perl -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/perldoc.exp b/test/lib/completions/perldoc.exp
new file mode 100644
index 00000000..b3ff83b3
--- /dev/null
+++ b/test/lib/completions/perldoc.exp
@@ -0,0 +1,38 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "perldoc -"
+
+
+sync_after_int
+
+
+set test "perldoc should complete word containing colons"
+set cmd "perldoc File::"
+send "$cmd\t"
+expect {
+ # Assuming the module `File::Path' is always installed
+ -re "\\sPath\\s" { pass "$test" }
+ # Assuming there's no perl module named `fixtures', but only our directory
+ # `test/fixtures' which is presented falsely.
+ -re "\\sfixtures/\\s" { fail "$test" }
+ -re "perldoc File::File::" { fail "$test" }
+ -re /@ { unresolved "$test" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pgrep.exp b/test/lib/completions/pgrep.exp
new file mode 100644
index 00000000..63143acc
--- /dev/null
+++ b/test/lib/completions/pgrep.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pgrep "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pine.exp b/test/lib/completions/pine.exp
new file mode 100644
index 00000000..0a0c3f40
--- /dev/null
+++ b/test/lib/completions/pine.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pine "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ping.exp b/test/lib/completions/ping.exp
new file mode 100644
index 00000000..b600849b
--- /dev/null
+++ b/test/lib/completions/ping.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ping "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pkg-config.exp b/test/lib/completions/pkg-config.exp
new file mode 100644
index 00000000..477dba08
--- /dev/null
+++ b/test/lib/completions/pkg-config.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pkg-config -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pkg_deinstall.exp b/test/lib/completions/pkg_deinstall.exp
new file mode 100644
index 00000000..8f3d8c3d
--- /dev/null
+++ b/test/lib/completions/pkg_deinstall.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ assert_bash_exec {PKG_DBDIR=fixtures/pkgtools/db}
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set pkgs [exec bash -c "cd fixtures/pkgtools/db ; compgen -d"]
+assert_complete $pkgs "pkg_deinstall "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pkg_delete.exp b/test/lib/completions/pkg_delete.exp
new file mode 100644
index 00000000..b0c1a2a5
--- /dev/null
+++ b/test/lib/completions/pkg_delete.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pkg_delete "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pkg_info.exp b/test/lib/completions/pkg_info.exp
new file mode 100644
index 00000000..3f253ccf
--- /dev/null
+++ b/test/lib/completions/pkg_info.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pkg_info "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pkill.exp b/test/lib/completions/pkill.exp
new file mode 100644
index 00000000..0333fc94
--- /dev/null
+++ b/test/lib/completions/pkill.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pkill "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/portinstall.exp b/test/lib/completions/portinstall.exp
new file mode 100644
index 00000000..d70f5db6
--- /dev/null
+++ b/test/lib/completions/portinstall.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ assert_bash_exec {PORTSDIR=fixtures/pkgtools/ports ; sed -e s,PORTSDIR,$PORTSDIR,g $PORTSDIR/INDEX.dist > $PORTSDIR/INDEX ; cp $PORTSDIR/INDEX $PORTSDIR/INDEX-5}
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_bash_exec {rm fixtures/pkgtools/ports/INDEX fixtures/pkgtools/ports/INDEX-5}
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete "bash-2.05b.007_6 bash-3.1.17 bash-completion-20060301_2 shells/bash shells/bash-completion shells/bash2" "portinstall "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/portupgrade.exp b/test/lib/completions/portupgrade.exp
new file mode 100644
index 00000000..cb583923
--- /dev/null
+++ b/test/lib/completions/portupgrade.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ assert_bash_exec {PKG_DBDIR=fixtures/pkgtools/db}
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete "a b-c-d" "portupgrade "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/povray.exp b/test/lib/completions/povray.exp
new file mode 100644
index 00000000..1efeeddb
--- /dev/null
+++ b/test/lib/completions/povray.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "povray "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pr.exp b/test/lib/completions/pr.exp
new file mode 100644
index 00000000..5d7a96c3
--- /dev/null
+++ b/test/lib/completions/pr.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pr "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/psql.exp b/test/lib/completions/psql.exp
new file mode 100644
index 00000000..56d56666
--- /dev/null
+++ b/test/lib/completions/psql.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "psql -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ptx.exp b/test/lib/completions/ptx.exp
new file mode 100644
index 00000000..2defe049
--- /dev/null
+++ b/test/lib/completions/ptx.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ptx "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pvchange.exp b/test/lib/completions/pvchange.exp
new file mode 100644
index 00000000..fd4b73d0
--- /dev/null
+++ b/test/lib/completions/pvchange.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pvchange --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pvcreate.exp b/test/lib/completions/pvcreate.exp
new file mode 100644
index 00000000..47cebf7a
--- /dev/null
+++ b/test/lib/completions/pvcreate.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pvcreate --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pvdisplay.exp b/test/lib/completions/pvdisplay.exp
new file mode 100644
index 00000000..151064cd
--- /dev/null
+++ b/test/lib/completions/pvdisplay.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pvdisplay --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pvmove.exp b/test/lib/completions/pvmove.exp
new file mode 100644
index 00000000..81c05e98
--- /dev/null
+++ b/test/lib/completions/pvmove.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pvmove --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pvremove.exp b/test/lib/completions/pvremove.exp
new file mode 100644
index 00000000..dd145bf6
--- /dev/null
+++ b/test/lib/completions/pvremove.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pvremove --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pvs.exp b/test/lib/completions/pvs.exp
new file mode 100644
index 00000000..6e5527e1
--- /dev/null
+++ b/test/lib/completions/pvs.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pvs --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pvscan.exp b/test/lib/completions/pvscan.exp
new file mode 100644
index 00000000..e92cdbe0
--- /dev/null
+++ b/test/lib/completions/pvscan.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "pvscan --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/python.exp b/test/lib/completions/python.exp
new file mode 100644
index 00000000..c9d70b43
--- /dev/null
+++ b/test/lib/completions/python.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "python "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/qrunner.exp b/test/lib/completions/qrunner.exp
new file mode 100644
index 00000000..b8fcf191
--- /dev/null
+++ b/test/lib/completions/qrunner.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "qrunner -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/querybts.exp b/test/lib/completions/querybts.exp
new file mode 100644
index 00000000..dc75cd62
--- /dev/null
+++ b/test/lib/completions/querybts.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "querybts --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rcs.exp b/test/lib/completions/rcs.exp
new file mode 100644
index 00000000..19ae4d50
--- /dev/null
+++ b/test/lib/completions/rcs.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rcs "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rcsdiff.exp b/test/lib/completions/rcsdiff.exp
new file mode 100644
index 00000000..8383cdb9
--- /dev/null
+++ b/test/lib/completions/rcsdiff.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rcsdiff "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rdict.exp b/test/lib/completions/rdict.exp
new file mode 100644
index 00000000..aa132617
--- /dev/null
+++ b/test/lib/completions/rdict.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rdict --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/readelf.exp b/test/lib/completions/readelf.exp
new file mode 100644
index 00000000..a084a41e
--- /dev/null
+++ b/test/lib/completions/readelf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "readelf --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/readonly.exp b/test/lib/completions/readonly.exp
new file mode 100644
index 00000000..84be3c96
--- /dev/null
+++ b/test/lib/completions/readonly.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "readonly BASH_ARG"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/remove_members.exp b/test/lib/completions/remove_members.exp
new file mode 100644
index 00000000..63d6a70e
--- /dev/null
+++ b/test/lib/completions/remove_members.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "remove_members --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/removepkg.exp b/test/lib/completions/removepkg.exp
new file mode 100644
index 00000000..7cf98805
--- /dev/null
+++ b/test/lib/completions/removepkg.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "removepkg "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/renice.exp b/test/lib/completions/renice.exp
new file mode 100644
index 00000000..c91e0212
--- /dev/null
+++ b/test/lib/completions/renice.exp
@@ -0,0 +1,42 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should show complete process ids"
+ # Try completion
+set cmd "renice 1"
+send "$cmd\t"
+expect {
+ -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "Tab should show complete process group ids"
+ # Try completion
+set cmd "renice -g "
+send "$cmd\t"
+expect {
+ -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/reportbug.exp b/test/lib/completions/reportbug.exp
new file mode 100644
index 00000000..1f66df2c
--- /dev/null
+++ b/test/lib/completions/reportbug.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "reportbug --m"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ri.exp b/test/lib/completions/ri.exp
new file mode 100644
index 00000000..160dc9a7
--- /dev/null
+++ b/test/lib/completions/ri.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ri "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rlog.exp b/test/lib/completions/rlog.exp
new file mode 100644
index 00000000..cbc06857
--- /dev/null
+++ b/test/lib/completions/rlog.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rlog "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rm.exp b/test/lib/completions/rm.exp
new file mode 100644
index 00000000..ae670e83
--- /dev/null
+++ b/test/lib/completions/rm.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rm "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rmdir.exp b/test/lib/completions/rmdir.exp
new file mode 100644
index 00000000..2b23a9c5
--- /dev/null
+++ b/test/lib/completions/rmdir.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rmdir "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rmlist.exp b/test/lib/completions/rmlist.exp
new file mode 100644
index 00000000..91519ee8
--- /dev/null
+++ b/test/lib/completions/rmlist.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rmlist -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rpcdebug.exp b/test/lib/completions/rpcdebug.exp
new file mode 100644
index 00000000..8629c947
--- /dev/null
+++ b/test/lib/completions/rpcdebug.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rpcdebug -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rpm.exp b/test/lib/completions/rpm.exp
new file mode 100644
index 00000000..3ed154a9
--- /dev/null
+++ b/test/lib/completions/rpm.exp
@@ -0,0 +1,29 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rpm "
+
+
+sync_after_int
+
+
+ # Build list of installed packages
+if {[assert_exec {rpm -qa --qf=%\{NAME\}\n | sort -u} packages]} {
+ assert_complete $packages "rpm -q "
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rsync.exp b/test/lib/completions/rsync.exp
new file mode 100644
index 00000000..fb301a35
--- /dev/null
+++ b/test/lib/completions/rsync.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rsync "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/rtcwake.exp b/test/lib/completions/rtcwake.exp
new file mode 100644
index 00000000..0b9a974b
--- /dev/null
+++ b/test/lib/completions/rtcwake.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "rtcwake "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sbcl-mt.exp b/test/lib/completions/sbcl-mt.exp
new file mode 100644
index 00000000..45e81f79
--- /dev/null
+++ b/test/lib/completions/sbcl-mt.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete {bar "bar bar.d/" foo foo.d/} "sbcl-mt fixtures/shared/default/"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sbcl.exp b/test/lib/completions/sbcl.exp
new file mode 100644
index 00000000..b68b2dce
--- /dev/null
+++ b/test/lib/completions/sbcl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete {bar "bar bar.d/" foo foo.d/} "sbcl fixtures/shared/default/"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp
new file mode 100644
index 00000000..efe2b686
--- /dev/null
+++ b/test/lib/completions/scp.exp
@@ -0,0 +1,121 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {
+ /BASH_LINENO=/d
+ /BASH_SOURCE=/d
+ /OLDPWD=/d
+ }
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete remote pwd"
+set host bash_completion
+
+ # Retrieving home directory (host_pwd) from ssh-host `bash_completion'
+ # yields error?
+if {
+ [catch {
+ exec -- ssh -o "Batchmode yes" -o "ConnectTimeout 1" $host pwd 2>> /dev/null
+ } host_pwd]
+} {
+ # Yes, retrieving pwd from ssh yields error; reset `host_pwd'
+ # Indicate host pwd is unknown and test is unsupported
+ # NOTE: To support this test, set the hostname "bash_completion"
+ # in `$HOME/.ssh/config' or `/etc/ssh_config'
+ set host_pwd ""
+ unsupported $test
+}; # if
+
+
+ # Try completion
+set cmd "scp $host:"
+send "$cmd\t"
+sync_after_tab
+expect {
+ -re "^$cmd$host_pwd.*$" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "Tab should complete known-hosts"
+
+ # Build string list of expected completions
+ # Get hostnames and give them a colon (:) suffix
+ # Hosts `gee' and `hus' are defined in ./fixtures/scp/config
+ # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts
+set expected {}
+foreach host [get_hosts] {
+ lappend expected "$host:"
+}; # foreach
+lappend expected doo: gee: hus: ike:
+ # Append local filenames
+lappend expected config known_hosts "spaced\\ \\ conf"
+set dir fixtures/scp
+assert_complete_dir $expected "scp -F config " $dir
+
+
+sync_after_int
+
+
+set test "-F without space shouldn't error"
+ # Try completion
+set cmd "scp -F"
+send "$cmd\t "
+expect {
+ -re "^${cmd}bash: option requires an argument -- F" { fail "$test" }
+ -re "^$cmd\r\n.*\r\n/@" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "Config file containing space should work"
+ # Build string list of expected completions
+ # Get hostnames and give them a colon (:) suffix
+set expected {}
+foreach host [get_hosts] {
+ lappend expected "$host:"
+}; # foreach
+ # Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf"
+ # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts
+lappend expected doo: gee: hus: ike: jar:
+ # Append local filenames
+lappend expected config known_hosts "spaced\\ \\ conf"
+set dir fixtures/scp
+#assert_complete_dir $expected "scp -F 'spaced conf' " $dir
+set prompt "/$dir/@"
+assert_bash_exec "cd $dir" "" $prompt
+set cmd "scp -F 'spaced conf' "
+send "$cmd\t"
+expect -ex "$cmd\r\n"
+if {[match_items [lsort -unique $expected] $test]} {
+ expect {
+ -re $prompt { pass "$test" }
+ -re eof { unresolved "eof" }
+ }; # expect
+} else {
+ # Expected failure (known bug) because of bash-4 bug in quoted words:
+ # http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html
+ if {[lindex $::BASH_VERSINFO 0] >= 4} {xfail "$test"} {fail "$test"}
+}; # if
+sync_after_int $prompt
+assert_bash_exec {cd "$TESTDIR"}
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp
new file mode 100644
index 00000000..985862c1
--- /dev/null
+++ b/test/lib/completions/screen.exp
@@ -0,0 +1,52 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {/OLDPWD=/d}
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "screen -"
+
+
+sync_after_int
+
+
+set test "-c should complete files/dirs"
+set dir fixtures/shared/default
+set prompt "/$dir/@"
+assert_bash_exec "cd $dir" "" $prompt
+set cmd "screen -c "
+set expected {bar {bar bar.d} foo {foo.d}}
+send "$cmd\t"
+expect -ex "$cmd"
+expect {
+ -re "\r\nbar\\s+bar bar.d/\\s+foo\\s+foo.d/" { pass "$test" }
+ # Directories might not be suffixed with a slash (/). This is because
+ # _filedir only works if `-o filenames' is in effect, which isn't the
+ # case for `screen' on bash-3, so an expected failure (xfail)
+ -re "\r\nbar\\s+bar bar.d\\s+foo\\s+foo.d" {
+ if {[lindex $::BASH_VERSINFO 0] < 4} {xfail "$test"} {fail "$test"}
+ }
+ -re "\r\nbar\\s+bar\\\\ bar.d/\\s+foo\\s+foo.d/" {
+ # On bash-3, the space in `bar bar.d' is escaped with a backslash
+ # as a side-effect of emulating `-o filenames'.
+ if {[lindex $::BASH_VERSINFO 0] <= 3} {pass "$test"} {fail "$test"}
+ }
+ -re $prompt { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+sync_after_int $prompt
+assert_bash_exec {cd "$TESTDIR"}
+
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sed.exp b/test/lib/completions/sed.exp
new file mode 100644
index 00000000..8764cfb8
--- /dev/null
+++ b/test/lib/completions/sed.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {sed --help} "" "" "unsupported"]} {
+ assert_complete_any "sed --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/seq.exp b/test/lib/completions/seq.exp
new file mode 100644
index 00000000..b5333ef9
--- /dev/null
+++ b/test/lib/completions/seq.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "seq --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/service.exp b/test/lib/completions/service.exp
new file mode 100644
index 00000000..917c5dcb
--- /dev/null
+++ b/test/lib/completions/service.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "service "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/set.exp b/test/lib/completions/set.exp
new file mode 100644
index 00000000..2b2d40e9
--- /dev/null
+++ b/test/lib/completions/set.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "set no"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp
new file mode 100644
index 00000000..24c37cb5
--- /dev/null
+++ b/test/lib/completions/sftp.exp
@@ -0,0 +1,77 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {
+ /BASH_LINENO=/d
+ /BASH_SOURCE=/d
+ /OLDPWD=/d
+ }
+}; # teardown()
+
+
+setup
+
+
+ # Build string list of expected completions
+set expected [get_hosts]
+ # Hosts `gee' and `hus' are defined in ./fixtures/sftp/config
+ # Hosts `doo' and `ike' are defined in ./fixtures/sftp/known_hosts
+lappend expected doo gee hus ike
+set dir fixtures/scp
+assert_complete_dir $expected "sftp -F config " $dir
+
+
+sync_after_int
+
+
+set test "-F without space shouldn't error"
+ # Try completion
+set cmd "sftp -F"
+send "$cmd\t "
+expect {
+ -re "^${cmd}bash: option requires an argument -- F" { fail "$test" }
+ -re "^$cmd\r\n.*\r\n/@" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+ # Build string list of expected completions
+ # Get hostnames and give them a colon (:) suffix
+set expected [get_hosts]
+ # Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf"
+ # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts
+lappend expected doo gee hus ike jar
+set dir fixtures/sftp
+assert_complete_dir $expected "sftp -F spaced\\ \\ conf " $dir
+
+
+sync_after_int
+
+
+set test "-F should complete filename"
+set dir fixtures/sftp
+set prompt "/$dir/@"
+assert_bash_exec "cd $dir" "" $prompt
+set cmd "ssh -Fsp"
+send "$cmd\t"
+expect -ex "$cmd"
+expect {
+ -ex "aced\\ \\ conf" { pass "$test" }
+ # _filedir works only if `-o filenames' is in effect, which isn't the
+ # case for `sftp'
+ -re "aced conf" { xfail "$test" }
+ -re $prompt { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+sync_after_int $prompt
+assert_bash_exec {cd "$TESTDIR"}
+
+
+teardown
diff --git a/test/lib/completions/sha1sum.exp b/test/lib/completions/sha1sum.exp
new file mode 100644
index 00000000..17519087
--- /dev/null
+++ b/test/lib/completions/sha1sum.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "sha1sum --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/shar.exp b/test/lib/completions/shar.exp
new file mode 100644
index 00000000..7ace9d6e
--- /dev/null
+++ b/test/lib/completions/shar.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "shar --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sitecopy.exp b/test/lib/completions/sitecopy.exp
new file mode 100644
index 00000000..49b78918
--- /dev/null
+++ b/test/lib/completions/sitecopy.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "sitecopy --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/smartctl.exp b/test/lib/completions/smartctl.exp
new file mode 100644
index 00000000..a9eeb956
--- /dev/null
+++ b/test/lib/completions/smartctl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "smartctl --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/snownews.exp b/test/lib/completions/snownews.exp
new file mode 100644
index 00000000..7502e587
--- /dev/null
+++ b/test/lib/completions/snownews.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "snownews --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sort.exp b/test/lib/completions/sort.exp
new file mode 100644
index 00000000..20516cc8
--- /dev/null
+++ b/test/lib/completions/sort.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "sort --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/split.exp b/test/lib/completions/split.exp
new file mode 100644
index 00000000..b74da369
--- /dev/null
+++ b/test/lib/completions/split.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {split --help} "" "" "unsupported"]} {
+ assert_complete_any "split --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/spovray.exp b/test/lib/completions/spovray.exp
new file mode 100644
index 00000000..30d81853
--- /dev/null
+++ b/test/lib/completions/spovray.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "spovray "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp
new file mode 100644
index 00000000..91955c1d
--- /dev/null
+++ b/test/lib/completions/ssh.exp
@@ -0,0 +1,93 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {
+ /BASH_LINENO=/d
+ /BASH_SOURCE=/d
+ /OLDPWD=/d
+ }
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete both commands and hostname"
+ # Try completion
+set dir fixtures/ssh
+set prompt "/$dir/@"
+assert_bash_exec "cd $dir" "" $prompt
+set cmd "ssh -F config ls"
+send "$cmd\t"
+set expected "^$cmd\r\n.*ls.*ls_known_host.*\r\n$prompt$cmd$"
+expect {
+ -re $expected { pass "$test" }
+ -re $prompt { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+sync_after_int $prompt
+assert_bash_exec {cd "$TESTDIR"}
+
+
+sync_after_int
+
+
+set test "-F without space shouldn't error"
+ # Try completion
+set cmd "ssh -F"
+send "$cmd\t "
+set expected "^$cmd $"
+expect {
+ -re "^${cmd}bash: option requires an argument -- F" { fail "$test" }
+ -re "^$cmd\r\n.*\r\n/@" { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "First argument shouldn't complete with commands"
+# NOTE: This test assumes there's a command "bash" and no host named "bash"
+set cmd "ssh bas"
+assert_complete [get_known_hosts "bas"] $cmd $test
+
+
+sync_after_int
+
+
+set test "First argument should complete partial hostname"
+assert_complete_partial [get_hosts] ssh "" $test /@ 20 \
+ [list "ltrim_colon_completions"]
+
+
+sync_after_int
+
+
+set test "-F should complete filename"
+set dir fixtures/ssh
+set prompt "/$dir/@"
+assert_bash_exec "cd $dir" "" $prompt
+set cmd "ssh -Fsp"
+send "$cmd\t"
+expect -ex "$cmd"
+expect {
+ -ex "aced\\ \\ conf" { pass "$test" }
+ # _filedir works only if `-o filenames' is in effect, which isn't the
+ # case for `ssh'
+ -re "aced conf" { xfail "$test" }
+ -re $prompt { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+sync_after_int $prompt
+assert_bash_exec {cd "$TESTDIR"}
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sshmitm.exp b/test/lib/completions/sshmitm.exp
new file mode 100644
index 00000000..b8f8a2c9
--- /dev/null
+++ b/test/lib/completions/sshmitm.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "sshmitm -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sshow.exp b/test/lib/completions/sshow.exp
new file mode 100644
index 00000000..36a6cc2c
--- /dev/null
+++ b/test/lib/completions/sshow.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "sshow -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/strace.exp b/test/lib/completions/strace.exp
new file mode 100644
index 00000000..55004d20
--- /dev/null
+++ b/test/lib/completions/strace.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "strace -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/strip.exp b/test/lib/completions/strip.exp
new file mode 100644
index 00000000..46d9f362
--- /dev/null
+++ b/test/lib/completions/strip.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "strip --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp
new file mode 100644
index 00000000..1299a6da
--- /dev/null
+++ b/test/lib/completions/sudo.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete "fixtures/shared/default/foo.d/" "sudo cd fixtures/shared/default/fo"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/svk.exp b/test/lib/completions/svk.exp
new file mode 100644
index 00000000..a08674dc
--- /dev/null
+++ b/test/lib/completions/svk.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "svk "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/svn.exp b/test/lib/completions/svn.exp
new file mode 100644
index 00000000..fe40d6f7
--- /dev/null
+++ b/test/lib/completions/svn.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "svn "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/svnadmin.exp b/test/lib/completions/svnadmin.exp
new file mode 100644
index 00000000..35e07021
--- /dev/null
+++ b/test/lib/completions/svnadmin.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "svnadmin "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/svnlook.exp b/test/lib/completions/svnlook.exp
new file mode 100644
index 00000000..33b67052
--- /dev/null
+++ b/test/lib/completions/svnlook.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "svnlook "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sync_members.exp b/test/lib/completions/sync_members.exp
new file mode 100644
index 00000000..4cb84ad8
--- /dev/null
+++ b/test/lib/completions/sync_members.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "sync_members --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/sysctl.exp b/test/lib/completions/sysctl.exp
new file mode 100644
index 00000000..e1866f55
--- /dev/null
+++ b/test/lib/completions/sysctl.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {sysctl -N -a 2>/dev/null | grep ^kern | sort -u} values]} {
+ assert_complete $values "sysctl kern"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tac.exp b/test/lib/completions/tac.exp
new file mode 100644
index 00000000..21230052
--- /dev/null
+++ b/test/lib/completions/tac.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "tac --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tail.exp b/test/lib/completions/tail.exp
new file mode 100644
index 00000000..c8a82d97
--- /dev/null
+++ b/test/lib/completions/tail.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {tail --help} "" "" "unsupported"]} {
+ assert_complete_any "tail --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tar.exp b/test/lib/completions/tar.exp
new file mode 100644
index 00000000..43c60ff9
--- /dev/null
+++ b/test/lib/completions/tar.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "tar "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tcpkill.exp b/test/lib/completions/tcpkill.exp
new file mode 100644
index 00000000..e8cc9c10
--- /dev/null
+++ b/test/lib/completions/tcpkill.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "tcpkill -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tcpnice.exp b/test/lib/completions/tcpnice.exp
new file mode 100644
index 00000000..44bb59c6
--- /dev/null
+++ b/test/lib/completions/tcpnice.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "tcpnice -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tee.exp b/test/lib/completions/tee.exp
new file mode 100644
index 00000000..c25057ba
--- /dev/null
+++ b/test/lib/completions/tee.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "tee "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/texindex.exp b/test/lib/completions/texindex.exp
new file mode 100644
index 00000000..d5b8cd77
--- /dev/null
+++ b/test/lib/completions/texindex.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "texindex --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tightvncviewer.exp b/test/lib/completions/tightvncviewer.exp
new file mode 100644
index 00000000..6eba24c2
--- /dev/null
+++ b/test/lib/completions/tightvncviewer.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "tightvncviewer "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/time.exp b/test/lib/completions/time.exp
new file mode 100644
index 00000000..b114318b
--- /dev/null
+++ b/test/lib/completions/time.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "time set"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/touch.exp b/test/lib/completions/touch.exp
new file mode 100644
index 00000000..f0960ef7
--- /dev/null
+++ b/test/lib/completions/touch.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {touch --help} "" "" "unsupported"]} {
+ assert_complete_any "touch --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tr.exp b/test/lib/completions/tr.exp
new file mode 100644
index 00000000..68b11a36
--- /dev/null
+++ b/test/lib/completions/tr.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {tr --help} "" "" "unsupported"]} {
+ assert_complete_any "tr --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/unace.exp b/test/lib/completions/unace.exp
new file mode 100644
index 00000000..0afbaafb
--- /dev/null
+++ b/test/lib/completions/unace.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "unace -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/uname.exp b/test/lib/completions/uname.exp
new file mode 100644
index 00000000..2179dafd
--- /dev/null
+++ b/test/lib/completions/uname.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {uname --help} "" "" "unsupported"]} {
+ assert_complete_any "uname --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/unexpand.exp b/test/lib/completions/unexpand.exp
new file mode 100644
index 00000000..31822561
--- /dev/null
+++ b/test/lib/completions/unexpand.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {unexpand --help} "" "" "unsupported"]} {
+ assert_complete_any "unexpand --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/uniq.exp b/test/lib/completions/uniq.exp
new file mode 100644
index 00000000..20dbcfac
--- /dev/null
+++ b/test/lib/completions/uniq.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {uniq --help} "" "" "unsupported"]} {
+ assert_complete_any "uniq --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/units.exp b/test/lib/completions/units.exp
new file mode 100644
index 00000000..a40b5f3f
--- /dev/null
+++ b/test/lib/completions/units.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {units --help} "" "" "unsupported"]} {
+ assert_complete_any "units --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/unpack200.exp b/test/lib/completions/unpack200.exp
new file mode 100644
index 00000000..845701dd
--- /dev/null
+++ b/test/lib/completions/unpack200.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "unpack200 "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/unrar.exp b/test/lib/completions/unrar.exp
new file mode 100644
index 00000000..e66e3c8b
--- /dev/null
+++ b/test/lib/completions/unrar.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "unrar -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/unset.exp b/test/lib/completions/unset.exp
new file mode 100644
index 00000000..a5e7fc9b
--- /dev/null
+++ b/test/lib/completions/unset.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "unset BASH_ARG"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/unshunt.exp b/test/lib/completions/unshunt.exp
new file mode 100644
index 00000000..964cac68
--- /dev/null
+++ b/test/lib/completions/unshunt.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "unshunt -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/update-alternatives.exp b/test/lib/completions/update-alternatives.exp
new file mode 100644
index 00000000..10ff4e6d
--- /dev/null
+++ b/test/lib/completions/update-alternatives.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "update-alternatives --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/update-rc.d.exp b/test/lib/completions/update-rc.d.exp
new file mode 100644
index 00000000..9c2c2464
--- /dev/null
+++ b/test/lib/completions/update-rc.d.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "update-rc.d -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/urlsnarf.exp b/test/lib/completions/urlsnarf.exp
new file mode 100644
index 00000000..c5b26922
--- /dev/null
+++ b/test/lib/completions/urlsnarf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "urlsnarf -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vdir.exp b/test/lib/completions/vdir.exp
new file mode 100644
index 00000000..b525c382
--- /dev/null
+++ b/test/lib/completions/vdir.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vdir "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgcfgbackup.exp b/test/lib/completions/vgcfgbackup.exp
new file mode 100644
index 00000000..19ceeeca
--- /dev/null
+++ b/test/lib/completions/vgcfgbackup.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgcfgbackup -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgcfgrestore.exp b/test/lib/completions/vgcfgrestore.exp
new file mode 100644
index 00000000..e1c3c3b9
--- /dev/null
+++ b/test/lib/completions/vgcfgrestore.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgcfgrestore -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgchange.exp b/test/lib/completions/vgchange.exp
new file mode 100644
index 00000000..645eedb4
--- /dev/null
+++ b/test/lib/completions/vgchange.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgchange -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgck.exp b/test/lib/completions/vgck.exp
new file mode 100644
index 00000000..67209b15
--- /dev/null
+++ b/test/lib/completions/vgck.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgck -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgconvert.exp b/test/lib/completions/vgconvert.exp
new file mode 100644
index 00000000..065c4828
--- /dev/null
+++ b/test/lib/completions/vgconvert.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgconvert -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgcreate.exp b/test/lib/completions/vgcreate.exp
new file mode 100644
index 00000000..7c324e62
--- /dev/null
+++ b/test/lib/completions/vgcreate.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgcreate -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgdisplay.exp b/test/lib/completions/vgdisplay.exp
new file mode 100644
index 00000000..b6bc9125
--- /dev/null
+++ b/test/lib/completions/vgdisplay.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgdisplay -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgexport.exp b/test/lib/completions/vgexport.exp
new file mode 100644
index 00000000..2ad4230e
--- /dev/null
+++ b/test/lib/completions/vgexport.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgexport -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgextend.exp b/test/lib/completions/vgextend.exp
new file mode 100644
index 00000000..18a491d2
--- /dev/null
+++ b/test/lib/completions/vgextend.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgextend -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgimport.exp b/test/lib/completions/vgimport.exp
new file mode 100644
index 00000000..e4568f3b
--- /dev/null
+++ b/test/lib/completions/vgimport.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgimport -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgmerge.exp b/test/lib/completions/vgmerge.exp
new file mode 100644
index 00000000..8ba5e893
--- /dev/null
+++ b/test/lib/completions/vgmerge.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgmerge -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgmknodes.exp b/test/lib/completions/vgmknodes.exp
new file mode 100644
index 00000000..d24552f0
--- /dev/null
+++ b/test/lib/completions/vgmknodes.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgmknodes -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgreduce.exp b/test/lib/completions/vgreduce.exp
new file mode 100644
index 00000000..887ba8de
--- /dev/null
+++ b/test/lib/completions/vgreduce.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgreduce -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgremove.exp b/test/lib/completions/vgremove.exp
new file mode 100644
index 00000000..26dadf95
--- /dev/null
+++ b/test/lib/completions/vgremove.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgremove -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgrename.exp b/test/lib/completions/vgrename.exp
new file mode 100644
index 00000000..8ddaa758
--- /dev/null
+++ b/test/lib/completions/vgrename.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgrename -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgs.exp b/test/lib/completions/vgs.exp
new file mode 100644
index 00000000..a27e3650
--- /dev/null
+++ b/test/lib/completions/vgs.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgs -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgscan.exp b/test/lib/completions/vgscan.exp
new file mode 100644
index 00000000..4bb8c35e
--- /dev/null
+++ b/test/lib/completions/vgscan.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgscan -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vgsplit.exp b/test/lib/completions/vgsplit.exp
new file mode 100644
index 00000000..54e7034f
--- /dev/null
+++ b/test/lib/completions/vgsplit.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vgsplit -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/vncviewer.exp b/test/lib/completions/vncviewer.exp
new file mode 100644
index 00000000..3d47f49f
--- /dev/null
+++ b/test/lib/completions/vncviewer.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified {
+ /declare -f _vncviewer_bootstrap/d
+ }
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "vncviewer "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/wc.exp b/test/lib/completions/wc.exp
new file mode 100644
index 00000000..8ad2bf8d
--- /dev/null
+++ b/test/lib/completions/wc.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {wc --help} "" "" "unsupported"]} {
+ assert_complete_any "wc --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/webmitm.exp b/test/lib/completions/webmitm.exp
new file mode 100644
index 00000000..1d48a3a6
--- /dev/null
+++ b/test/lib/completions/webmitm.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "webmitm -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/wget.exp b/test/lib/completions/wget.exp
new file mode 100644
index 00000000..245b27be
--- /dev/null
+++ b/test/lib/completions/wget.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "wget --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/who.exp b/test/lib/completions/who.exp
new file mode 100644
index 00000000..73928ef7
--- /dev/null
+++ b/test/lib/completions/who.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+if {[assert_exec {who --help} "" "" "unsupported"]} {
+ assert_complete_any "who --"
+}; # if
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/withlist.exp b/test/lib/completions/withlist.exp
new file mode 100644
index 00000000..6310466d
--- /dev/null
+++ b/test/lib/completions/withlist.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "withlist --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/wol.exp b/test/lib/completions/wol.exp
new file mode 100644
index 00000000..84a2d88d
--- /dev/null
+++ b/test/lib/completions/wol.exp
@@ -0,0 +1,29 @@
+proc setup {} {
+ # See fixtures/shared/bin/{arp,ifconfig}
+ assert_bash_exec {OLDPATH="$PATH"; PATH="$TESTDIR/fixtures/shared/bin:$PATH";}
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+ assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
+}; # teardown()
+
+
+setup
+
+
+assert_complete "00:00:00:00:00:00 11:11:11:11:11:11 22:22:22:22:22:22 33:33:33:33:33:33" "wol "
+
+
+sync_after_int
+
+
+assert_complete "00:00:00:00:00:00" "wol 00:"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/wtf.exp b/test/lib/completions/wtf.exp
new file mode 100644
index 00000000..8250becc
--- /dev/null
+++ b/test/lib/completions/wtf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "wtf "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/wvdial.exp b/test/lib/completions/wvdial.exp
new file mode 100644
index 00000000..8d4669de
--- /dev/null
+++ b/test/lib/completions/wvdial.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "wvdial -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xhost.exp b/test/lib/completions/xhost.exp
new file mode 100644
index 00000000..aeceadb6
--- /dev/null
+++ b/test/lib/completions/xhost.exp
@@ -0,0 +1,100 @@
+proc setup {} {
+ assert_bash_exec {HOME=$TESTDIR}
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete hostnames"
+ # Build string list of hostnames
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ lappend hosts $h
+}; # foreach
+assert_complete $hosts "xhost " $test
+
+
+sync_after_int
+
+
+set test "Tab should complete partial hostname"
+# Build string list of hostnames, starting with the character of the first hostname
+set hosts {}
+set char ""
+foreach h [exec bash -c "compgen -A hostname"] {
+ if {$char == ""} {set char [string range $h 0 0]}
+ # Only append hostname if starting with $char
+ if {[string range $h 0 0] == "$char"} {
+ lappend hosts $h
+ }; # if
+}; # foreach
+assert_complete $hosts "xhost $char" $test
+
+
+sync_after_int
+
+
+set test "Tab should complete hostnames prefixed with +"
+# Build string list of hostnames, prefixed with plus (+)
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ lappend hosts "+$h"
+}; # foreach
+assert_complete $hosts "xhost \+" $test
+
+
+sync_after_int
+
+
+set test "Tab should complete partial hostname prefixed with +"
+ # Build string list of hostnames, starting with character of first host.
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ if {$char == ""} {set char [string range $h 0 0]}
+ # Only append hostname if starting with $char
+ if {[string range $h 0 0] == "$char"} {
+ lappend hosts "+$h"
+ }; # if
+}; # foreach
+assert_complete $hosts "xhost +$char"
+
+
+sync_after_int
+
+
+set test "Tab should complete hostnames prefixed with -"
+ # Build string list of hostnames, prefix with minus (-)
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ lappend hosts "-$h"
+}; # foreach
+assert_complete $hosts "xhost -" $test
+
+
+sync_after_int
+
+
+set test "Tab should complete partial hostname prefixed with -"
+ # Build list of hostnames, starting with character of first host
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ if {$char == ""} {set char [string range $h 0 0]}
+ # Only append hostname if starting with $char
+ if {[string range $h 0 0] == "$char"} {
+ lappend hosts "-$h"
+ }; # if
+}; # foreach
+assert_complete $hosts "xhost -$char" $test
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xmllint.exp b/test/lib/completions/xmllint.exp
new file mode 100644
index 00000000..15451471
--- /dev/null
+++ b/test/lib/completions/xmllint.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "xmllint "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xmlwf.exp b/test/lib/completions/xmlwf.exp
new file mode 100644
index 00000000..a996d458
--- /dev/null
+++ b/test/lib/completions/xmlwf.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "xmlwf "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xmms.exp b/test/lib/completions/xmms.exp
new file mode 100644
index 00000000..c4ad64e8
--- /dev/null
+++ b/test/lib/completions/xmms.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "xmms --"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xpovray.exp b/test/lib/completions/xpovray.exp
new file mode 100644
index 00000000..92cc903d
--- /dev/null
+++ b/test/lib/completions/xpovray.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "xpovray "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xrandr.exp b/test/lib/completions/xrandr.exp
new file mode 100644
index 00000000..649ed43b
--- /dev/null
+++ b/test/lib/completions/xrandr.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "xrandr "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xsltproc.exp b/test/lib/completions/xsltproc.exp
new file mode 100644
index 00000000..2470c22e
--- /dev/null
+++ b/test/lib/completions/xsltproc.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "xsltproc "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xvnc4viewer.exp b/test/lib/completions/xvnc4viewer.exp
new file mode 100644
index 00000000..3456c3e7
--- /dev/null
+++ b/test/lib/completions/xvnc4viewer.exp
@@ -0,0 +1,45 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete options"
+set options {
+ -AcceptClipboard -AutoSelect -DebugDelay -display
+ -DotWhenNoCursor -FullColor -FullColour -FullScreen
+ -geometry -help -listen -Log
+ -LowColourLevel -MenuKey -name -Parent
+ -passwd -PasswordFile -PointerEventInterval -PreferredEncoding
+ -SendClipboard -SendPrimary -Shared -UseLocalCursor
+ -via -ViewOnly -WMDecorationHeight -WMDecorationWidth
+ -ZlibLevel
+}
+assert_complete $options {vncviewer -}
+
+
+sync_after_int
+
+
+set expected {hextile raw zrle}
+assert_complete $expected "xvnc4viewer -PreferredEncoding "
+
+
+sync_after_int
+
+
+set expected {hextile raw zrle}
+assert_complete $expected "xvnc4viewer --preferredencoding "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xz.exp b/test/lib/completions/xz.exp
new file mode 100644
index 00000000..820b0689
--- /dev/null
+++ b/test/lib/completions/xz.exp
@@ -0,0 +1,33 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "xz "
+
+
+sync_after_int
+
+
+assert_complete "a/ bashcomp.lzma bashcomp.tar.xz bashcomp.tlz bashcomp.xz" \
+ "xz -d fixtures/xz/"
+
+
+sync_after_int
+
+
+assert_complete "a/ bashcomp.tar" "xz fixtures/xz/"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ypcat.exp b/test/lib/completions/ypcat.exp
new file mode 100644
index 00000000..f1bd0c0e
--- /dev/null
+++ b/test/lib/completions/ypcat.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ypcat "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ypmatch.exp b/test/lib/completions/ypmatch.exp
new file mode 100644
index 00000000..f1695f67
--- /dev/null
+++ b/test/lib/completions/ypmatch.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "ypmatch foo "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/yum-arch.exp b/test/lib/completions/yum-arch.exp
new file mode 100644
index 00000000..defb7bf4
--- /dev/null
+++ b/test/lib/completions/yum-arch.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "yum-arch -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/yum.exp b/test/lib/completions/yum.exp
new file mode 100644
index 00000000..09d7282c
--- /dev/null
+++ b/test/lib/completions/yum.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+assert_complete_any "yum -"
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/library.exp b/test/lib/library.exp
new file mode 100644
index 00000000..c76d9854
--- /dev/null
+++ b/test/lib/library.exp
@@ -0,0 +1,908 @@
+ # Source `init.tcl' again to restore the `unknown' procedure
+ # NOTE: DejaGnu has an old `unknown' procedure which unfortunately disables
+ # tcl auto-loading.
+source [file join [info library] init.tcl]
+package require textutil::string
+
+
+
+# Execute a bash command and make sure the exit status is successful.
+# If not, output the error message.
+# @param string $cmd Bash command line to execute. If empty string (""), the
+# exit status of the previously executed bash command will be
+# checked; specify `title' to adorn the error message.
+# @param string $title (optional) Command title. If empty, `cmd' is used.
+# @param string $prompt (optional) Bash prompt. Default is "/@"
+# @param mixed $out (optional) Reference to (tcl) variable to hold output.
+# If variable equals -1 (default) the bash command is expected
+# to return no output. If variable equals 0, any output
+# from the bash command is disregarded.
+proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {out -1}} {
+ if {$out != 0 && $out != -1} {upvar $out results}
+ if {[string length $aCmd] != 0} {
+ send "$aCmd\r"
+ expect -ex "$aCmd\r\n"
+ }; # if
+ if {[string length $title] == 0} {set title $aCmd}
+ expect -ex $prompt
+ set results $expect_out(buffer); # Catch output
+ # Remove $prompt suffix from output
+ set results [
+ string range $results 0 [
+ expr [string length $results] - [string length $prompt] - 1
+ ]
+ ]
+ if {$out == -1 && [string length $results] > 0} {
+ if {[info exists multipass_name]} {
+ fail "ERROR Unexpected output from bash command \"$title\""
+ }; # if
+ send_user "ERROR Unexpected output from bash command \"$title\":\n$results"
+ }; # if
+
+ set cmd "echo $?"
+ send "$cmd\r"
+ expect {
+ -ex "$cmd\r\n0\r\n$prompt" {}
+ $prompt {
+ if {[info exists multipass_name]} {
+ fail "ERROR executing bash command \"$title\""
+ }; # if
+ send_user "ERROR executing bash command \"$title\""
+ }
+ }; # expect
+}; # assert_bash_exec()
+
+
+# Test `type ...' in bash
+# Indicate "unsupported" if `type' exits with error status.
+# @param string $command Command to locate
+proc assert_bash_type {command} {
+ set test "$command should be available in bash"
+ set cmd "type $command &> /dev/null && echo -n 0 || echo -n 1"
+ send "$cmd\r"
+ expect "$cmd\r\n"
+ expect {
+ -ex 0 { set result true }
+ -ex 1 { set result false; unsupported "$test" }
+ }; # expect
+ expect "/@"
+ return $result
+}; # assert_bash_type()
+
+
+# Make sure the expected list is returned by executing the specified command.
+# @param list $expected
+# @param string $cmd Command given to generate items
+# @param string $test (optional) Test title. Default is "$cmd<TAB> should show completions"
+# @param string $prompt (optional) Bash prompt. Default is "/@"
+# @param integer $size (optional) Chunk size. Default is 20.
+# @result boolean True if successful, False if not
+proc assert_bash_list {expected cmd {test ""} {prompt /@} {size 20}} {
+ if {$test == ""} {set test "$cmd should show expected output"}
+ if {[llength $expected] == 0} {
+ assert_no_output $cmd $test $prompt
+ } else {
+ send "$cmd\r"
+ expect -ex "$cmd\r\n"
+
+ if {[match_items $expected $test $prompt $size]} {
+ expect {
+ -re $prompt { pass "$test" }
+ -re eof { unresolved "eof" }
+ }
+ } else {
+ fail "$test"
+ }
+ }
+}
+
+
+proc assert_bash_list_dir {expected cmd dir {test ""} {prompt /@} {size 20}} {
+ set prompt "/$dir/@"
+ assert_bash_exec "cd $dir" "" $prompt
+ assert_bash_list $expected $cmd $test $prompt $size
+ sync_after_int $prompt
+ assert_bash_exec {cd "$TESTDIR"}
+}; # assert_bash_list_dir()
+
+
+# Make sure the expected items are returned by TAB-completing the specified
+# command.
+# @param list $expected Expected completions.
+# @param string $cmd Command given to generate items
+# @param string $test (optional) Test title. Default is "$cmd<TAB> should show completions"
+# @param string $prompt (optional) Bash prompt. Default is "/@"
+# @param integer $size (optional) Chunk size. Default is 20.
+# @param string $cword (optional) Last argument of $cmd which is an
+# argument-to-complete and to be replaced with the longest common prefix
+# of $expected. If empty string (default), `assert_complete' autodetects
+# if the last argument is an argument-to-complete by checking if $cmd
+# doesn't end with whitespace. Specifying `cword' should only be necessary
+# if this autodetection fails, e.g. when the last whitespace is escaped or
+# quoted, e.g. "finger foo\ " or "finger 'foo "
+# @param list $filters (optional) List of filters to apply to this function to tweak
+# the expected completions and argument-to-complete. Possible values:
+# - "ltrim_colon_completions"
+# @result boolean True if successful, False if not
+proc assert_complete {expected cmd {test ""} {prompt /@} {size 20} {cword ""} {filters ""}} {
+ if {[llength $expected] == 0} {
+ assert_no_complete $cmd $test
+ } else {
+ if {$test == ""} {set test "$cmd should show completions"}
+ send "$cmd\t"
+ if {[llength $expected] == 1} {
+ expect -ex "$cmd"
+
+ if {[lsearch -exact $filters "ltrim_colon_completions"] == -1} {
+ set cur ""; # Default to empty word to complete on
+ set words [split_words_bash $cmd]
+ if {[llength $words] > 1} {
+ # Assume last word of `$cmd' is word to complete on.
+ set index [expr [llength $words] - 1]
+ set cur [lindex $words $index]
+ }; # if
+ # Remove second word from beginning of single item $expected
+ if {[string first $cur $expected] == 0} {
+ set expected [list [string range $expected [string length $cur] end]]
+ }; # if
+ }; # if
+ } else {
+ expect -ex "$cmd\r\n"
+ # Make sure expected items are unique
+ set expected [lsort -unique $expected]
+ }; # if
+
+ if {[lsearch -exact $filters "ltrim_colon_completions"] != -1} {
+ # If partial contains colon (:), remove partial from begin of items
+ # See also: bash_completion.__ltrim_colon_completions()
+ _ltrim_colon_completions cword expected
+ }; # if
+
+ if {[match_items $expected $test $prompt $size]} {
+ if {[llength $expected] == 1} {
+ pass "$test"
+ } else {
+ # Remove optional (partial) last argument-to-complete from `cmd',
+ # E.g. "finger test@" becomes "finger"
+
+ if {[lsearch -exact $filters "ltrim_colon_completions"] != -1} {
+ set cmd2 $cmd
+ } else {
+ set cmd2 [_remove_cword_from_cmd $cmd $cword]
+ }; # if
+
+ # Determine common prefix of completions
+ set common [::textutil::string::longestCommonPrefixList $expected]
+ #if {[string length $common] > 0} {set common " $common"}
+ expect {
+ -ex "$prompt$cmd2$common" { pass "$test" }
+ -re $prompt { unresolved "$test at prompt" }
+ -re eof { unresolved "eof" }
+ }; # expect
+ }; # if
+ } else {
+ fail "$test"
+ }; # if
+ }; # if
+}; # assert_complete()
+
+
+# @param string $cmd Command to remove cword from
+# @param string $cword (optional) Last argument of $cmd which is an
+# argument-to-complete and to be deleted. If empty string (default),
+# `_remove_cword_from_cmd' autodetects if the last argument is an
+# argument-to-complete by checking if $cmd doesn't end with whitespace.
+# Specifying `cword' is only necessary if this autodetection fails, e.g.
+# when the last whitespace is escaped or quoted, e.g. "finger foo\ " or
+# "finger 'foo "
+# @return string Command with cword removed
+proc _remove_cword_from_cmd {cmd {cword ""}} {
+ set cmd2 $cmd
+ # Is $cword specified?
+ if {[string length $cword] > 0} {
+ # Remove $cword from end of $cmd
+ if {[string last $cword $cmd] == [string length $cmd] - [string length $cword]} {
+ set cmd2 [string range $cmd 0 [expr [string last $cword $cmd] - 1]]
+ }; # if
+ } else {
+ # No, $cword not specified;
+ # Check if last argument is really an-argument-to-complete, i.e.
+ # doesn't end with whitespace.
+ # NOTE: This check fails if trailing whitespace is escaped or quoted,
+ # e.g. "finger foo\ " or "finger 'foo ". Specify parameter
+ # $cword in those cases.
+ # Is last char whitespace?
+ if {! [string is space [string range $cmd end end]]} {
+ # No, last char isn't whitespace;
+ # Remove argument-to-complete from end of $cmd
+ set cmd2 [lrange [split $cmd] 0 end-1]
+ append cmd2 " "
+ }; # if
+ }; # if
+ return $cmd2
+}; # _remove_cword_from_cmd()
+
+
+# Escape regexp special characters
+proc _escape_regexp_chars {var} {
+ upvar $var str
+ regsub -all {([\^$+*?.|(){}[\]\\])} $str {\\\1} str
+}
+
+# Make sure any completions are returned
+proc assert_complete_any {cmd {test ""} {prompt /@}} {
+ if {$test == ""} {set test "$cmd should show completions"}
+ send "$cmd\t"
+ expect -ex "$cmd"
+ _escape_regexp_chars cmd
+ expect {
+ -timeout 1
+ # Match completions, multiple words
+ # NOTE: The `\S*' (zero or more non-whitespace characters) matches a
+ # longest common prefix of the completions shown.
+ # E.g. `fmt -' becomes `fmt --' (two dashes) when completing
+ -re "^\r\n.*$prompt$cmd\\S*$" { pass "$test" }
+ timeout {
+ expect {
+ # Match completion, single word. This word is shown on the
+ # same line as the command.
+ -re "^\\w+ $" { pass "$test" }
+ # Try matching multiple words again, with new timeout
+ -re "^\r\n.*$prompt$cmd\\S*$" { pass "$test" }
+ }
+ }
+ -re $prompt { unresolved "$test at prompt" }
+ eof { unresolved "eof" }
+ }; # expect
+}; # assert_complete_any()
+
+
+# Make sure the expected files are returned by TAB-completing the
+# specified command in the specified subdirectory.
+# @param list $expected
+# @param string $cmd Command given to generate items
+# @param string $dir Subdirectory to attempt completion in. The directory must be relative from the $TESTDIR and without a trailing slash. E.g. `fixtures/evince'
+# @param string $test (optional) Test title. Default is "$cmd<TAB> should show completions"
+# @param string $prompt (optional) Bash prompt. Default is "/@"
+# @param integer $size (optional) Chunk size. Default is 20.
+# @param string $cword (optional) Last word of $cmd to complete. See: assert_complete()
+# @result boolean True if successful, False if not
+proc assert_complete_dir {expected cmd dir {test ""} {size 20} {cword ""}} {
+ set prompt "/$dir/@"
+ assert_bash_exec "cd $dir" "" $prompt
+ assert_complete $expected $cmd $test $prompt $size $cword
+ sync_after_int $prompt
+ assert_bash_exec {cd "$TESTDIR"}
+}; # assert_complete_dir
+
+
+
+# Make sure a partial argument is completed.
+# A completion is tried with `$partial', or if this is empty, the first
+# character of the first item of `$expected'. Only the items from $expected,
+# starting with this character are then expected as completions.
+# @param list $expected List of all completions.
+# @param string $cmd Command given to generate items
+# @param string $partial Word to complete
+# @param string $test (optional) Test title. Default is "$cmd<TAB> should show completions"
+# @param string $prompt (optional) Bash prompt. Default is "/@"
+# @param integer $size (optional) Chunk size. Default is 20.
+# @param list $filters (optional) List of filters to apply to this function to tweak
+# the expected completions and argument-to-complete.
+# @see assert_complete()
+# @result boolean True if successful, False if not
+proc assert_complete_partial {expected cmd {partial ""} {test ""} {prompt /@} {size 20} {filters ""}} {
+ if {$test == ""} {set test "$cmd should complete partial argument"}
+ if {[llength $expected] == 0} {
+ unresolved "$test"
+ } else {
+ set pick {}
+ # Make sure expected items are unique
+ set expected [lsort -unique $expected]
+ foreach item $expected {
+ if {$partial == ""} {set partial [string range $item 0 0]}
+ # Only append item if starting with $partial
+ if {[string range $item 0 [expr [string length $partial] - 1]] == "$partial"} {
+ lappend pick $item
+ }; # if
+ }; # foreach
+ assert_complete $pick "$cmd $partial" $test $prompt $size $partial $filters
+ }; # if
+}; # assert_complete_partial()
+
+
+# See also: bash_completion._ltrim_colon_completions
+proc _ltrim_colon_completions {cword items} {
+ upvar 1 $cword cword_out
+ upvar 1 $items items_out
+ # If word-to-complete contains a colon,
+ # and bash-version < 4,
+ # or bash-version >= 4 and COMP_WORDBREAKS contains a colon
+ if {
+ [string first : $cword_out] > -1 && (
+ [lindex $::BASH_VERSINFO 0] < 4 ||
+ ([lindex $::BASH_VERSINFO 0] >= 4 && [string first ":" $::COMP_WORDBREAKS] > -1)
+ )
+ } {
+ for {set i 0} {$i < [llength $items_out]} {incr i} {
+ set item [lindex $items_out $i]
+ if {[string first $cword_out $item] == 0} {
+ # Strip colon-prefix
+ lset items_out $i [string range $item [string length $cword_out] end]
+ }; # if
+ }; # for
+ #set cword_out ""
+ }; # if
+}; # _ltrim_colon_completions()
+
+
+# Make sure the bash environment hasn't changed between now and the last call
+# to `save_env()'.
+# @param string $sed Sed commands to preprocess diff output.
+# Example calls:
+#
+# # Replace `COMP_PATH=.*' with `COMP_PATH=PATH'
+# assert_env_unmodified {s/COMP_PATH=.*/COMP_PATH=PATH/}
+#
+# # Remove lines containing `OLDPWD='
+# assert_env_unmodified {/OLDPWD=/d}
+#
+# @param string $file Filename to generate environment save file from. See
+# `gen_env_filename()'.
+# @param string $diff Expected diff output (after being processed by $sed)
+# @see save_env()
+proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} {
+ set test "Environment should not be modified"
+ _save_env [gen_env_filename $file 2]
+
+ # Prepare sed script
+
+ # Escape special bash characters ("\)
+ regsub -all {([\"\\])} $sed {\\\1} sed; #"# (fix Vim syntax highlighting)
+ # Escape newlines
+ regsub -all {\n} [string trim $sed] "\r\n" sed
+
+ # Prepare diff script
+
+ # If diff is filled, escape newlines and make sure it ends with a newline
+ if {[string length [string trim $diff]]} {
+ regsub -all {\n} [string trim $diff] "\r\n" diff
+ append diff "\r\n"
+ } else {
+ set diff ""
+ }; # if
+
+ # Execute diff
+
+ # NOTE: The dummy argument 'LAST-ARG' sets bash variable $_ (last argument) to
+ # 'LAST-ARG' so that $_ doesn't mess up the diff (as it would if $_
+ # was the (possibly multi-lined) sed script).
+ set cmd "diff_env \"[gen_env_filename $file 1]\" \"[gen_env_filename $file 2]\" \"$sed\" LAST-ARG"
+ send "$cmd\r"
+ expect "LAST-ARG\r\n"
+
+ expect {
+ -re "^$diff[wd]@$" { pass "$test" }
+ -re [wd]@ {
+ fail "$test"
+
+ # Show diff to user
+
+ set diff $expect_out(buffer)
+ # Remove possible `\r\n[wd]@' from end of diff
+ if {[string last "\r\n[wd]@" $diff] == [string length $diff] - [string length "\r\n[wd]@"]} {
+ set diff [string range $diff 0 [expr [string last "\r\n[wd]@" $diff] - 1]]
+ }; # if
+ send_user $diff;
+ }
+ }; # expect
+}; # assert_env_unmodified()
+
+
+# Make sure the specified command executed from within Tcl/Expect.
+# Fail the test with status UNSUPPORTED if Tcl fails with error "POSIX/ENOENT
+# (No such file or directory)", or with the given Tcl failure status command
+# (default "unresolved") if other error occurs.
+# NOTE: Further tests are assumed if executing the command is successful. The
+# test isn't immediately declared to have PASSED if the command is
+# executed successful.
+# @param string $command
+# @param string $stdout (optional) Reference to variable to hold stdout.
+# @param string $test (optional) Test title
+# @param string $failcmd (optional, default "unresolved") Failure command
+# @see assert_bash_exec()
+proc assert_exec {cmd {stdout ''} {test ''} {failcmd "unresolved"}} {
+ if {$test == ""} {set test "$cmd should execute successfully"}
+ upvar $stdout results
+ set status [catch {eval exec $cmd} results]
+ if {$status == 0} {
+ set result true
+ } else {
+ set result false
+ # Command not found (POSIX/ENOENT = no such file or directory)?
+ if {[lindex $::errorCode 0] == "POSIX" && [lindex $::errorCode 1] == "ENOENT"} {
+ # Yes, command not found;
+ # Indicate test is unsupported
+ unsupported "$test"
+ } else {
+ $failcmd "$test"
+ }; # if
+ }; # if
+ return $result
+}; # assert_exec()
+
+
+# Check that no completion is attempted on a certain command.
+# Params:
+# @cmd The command to attempt to complete.
+# @test Optional parameter with test name.
+proc assert_no_complete {{cmd} {test ""}} {
+ if {[string length $test] == 0} {
+ set test "$cmd shouldn't complete"
+ }; # if
+
+ send "$cmd\t"
+ expect -ex "$cmd"
+
+ # We can't anchor on $, simulate typing a magical string instead.
+ set endguard "Magic End Guard"
+ send "$endguard"
+ expect {
+ -re "^$endguard$" { pass "$test" }
+ default { fail "$test" }
+ timeout { fail "$test" }
+ }; # expect
+}; # assert_no_complete()
+
+
+# Check that no output is generated on a certain command.
+# @param string $cmd The command to attempt to complete.
+# @param string $test Optional parameter with test name.
+# @param string $prompt (optional) Bash prompt. Default is "/@"
+proc assert_no_output {{cmd} {test ""} {prompt /@}} {
+ if {[string length $test] == 0} {
+ set test "$cmd shouldn't generate output"
+ }
+
+ send "$cmd\r"
+ expect -ex "$cmd"
+
+ expect {
+ -re "^\r\n$prompt$" { pass "$test" }
+ default { fail "$test" }
+ timeout { fail "$test" }
+ }
+}
+
+
+# Source/run file with additional tests if completion for the specified command
+# is installed in bash.
+# @param string $command Command to check completion availability for.
+# @param string $file (optional) File to source/run. Default is
+# "lib/completions/$cmd.exp".
+proc assert_source_completions {command {file ""}} {
+ if {[is_bash_completion_installed_for $command]} {
+ if {[string length $file] == 0} {
+ set file "lib/completions/$command.exp"
+ }
+ source $file
+ } else {
+ untested $command
+ }
+}
+
+
+# Sort list.
+# `exec sort' is used instead of `lsort' to achieve exactly the
+# same sort order as in bash.
+# @param list $items
+# @return list Sort list
+proc bash_sort {items} {
+ return [split [exec sort << [join $items "\n"]] "\n"]
+}
+
+
+# Get 'known' hostnames. Looks also in ssh's 'known_hosts' files.
+# @param string cword (optional) Word, hosts should start with.
+# @return list Hostnames
+# @see get_hosts()
+proc get_known_hosts {{cword ''}} {
+ assert_bash_exec "_known_hosts_real '$cword'; echo_array COMPREPLY" \
+ {} /@ result
+ return $result
+}; # get_known_hosts()
+
+
+# Get hostnames
+# @return list Hostnames
+# @see get_known_hosts()
+proc get_hosts {} {
+ set hosts [exec bash -c "compgen -A hostname"]
+ # NOTE: Circumventing var `avahi_hosts' and appending directly to `hosts'
+ # causes an empty element to be inserted in `hosts'.
+ # -- FVu, Fri Jul 17 23:11:46 CEST 2009
+ set avahi_hosts [get_hosts_avahi]
+ if {[llength $avahi_hosts] > 0} {
+ lappend hosts $avahi_hosts
+ }; # if
+ return $hosts
+}; # get_hosts()
+
+
+# Get hostnames according to avahi
+# @return list Hostnames
+proc get_hosts_avahi {} {
+ # Retrieving hosts is successful?
+ if { [catch {exec bash -c {
+ type avahi-browse >&/dev/null \
+ && avahi-browse -cpr _workstation._tcp 2>/dev/null | command grep ^= | cut -d\; -f7 | sort -u
+ }} hosts] } {
+ # No, retrieving hosts yields error;
+ # Reset hosts
+ set hosts {}
+ }; # if
+ return $hosts
+}; # get_hosts_avahi()
+
+
+# Get signals
+# This function is written in analogy to the bash function `_signals()' in
+# `bash_completion'.
+# @return list Signals starting with `SIG', but with the `SIG' prefix removed.
+proc get_signals {} {
+ set signals {}
+ foreach signal [exec bash -c {compgen -A signal}] {
+ # Does signal start with `SIG'?
+ if {[string range $signal 0 [expr [string length "SIG"] - 1]] == "SIG"} {
+ # Remove `SIG' prefix
+ set signal [string range $signal 3 end]
+ # Add signal (with dash (-) prefix) to list
+ lappend signals -$signal
+ }; # if
+ }; # foreach
+ return $signals
+}; # get_signals()
+
+
+# Initialize tcl globals with bash variables
+proc init_tcl_bash_globals {} {
+ global BASH_VERSINFO BASH_VERSION COMP_WORDBREAKS
+ assert_bash_exec {printf "%s" "$COMP_WORDBREAKS"} {} /@ COMP_WORDBREAKS
+ assert_bash_exec {printf "%s " "${BASH_VERSINFO[@]}"} "" /@ BASH_VERSINFO
+ set BASH_VERSINFO [eval list $BASH_VERSINFO]
+ assert_bash_exec {printf "%s" "$BASH_VERSION"} "" /@ BASH_VERSION
+ assert_bash_exec {printf "%s" "$TESTDIR"} "" /@ TESTDIR
+}; # init_tcl_bash_globals()
+
+
+# Check whether completion is installed for the specified command by executing
+# `complete -p ...' in bash.
+# @param string $command Command to check completion availability for.
+# @return boolean True (1) if completion is installed, False (0) if not.
+proc is_bash_completion_installed_for {command} {
+ set test "$command should have completion installed in bash"
+ set cmd "complete -p $command &> /dev/null && echo -n 0 || echo -n 1"
+ send "$cmd\r"
+ expect "$cmd\r\n"
+ expect {
+ -ex 0 { set result true }
+ -ex 1 { set result false }
+ }
+ expect "/@"
+ return $result
+}; # is_bash_completion_installed_for()
+
+
+# Detect if test suite is running under Cygwin/Windows
+proc is_cygwin {} {
+ expr {[string first [string tolower [exec uname -s]] cygwin] >= 0}
+}; # is_cygwin()
+
+
+# Expect items.
+# Break items into chunks because `expect' seems to have a limited buffer size
+# @param list $items
+# @param integer $size Chunk size
+# @result boolean True if successful, False if not
+proc match_items {items test {prompt /@} {size 20}} {
+ set items [bash_sort $items]
+ set result false
+ for {set i 0} {$i < [llength $items]} {set i [expr {$i + $size}]} {
+ # For chunks > 1, allow leading whitespace
+ if {$i > $size} { set expected "\\s*" } else { set expected "" }
+ for {set j 0} {$j < $size && $i + $j < [llength $items]} {incr j} {
+ set item "[lindex $items [expr {$i + $j}]]"
+ _escape_regexp_chars item
+ append expected $item
+ if {[llength $items] > 1} {append expected {\s+}};
+ }; # for
+ if {[llength $items] == 1} {
+ expect {
+ -re "^$expected\r\n$" { set result true }
+ # NOTE: The optional space ( ?) depends on whether -o nospace is active
+ -re "^$expected ?$" { set result true }
+ -re "^$prompt$" {set result false; break }
+ "\r\n" { set result false; break }
+ default { set result false; break }
+ timeout { set result false; break }
+ }; # expect
+ } else {
+ expect {
+ -re "^$expected" { set result true }
+ default { set result false; break }
+ timeout { set result false; break }
+ }; # expect
+ }; # if
+ }; # for
+ return $result
+}; # match_items()
+
+
+
+# Get real command.
+# - arg: $1 Command
+# - return: Command found, empty string if not found
+proc realcommand {cmd} {
+ set result ""
+ if [string length [set path [auto_execok $cmd]]] {
+ if {[string length [auto_execok realpath]]} {
+ set result [exec realpath $path]
+ } elseif {[string length [auto_execok readlink]]} {
+ set result [exec readlink -f $path]
+ } else {
+ set result $path
+ }; # if
+ }; # if
+ return $result
+}; # realcommand()
+
+
+# Generate filename to save environment to.
+# @param string $file File-basename to save environment to. If the file has a
+# `.exp' suffix, it is removed. E.g.:
+# - "file.exp" becomes "file.env1~"
+# - "" becomes "env.env1~"
+# - "filename" becomes "filename.env1~"
+# The file will be stored in the $TESTDIR/tmp directory.
+# @param integer $seq Sequence number. Must be either 1 or 2.
+proc gen_env_filename {{file ""} {seq 1}} {
+ if {[string length $file] == 0} {
+ set file "env"
+ } else {
+ # Remove possible directories
+ set file [file tail $file]
+ # Remove possible '.exp' suffix from filename
+ if {[string last ".exp" $file] == [string length $file] - [string length ".exp"]} {
+ set file [string range $file 0 [expr [string last ".exp" $file] - 1]]
+ }; # if
+ }; # if
+ return "\$TESTDIR/tmp/$file.env$seq~"
+}; # gen_env_filename()
+
+
+# Save the environment for later comparison
+# @param string $file Filename to generate environment save file from. See
+# `gen_env_filename()'.
+proc save_env {{file ""}} {
+ _save_env [gen_env_filename $file 1]
+}; # save_env()
+
+
+# Save the environment for later comparison
+# @param string File to save the environment to. Default is "$TESTDIR/tmp/env1~".
+# @see assert_env_unmodified()
+proc _save_env {{file ""}} {
+ assert_bash_exec "{ set; declare -F; shopt -p; } > \"$file\""
+}; # _save_env()
+
+
+# Source bash_completion package
+proc source_bash_completion {} {
+ assert_bash_exec {BASH_COMPLETION_DIR=$(cd "$TESTDIR/.."; pwd)/contrib}
+ assert_bash_exec {BASH_COMPLETION_COMPAT_DIR=$BASH_COMPLETION_DIR}
+ assert_bash_exec {BASH_COMPLETION=$(cd "$TESTDIR/.."; pwd)/bash_completion}
+ assert_bash_exec {source "$BASH_COMPLETION"}
+}; # source_bash_completion()
+
+
+# Split line into words, disregarding backslash escapes (e.g. \b (backspace),
+# \g (bell)), but taking backslashed spaces into account.
+# Aimed for simulating bash word splitting.
+# Example usage:
+#
+# % set a {f cd\ \be}
+# % split_words $a
+# f {cd\ \be}
+#
+# @param string Line to split
+# @return list Words
+proc split_words_bash {line} {
+ set words {}
+ set glue false
+ foreach part [split $line] {
+ set glue_next false
+ # Does `part' end with a backslash (\)?
+ if {[string last "\\" $part] == [string length $part] - [string length "\\"]} {
+ # Remove end backslash
+ set part [string range $part 0 [expr [string length $part] - [string length "\\"] - 1]]
+ # Indicate glue on next run
+ set glue_next true
+ }; # if
+ # Must `part' be appended to latest word (= glue)?
+ if {[llength $words] > 0 && [string is true $glue]} {
+ # Yes, join `part' to latest word;
+ set zz [lindex $words [expr [llength $words] - 1]]
+ # Separate glue with backslash-space (\ );
+ lset words [expr [llength $words] - 1] "$zz\\ $part"
+ } else {
+ # No, don't append word to latest word;
+ # Append `part' as separate word
+ lappend words $part
+ }; # if
+ set glue $glue_next
+ }; # foreach
+ return $words
+}; # split_words_bash()
+
+
+# Given a list of items this proc finds a (part, full) pair so that when
+# completing from $part $full will be the only option.
+#
+# Arguments:
+# list The list of full completions.
+# partName Output parameter for the partial string.
+# fullName Output parameter for the full string, member of item.
+#
+# Results:
+# 1, or 0 if no suitable result was found.
+proc find_unique_completion_pair {{list} {partName} {fullName}} {
+ upvar $partName part
+ upvar $fullName full
+ set bestscore 0
+ set list [lsort $list]
+ set n [llength $list]
+ for {set i 0} {$i < $n} {incr i} {
+ set cur [lindex $list $i]
+ set curlen [string length $cur]
+
+ set prev [lindex $list [expr {$i - 1}]]
+ set next [lindex $list [expr {$i + 1}]]
+ set diffprev [expr {$prev == ""}]
+ set diffnext [expr {$next == ""}]
+
+ # Analyse each item of the list and look for the minimum length of the
+ # partial prefix which is distinct from both $next and $prev. The list
+ # is sorted so the prefix will be unique in the entire list.
+ #
+ # In the worst case we analyse every character in the list 3 times.
+ # That's actually very fast, sorting could take more.
+ for {set j 0} {$j < $curlen} {incr j} {
+ set curchar [string index $cur $j]
+ if {!$diffprev && [string index $prev $j] != $curchar} {
+ set diffprev 1
+ }
+ if {!$diffnext && [string index $next $j] != $curchar} {
+ set diffnext 1
+ }
+ if {$diffnext && $diffprev} {
+ break
+ }
+ }
+
+ # At the end of the loop $j is the index of last character of
+ # the unique partial prefix. The length is one plus that.
+ set parlen [expr {$j + 1}]
+ if {$parlen >= $curlen} {
+ continue
+ }
+
+ # Try to find the most "readable pair"; look for a long pair where
+ # $part is about half of $full.
+ if {$parlen < $curlen / 2} {
+ set parlen [expr {$curlen / 2}]
+ }
+ set score [expr {$curlen - $parlen}]
+ if {$score > $bestscore} {
+ set bestscore $score
+ set part [string range $cur 0 [expr {$parlen - 1}]]
+ set full $cur
+ }
+ }
+ return [expr {$bestscore != 0}]
+}
+
+
+# Start bash running as test environment.
+proc start_bash {} {
+ global TESTDIR TOOL_EXECUTABLE spawn_id
+ set TESTDIR [pwd]
+ # If `--tool_exec' option not specified, use "bash"
+ if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash}
+ exp_spawn $TOOL_EXECUTABLE --rcfile config/bashrc
+ assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile config/bashrc"
+ # Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS
+ # whenever a shopt setting is sourced or eval'ed. Disabling 'history'
+ # makes it not show in tests "Environment should not be modified"
+ # for bash < 3.2.41.
+ # -- FVu, Tue Sep 15 22:52:00 CEST 2009
+ assert_bash_exec {is_bash_version_minimal 3 2 41 || set +o history}
+}; # start_bash()
+
+
+# Redirect xtrace output to a file.
+#
+# 'set -x' can be very useful for debugging but by default it writes to
+# stderr. Bash 4.1 has a feature to redirect this output to a random FD.
+#
+# This function uses file descriptor 6. This will break if any completion
+# tries to use the same descriptor.
+proc init_bash_xtrace {{fname xtrace.log}} {
+ global BASH_VERSINFO
+ if {([lindex $BASH_VERSINFO 0] == 4 && [lindex $BASH_VERSINFO 1] < 1) ||
+ [lindex $BASH_VERSINFO 0] < 4} {
+ note "BASH_XTRACEFD not available in this version; no xtrace.log"
+ return
+ }
+ verbose "Enabling bash xtrace output to '$fname'"
+ assert_bash_exec "exec 6>'$fname'"
+ assert_bash_exec "BASH_XTRACEFD=6"
+ assert_bash_exec "set -o xtrace"
+}
+
+
+# Setup test environment
+#
+# Common initialization for unit and completion tests.
+proc start_interactive_test {} {
+ start_bash
+ source_bash_completion
+ init_tcl_bash_globals
+
+ global OPT_BASH_XTRACE
+ if {[info exists OPT_BASH_XTRACE]} {
+ init_bash_xtrace
+ }
+ global OPT_TIMEOUT
+ if {[info exists OPT_TIMEOUT]} {
+ global timeout
+ verbose "Changing default expect timeout from $timeout to $OPT_TIMEOUT"
+ set timeout $OPT_TIMEOUT
+ }
+}
+
+
+# Interrupt completion and sync with prompt.
+# Send signals QUIT & INT.
+# @param string $prompt (optional) Bash prompt. Default is "/@"
+proc sync_after_int {{prompt /@}} {
+ set test "Sync after INT"
+ sleep .1
+ send \031\003; # QUIT/INT
+ # Wait to allow bash to become ready
+ # See also: http://lists.alioth.debian.org/pipermail/bash-completion-devel/
+ # 2010-February/002566.html
+ sleep .1
+ # NOTE: Regexp `.*' causes `expect' to discard previous unknown output.
+ # This is necessary if a completion doesn't match expectations.
+ # For instance with `filetype_xspec' completion (e.g. `kdvi') if
+ # one expects `.txt' as a completion (wrong, because it isn't
+ # there), the unmatched completions need to be cleaned up.
+ expect -re ".*$prompt$"
+}
+
+
+proc sync_after_tab {} {
+ # NOTE: Wait in case completion returns nothing - because `units' isn't
+ # installed, so that "^$cdm.*$" doesn't match too early - before
+ # comp_install has finished
+ sleep .4
+}; # sync_after_tab()
+
+
+# Return current working directory with `TESTDIR' stripped
+# @return string Working directory. E.g. /, or /fixtures/
+proc wd {} {
+ global TESTDIR
+ # Remove `$TESTDIR' prefix from current working directory
+ set wd [string replace [pwd] 0 [expr [string length $TESTDIR] - 1]]/
+}; # wd()
diff --git a/test/lib/library.sh b/test/lib/library.sh
new file mode 100644
index 00000000..98107dcb
--- /dev/null
+++ b/test/lib/library.sh
@@ -0,0 +1,75 @@
+# Bash library for bash-completion DejaGnu testsuite
+
+
+# @param $1 Char to add to $COMP_WORDBREAKS
+# @see remove_comp_wordbreak_char()
+add_comp_wordbreak_char() {
+ if [ ${BASH_VERSINFO[0]} -ge 4 ]; then
+ [[ "${COMP_WORDBREAKS//[^$1]}" ]] || COMP_WORDBREAKS=$COMP_WORDBREAKS$1
+ fi
+} # add_comp_wordbreak_char()
+
+
+# Diff environment files to detect if environment is unmodified
+# @param $1 File 1
+# @param $2 File 2
+# @param $3 Additional sed script
+diff_env() {
+ diff "$1" "$2" | sed -e "
+# Remove diff line indicators
+ /^[0-9,]\{1,\}[acd]/d
+# Remove diff block separators
+ /---/d
+# Remove underscore variable
+ /[<>] _=/d
+# Remove PPID bash variable
+ /[<>] PPID=/d
+ $3"
+} # diff_env()
+
+
+# Output array elements, sorted and separated by newline
+# Unset variable after outputting.
+# @param $1 Name of array variable to process
+echo_array() {
+ local name=$1[@]
+ printf "%s\n" "${!name}" | sort
+} # echo_array()
+
+
+# Check if current bash version meets specified minimum
+# @param $1 (integer) Major version number
+# @param $2 (integer) Minor version number
+# @param $3 (integer) Patch level
+# @return 0 if success, > 0 if not
+is_bash_version_minimal() {
+ [[ (
+ ${BASH_VERSINFO[0]} -gt $1
+ ) || (
+ ${BASH_VERSINFO[0]} -eq $1 &&
+ ${BASH_VERSINFO[1]} -gt $2
+ ) || (
+ ${BASH_VERSINFO[0]} -eq $1 &&
+ ${BASH_VERSINFO[1]} -eq $2 &&
+ ${BASH_VERSINFO[2]} -ge $3
+ )
+ ]]
+} # is_bash_version_minimal()
+
+
+# @param $1 Char to remove from $COMP_WORDBREAKS
+# @see add_comp_wordbreak_char()
+remove_comp_wordbreak_char() {
+ if [ ${BASH_VERSINFO[0]} -ge 4 ]; then
+ COMP_WORDBREAKS=${COMP_WORDBREAKS//$1}
+ fi
+} # remove_comp_wordbreak_char()
+
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/test/lib/unit.exp b/test/lib/unit.exp
new file mode 100644
index 00000000..de870332
--- /dev/null
+++ b/test/lib/unit.exp
@@ -0,0 +1,17 @@
+source lib/library.exp
+
+
+proc unit_exit {} {
+ # Exit bash
+ send "\rexit\r"
+}
+
+
+proc unit_start {} {
+ start_interactive_test
+}
+
+
+proc unit_version {} {
+ puts "$::TESTDIR, bash-$::BASH_VERSION"
+}