diff options
author | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2018-03-18 12:02:11 -0300 |
---|---|---|
committer | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2018-03-18 12:02:11 -0300 |
commit | 9cd22d1df8f0f5b554858471c86faa9f37b8fed4 (patch) | |
tree | 6399b936aecc388506ec32cfc10fdb06cfc1949f /test | |
parent | 6d88f1055806932d9291f96847d2b691cccda2cd (diff) | |
download | bash-completion-9cd22d1df8f0f5b554858471c86faa9f37b8fed4.tar.gz |
New upstream version 2.8upstream/2.8
Diffstat (limited to 'test')
163 files changed, 1475 insertions, 705 deletions
diff --git a/test/completion/acroread.exp b/test/completion/acroread.exp index 95704601..e23e98dd 100644 --- a/test/completion/acroread.exp +++ b/test/completion/acroread.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed acroread - -source "$::srcdir/lib/completions/acroread.exp" +assert_source_completions acroread diff --git a/test/completion/ccze.exp b/test/completion/ccze.exp new file mode 100644 index 00000000..4ec83394 --- /dev/null +++ b/test/completion/ccze.exp @@ -0,0 +1 @@ +assert_source_completions ccze diff --git a/test/completion/cfrun.exp b/test/completion/cfrun.exp new file mode 100644 index 00000000..f261c3ba --- /dev/null +++ b/test/completion/cfrun.exp @@ -0,0 +1 @@ +assert_source_completions cfrun diff --git a/test/completion/chfn.exp b/test/completion/chfn.exp new file mode 100644 index 00000000..c67743c2 --- /dev/null +++ b/test/completion/chfn.exp @@ -0,0 +1 @@ +assert_source_completions chfn diff --git a/test/completion/complete.exp b/test/completion/complete.exp new file mode 100644 index 00000000..3872244f --- /dev/null +++ b/test/completion/complete.exp @@ -0,0 +1 @@ +assert_source_completions complete diff --git a/test/completion/cpan2dist.exp b/test/completion/cpan2dist.exp new file mode 100644 index 00000000..c9913b3b --- /dev/null +++ b/test/completion/cpan2dist.exp @@ -0,0 +1 @@ +assert_source_completions cpan2dist diff --git a/test/completion/ebtables.exp b/test/completion/ebtables.exp new file mode 100644 index 00000000..34399189 --- /dev/null +++ b/test/completion/ebtables.exp @@ -0,0 +1 @@ +assert_source_completions ebtables diff --git a/test/completion/freeciv-gtk2.exp b/test/completion/freeciv-gtk2.exp new file mode 100644 index 00000000..4f96469d --- /dev/null +++ b/test/completion/freeciv-gtk2.exp @@ -0,0 +1 @@ +assert_source_completions freeciv-gtk2 diff --git a/test/completion/freeciv-server.exp b/test/completion/freeciv-server.exp new file mode 100644 index 00000000..92b25ed0 --- /dev/null +++ b/test/completion/freeciv-server.exp @@ -0,0 +1 @@ +assert_source_completions freeciv-server diff --git a/test/completion/geoiplookup.exp b/test/completion/geoiplookup.exp new file mode 100644 index 00000000..b2f6bcec --- /dev/null +++ b/test/completion/geoiplookup.exp @@ -0,0 +1 @@ +assert_source_completions geoiplookup diff --git a/test/completion/getconf.exp b/test/completion/getconf.exp new file mode 100644 index 00000000..f1b010bd --- /dev/null +++ b/test/completion/getconf.exp @@ -0,0 +1 @@ +assert_source_completions getconf diff --git a/test/completion/gpg2.exp b/test/completion/gpg2.exp new file mode 100644 index 00000000..4c44ed41 --- /dev/null +++ b/test/completion/gpg2.exp @@ -0,0 +1 @@ +assert_source_completions gpg2 diff --git a/test/completion/groupadd.exp b/test/completion/groupadd.exp new file mode 100644 index 00000000..7cc8e386 --- /dev/null +++ b/test/completion/groupadd.exp @@ -0,0 +1 @@ +assert_source_completions groupadd diff --git a/test/completion/groupdel.exp b/test/completion/groupdel.exp new file mode 100644 index 00000000..337a8310 --- /dev/null +++ b/test/completion/groupdel.exp @@ -0,0 +1 @@ +assert_source_completions groupdel diff --git a/test/completion/groupmems.exp b/test/completion/groupmems.exp new file mode 100644 index 00000000..6a34f902 --- /dev/null +++ b/test/completion/groupmems.exp @@ -0,0 +1 @@ +assert_source_completions groupmems diff --git a/test/completion/groupmod.exp b/test/completion/groupmod.exp new file mode 100644 index 00000000..74d92e6e --- /dev/null +++ b/test/completion/groupmod.exp @@ -0,0 +1 @@ +assert_source_completions groupmod diff --git a/test/completion/hid2hci.exp b/test/completion/hid2hci.exp new file mode 100644 index 00000000..de78db2b --- /dev/null +++ b/test/completion/hid2hci.exp @@ -0,0 +1,3 @@ +assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/lib/udev"} +assert_source_completions hid2hci +assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH} diff --git a/test/completion/iptables.exp b/test/completion/iptables.exp new file mode 100644 index 00000000..3c3bbc39 --- /dev/null +++ b/test/completion/iptables.exp @@ -0,0 +1 @@ +assert_source_completions iptables diff --git a/test/completion/kdvi.exp b/test/completion/kdvi.exp index 78bd4a94..9f6aa664 100644 --- a/test/completion/kdvi.exp +++ b/test/completion/kdvi.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed kdvi - -source "$::srcdir/lib/completions/kdvi.exp" +assert_source_completions kdvi diff --git a/test/completion/kpdf.exp b/test/completion/kpdf.exp index 53417c32..d0a17749 100644 --- a/test/completion/kpdf.exp +++ b/test/completion/kpdf.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed kpdf - -source "$::srcdir/lib/completions/kpdf.exp" +assert_source_completions kpdf diff --git a/test/completion/ktutil.exp b/test/completion/ktutil.exp new file mode 100644 index 00000000..430316f3 --- /dev/null +++ b/test/completion/ktutil.exp @@ -0,0 +1 @@ +assert_source_completions ktutil diff --git a/test/completion/lintian-info.exp b/test/completion/lintian-info.exp new file mode 100644 index 00000000..9dcb3fce --- /dev/null +++ b/test/completion/lintian-info.exp @@ -0,0 +1 @@ +assert_source_completions lintian-info diff --git a/test/completion/lintian.exp b/test/completion/lintian.exp new file mode 100644 index 00000000..3662b0de --- /dev/null +++ b/test/completion/lintian.exp @@ -0,0 +1 @@ +assert_source_completions lintian diff --git a/test/completion/lspci.exp b/test/completion/lspci.exp new file mode 100644 index 00000000..7b287827 --- /dev/null +++ b/test/completion/lspci.exp @@ -0,0 +1 @@ +assert_source_completions lspci diff --git a/test/completion/lsscsi.exp b/test/completion/lsscsi.exp new file mode 100644 index 00000000..4b19b1fd --- /dev/null +++ b/test/completion/lsscsi.exp @@ -0,0 +1 @@ +assert_source_completions lsscsi diff --git a/test/completion/lsusb.exp b/test/completion/lsusb.exp new file mode 100644 index 00000000..0a75f462 --- /dev/null +++ b/test/completion/lsusb.exp @@ -0,0 +1 @@ +assert_source_completions lsusb diff --git a/test/completion/munin-node-configure.exp b/test/completion/munin-node-configure.exp new file mode 100644 index 00000000..34318e83 --- /dev/null +++ b/test/completion/munin-node-configure.exp @@ -0,0 +1 @@ +assert_source_completions munin-node-configure diff --git a/test/completion/munin-run.exp b/test/completion/munin-run.exp new file mode 100644 index 00000000..2a7d6c72 --- /dev/null +++ b/test/completion/munin-run.exp @@ -0,0 +1 @@ +assert_source_completions munin-run diff --git a/test/completion/munindoc.exp b/test/completion/munindoc.exp new file mode 100644 index 00000000..ea4d0fa2 --- /dev/null +++ b/test/completion/munindoc.exp @@ -0,0 +1 @@ +assert_source_completions munindoc diff --git a/test/completion/nmap.exp b/test/completion/nmap.exp new file mode 100644 index 00000000..441d1377 --- /dev/null +++ b/test/completion/nmap.exp @@ -0,0 +1 @@ +assert_source_completions nmap diff --git a/test/completion/nproc.exp b/test/completion/nproc.exp new file mode 100644 index 00000000..f2378bfa --- /dev/null +++ b/test/completion/nproc.exp @@ -0,0 +1 @@ +assert_source_completions nproc diff --git a/test/completion/oggdec.exp b/test/completion/oggdec.exp new file mode 100644 index 00000000..b18643d5 --- /dev/null +++ b/test/completion/oggdec.exp @@ -0,0 +1 @@ +assert_source_completions oggdec diff --git a/test/completion/perltidy.exp b/test/completion/perltidy.exp new file mode 100644 index 00000000..c4b577dd --- /dev/null +++ b/test/completion/perltidy.exp @@ -0,0 +1 @@ +assert_source_completions perltidy diff --git a/test/completion/pm-hibernate.exp b/test/completion/pm-hibernate.exp new file mode 100644 index 00000000..b0a6360c --- /dev/null +++ b/test/completion/pm-hibernate.exp @@ -0,0 +1 @@ +assert_source_completions pm-hibernate diff --git a/test/completion/pm-is-supported.exp b/test/completion/pm-is-supported.exp new file mode 100644 index 00000000..62d1f2ff --- /dev/null +++ b/test/completion/pm-is-supported.exp @@ -0,0 +1 @@ +assert_source_completions pm-is-supported diff --git a/test/completion/pm-powersave.exp b/test/completion/pm-powersave.exp new file mode 100644 index 00000000..deb061c6 --- /dev/null +++ b/test/completion/pm-powersave.exp @@ -0,0 +1 @@ +assert_source_completions pm-powersave diff --git a/test/completion/pv.exp b/test/completion/pv.exp new file mode 100644 index 00000000..2dffce6e --- /dev/null +++ b/test/completion/pv.exp @@ -0,0 +1 @@ +assert_source_completions pv diff --git a/test/completion/pycodestyle.exp b/test/completion/pycodestyle.exp new file mode 100644 index 00000000..50a3c496 --- /dev/null +++ b/test/completion/pycodestyle.exp @@ -0,0 +1 @@ +assert_source_completions pycodestyle diff --git a/test/completion/radvdump.exp b/test/completion/radvdump.exp new file mode 100644 index 00000000..e4efa171 --- /dev/null +++ b/test/completion/radvdump.exp @@ -0,0 +1 @@ +assert_source_completions radvdump diff --git a/test/completion/resolvconf.exp b/test/completion/resolvconf.exp new file mode 100644 index 00000000..d4651336 --- /dev/null +++ b/test/completion/resolvconf.exp @@ -0,0 +1 @@ +assert_source_completions resolvconf diff --git a/test/completion/rfkill.exp b/test/completion/rfkill.exp new file mode 100644 index 00000000..74201043 --- /dev/null +++ b/test/completion/rfkill.exp @@ -0,0 +1 @@ +assert_source_completions rfkill diff --git a/test/completion/rrdtool.exp b/test/completion/rrdtool.exp new file mode 100644 index 00000000..72016859 --- /dev/null +++ b/test/completion/rrdtool.exp @@ -0,0 +1 @@ +assert_source_completions rrdtool diff --git a/test/completion/runuser.exp b/test/completion/runuser.exp new file mode 100644 index 00000000..ed0abdcf --- /dev/null +++ b/test/completion/runuser.exp @@ -0,0 +1 @@ +assert_source_completions runuser diff --git a/test/completion/sshfs.exp b/test/completion/sshfs.exp new file mode 100644 index 00000000..e5deaddd --- /dev/null +++ b/test/completion/sshfs.exp @@ -0,0 +1 @@ +assert_source_completions sshfs diff --git a/test/completion/tox.exp b/test/completion/tox.exp new file mode 100644 index 00000000..f383b569 --- /dev/null +++ b/test/completion/tox.exp @@ -0,0 +1 @@ +assert_source_completions tox diff --git a/test/completion/uscan.exp b/test/completion/uscan.exp new file mode 100644 index 00000000..e524e39e --- /dev/null +++ b/test/completion/uscan.exp @@ -0,0 +1 @@ +assert_source_completions uscan diff --git a/test/completion/useradd.exp b/test/completion/useradd.exp new file mode 100644 index 00000000..f91bddae --- /dev/null +++ b/test/completion/useradd.exp @@ -0,0 +1 @@ +assert_source_completions useradd diff --git a/test/completion/userdel.exp b/test/completion/userdel.exp new file mode 100644 index 00000000..e4ba42ce --- /dev/null +++ b/test/completion/userdel.exp @@ -0,0 +1 @@ +assert_source_completions userdel diff --git a/test/completion/usermod.exp b/test/completion/usermod.exp new file mode 100644 index 00000000..e3861f52 --- /dev/null +++ b/test/completion/usermod.exp @@ -0,0 +1 @@ +assert_source_completions usermod diff --git a/test/completion/vi.exp b/test/completion/vi.exp index 675ea06a..b0191404 100644 --- a/test/completion/vi.exp +++ b/test/completion/vi.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed vi - -source "$::srcdir/lib/completions/vi.exp" +assert_source_completions vi diff --git a/test/completion/wodim.exp b/test/completion/wodim.exp new file mode 100644 index 00000000..51b407ba --- /dev/null +++ b/test/completion/wodim.exp @@ -0,0 +1 @@ +assert_source_completions wodim diff --git a/test/completion/write.exp b/test/completion/write.exp new file mode 100644 index 00000000..d454b62f --- /dev/null +++ b/test/completion/write.exp @@ -0,0 +1 @@ +assert_source_completions write diff --git a/test/completion/xdg-mime.exp b/test/completion/xdg-mime.exp new file mode 100644 index 00000000..01f24d41 --- /dev/null +++ b/test/completion/xdg-mime.exp @@ -0,0 +1 @@ +assert_source_completions xdg-mime diff --git a/test/completion/xdg-settings.exp b/test/completion/xdg-settings.exp new file mode 100644 index 00000000..8fb8a53e --- /dev/null +++ b/test/completion/xdg-settings.exp @@ -0,0 +1 @@ +assert_source_completions xdg-settings diff --git a/test/completion/xm.exp b/test/completion/xm.exp new file mode 100644 index 00000000..fa0cddf6 --- /dev/null +++ b/test/completion/xm.exp @@ -0,0 +1 @@ +assert_source_completions xm diff --git a/test/config/bashrc b/test/config/bashrc index d16c9033..69098e14 100644 --- a/test/config/bashrc +++ b/test/config/bashrc @@ -1,5 +1,8 @@ # bashrc file for DejaGnu testsuite +# Note that we do some initialization that would be too late to do here in +# library.exp's start_bash(). + # Use emacs key bindings set -o emacs # Use bash strict mode @@ -7,17 +10,8 @@ set -o posix # Unset `command_not_found_handle' as defined on Debian/Ubuntu, because this # troubles and slows down testing unset -f command_not_found_handle - # Set fixed prompt `/@' TESTDIR=$(pwd) -export PS1='/@' export PS2='> ' - # Configure readline -export INPUTRC=$SRCDIR/config/inputrc - # When not running via cron, avoid escape junk at beginning of line from - # readline, see e.g. http://bugs.gentoo.org/246091 -[ "$CRON" ] || export TERM=dumb - # Ensure enough columns so expect doesn't have to care about line breaks -stty columns 150 # Also test completions of system administrator commands, which are # installed via the same PATH expansion in `bash_completion.have()' export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin diff --git a/test/docker/Dockerfile-centos6 b/test/docker/Dockerfile-centos6 index 8686fde4..6f886ffa 100644 --- a/test/docker/Dockerfile-centos6 +++ b/test/docker/Dockerfile-centos6 @@ -1,18 +1,11 @@ -FROM centos:6 +FROM vskytta/bash-completion:centos6 -# TODO: more coverage -# /usr/bin/which: https://bugzilla.redhat.com/show_bug.cgi?id=1443357 -RUN sed -i -e /tsflags=nodocs/d /etc/yum.conf \ - && \ - yum -y install \ - https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm \ - && \ - yum -y install \ - autoconf \ - automake \ - dejagnu \ - tcllib \ - /usr/bin/xvfb-run /usr/bin/which +# When adding new completions, install packages desired for their testing here +# in case they're not in the base image, and remove later when the base image +# has caught up. +#RUN yum -y install \ +# some-package -WORKDIR /usr/src/bash-completion +WORKDIR /work COPY . . +CMD ["bash"] diff --git a/test/docker/Dockerfile-fedoradev b/test/docker/Dockerfile-fedoradev index 423f836b..8c4f86d7 100644 --- a/test/docker/Dockerfile-fedoradev +++ b/test/docker/Dockerfile-fedoradev @@ -1,41 +1,11 @@ -FROM fedora:rawhide +FROM vskytta/bash-completion:fedoradev -# TODO: more coverage -# /usr/bin/which: https://bugzilla.redhat.com/show_bug.cgi?id=1443357 -RUN dnf --refresh -y install \ - autoconf \ - automake \ - dejagnu \ - tcllib \ - /usr/bin/xvfb-run /usr/bin/which \ - && \ - dnf -y install \ - /usr/bin/checksec \ - /usr/bin/compare \ - /usr/bin/dcop \ - /usr/sbin/ether-wake \ - /usr/bin/g77 \ - /usr/sbin/hping2 \ - /usr/bin/koji \ - /usr/bin/lua \ - /usr/bin/luac \ - /usr/sbin/mii-diag \ - /usr/bin/mock \ - /usr/bin/msynctool \ - /usr/bin/mutt \ - /usr/bin/ncftp \ - /usr/bin/phing \ - /usr/bin/plague-client \ - /usr/bin/pngfix \ - /usr/bin/pyvenv \ - /usr/bin/snownews \ - /usr/bin/stream \ - /usr/bin/svk \ - /usr/sbin/tipc \ - /usr/bin/wine \ - /usr/bin/wol \ - /usr/bin/xmms \ - /usr/bin/zopflipng +# When adding new completions, install packages desired for their testing here +# in case they're not in the base image, and remove later when the base image +# has caught up. +#RUN dnf --nogpgcheck --refresh -y install \ +# some-package -WORKDIR /usr/src/bash-completion +WORKDIR /work COPY . . +CMD ["bash"] diff --git a/test/docker/Dockerfile-ubuntu14 b/test/docker/Dockerfile-ubuntu14 index 8db91503..a1086add 100644 --- a/test/docker/Dockerfile-ubuntu14 +++ b/test/docker/Dockerfile-ubuntu14 @@ -1,197 +1,13 @@ -FROM ubuntu:14.04 +FROM vskytta/bash-completion:ubuntu14 -# TODO: more coverage -# TODO: wine needs dpkg --add-architecture i386 before apt-get update, but -# that results in apt-get update errors (some index files not found) -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - autoconf \ - automake \ - dejagnu \ - tcllib \ - xvfb \ - software-properties-common && \ - apt-add-repository multiverse && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - a2ps \ - abook \ - acpi \ - alpine \ - android-tools-adb \ - ant \ - apache2 \ - apache2-utils \ - apt-build \ - asciidoc \ - aspell \ - autoconf \ - automake \ - bc \ - bind9-host \ - bison \ - bluez \ - bridge-utils \ - bsdgames \ - ccache \ - cfengine2 \ - chrony \ - chrpath \ - cksfv \ - clisp \ - cowsay \ - cppcheck \ - cryptsetup-bin \ - cups-bsd \ - cups-client \ - curl \ - cvs \ - cvsps \ - deja-dup \ - desktop-file-utils \ - dict \ - dnsutils \ - dselect \ - dsniff \ - enscript \ - eog \ - evince \ - expat \ - fbi \ - feh \ - file-roller \ - finger \ - freerdp-x11 \ - fuse \ - gcj-jdk \ - gcl \ - gdb \ - genisoimage \ - gkrellm \ - gnat-4.6 \ - gnokii-cli \ - gnome-mplayer \ - gperf \ - gphoto2 \ - graphicsmagick \ - graphicsmagick-imagemagick-compat \ - graphviz \ - growisofs \ - grub \ - hddtemp \ - hping3 \ - htop \ - icedtea-netx \ - idn \ - iftop \ - info \ - iperf \ - ipmitool \ - iputils-arping \ - iputils-ping \ - iputils-tracepath \ - ipv6calc \ - isc-dhcp-client \ - jpegoptim \ - k3b \ - kcov \ - kplayer \ - ldap-utils \ - ldapvi \ - lftp \ - liblz4-tool \ - libuser \ - lilo \ - links \ - lrzip \ - lsof \ - lvm2 \ - lzip \ - lzop \ - mailman \ - man \ - mariadb-client-5.5 \ - mc \ - mcrypt \ - mdadm \ - medusa \ - mencoder \ - minicom \ - monodevelop \ - mplayer-gui \ - mr \ - mtx \ - mussh \ - net-tools \ - nethogs \ - network-manager \ - nfs-common \ - ngrep \ - nis \ - nodejs-legacy \ - npm \ - ntpdate \ - open-iscsi-utils \ - openjdk-7-jdk \ - openswan \ - optipng \ - p7zip-full \ - patchutils \ - perl-doc \ - pinfo \ - poppler-utils \ - postgresql-client-9.3 \ - postfix \ - prelink \ - protobuf-compiler \ - puppet-common \ - pwgen \ - pyflakes \ - pylint \ - python-flake8 \ - python-pytest \ - python3 \ - quota \ - rcs \ - rdesktop \ - reportbug \ - reptyr \ - ri \ - rpm \ - rsync \ - samba-common-bin \ - sbcl \ - screen \ - sharutils \ - sitecopy \ - smartmontools \ - smbclient \ - sqlite3 \ - strace \ - subversion \ - sysbench \ - tcpdump \ - texinfo \ - tshark \ - unace \ - unrar \ - units \ - unixodbc \ - valgrind \ - vpnc \ - wget \ - wireless-tools \ - wodim \ - wvdial \ - x11-xserver-utils \ - xserver-xorg-input-synaptics \ - xsltproc \ - xvnc4viewer \ - xzdec \ - yum \ - yum-utils \ - zopfli && \ - npm install -g jshint +# When adding new completions, install packages desired for their testing here +# in case they're not in the base image, and remove later when the base image +# has caught up. +#RUN apt-get update \ +# && \ +# DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +# some-package -WORKDIR /usr/src/bash-completion +WORKDIR /work COPY . . +CMD ["bash"] diff --git a/test/fixtures/_known_hosts_real/localhost_config b/test/fixtures/_known_hosts_real/localhost_config new file mode 100644 index 00000000..1e751338 --- /dev/null +++ b/test/fixtures/_known_hosts_real/localhost_config @@ -0,0 +1 @@ +UserKnownHostsFile fixtures/_known_hosts_real/localhost_hosts diff --git a/test/fixtures/_known_hosts_real/localhost_hosts b/test/fixtures/_known_hosts_real/localhost_hosts new file mode 100644 index 00000000..ff752c26 --- /dev/null +++ b/test/fixtures/_known_hosts_real/localhost_hosts @@ -0,0 +1,3 @@ +localhost +127.0.0.1 +::1 diff --git a/test/fixtures/man/man1/bar.1.bz2 b/test/fixtures/dpkg/bash-completion-test-subject.deb index e69de29b..e69de29b 100644 --- a/test/fixtures/man/man1/bar.1.bz2 +++ b/test/fixtures/dpkg/bash-completion-test-subject.deb diff --git a/test/fixtures/info/bash-completion.info b/test/fixtures/info/bash-completion.info new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/info/bash-completion.info diff --git a/test/fixtures/java/bashcomp.war b/test/fixtures/java/bashcomp.war new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/java/bashcomp.war diff --git a/test/fixtures/man/man1/bash-completion-testcase.1.bz2 b/test/fixtures/man/man1/bash-completion-testcase.1.bz2 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/man/man1/bash-completion-testcase.1.bz2 diff --git a/test/fixtures/mplayer/.mplayer/config b/test/fixtures/mplayer/.mplayer/config new file mode 100644 index 00000000..8af74eed --- /dev/null +++ b/test/fixtures/mplayer/.mplayer/config @@ -0,0 +1,2 @@ +# https://github.com/scop/bash-completion/issues/182 +msglevel=all=3 diff --git a/test/fixtures/mplayer/.mplayer/mencoder.conf b/test/fixtures/mplayer/.mplayer/mencoder.conf new file mode 100644 index 00000000..9f5aa0f2 --- /dev/null +++ b/test/fixtures/mplayer/.mplayer/mencoder.conf @@ -0,0 +1 @@ +# mencoder test config file diff --git a/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.yaml b/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.yaml new file mode 100644 index 00000000..bc064a82 --- /dev/null +++ b/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.yaml @@ -0,0 +1,15 @@ +--- !ruby/object:RI::ClassDescription +attributes: [] + +class_methods: [] + +comment: +constants: [] + +full_name: BashCompletion +includes: [] + +instance_methods: [] + +name: BashCompletion +superclass: diff --git a/test/fixtures/ri/bashcompletion.rb b/test/fixtures/ri/bashcompletion.rb new file mode 100644 index 00000000..0e075d26 --- /dev/null +++ b/test/fixtures/ri/bashcompletion.rb @@ -0,0 +1,2 @@ +module BashCompletion +end diff --git a/test/fixtures/ri/created.rid b/test/fixtures/ri/created.rid index ced9a4e0..1392d206 100644 --- a/test/fixtures/ri/created.rid +++ b/test/fixtures/ri/created.rid @@ -1 +1 @@ -Sat, 29 Apr 2017 07:21:09 +0000 +Mon, 09 Oct 2017 21:45:15 +0000 diff --git a/test/lib/completions/alias.exp b/test/lib/completions/alias.exp index 9dba4e62..2010df2d 100644 --- a/test/lib/completions/alias.exp +++ b/test/lib/completions/alias.exp @@ -19,8 +19,6 @@ set test "Tab should complete alias" # Try completion set cmd "alias " assert_complete {bar foo} $cmd $test - - sync_after_int @@ -35,9 +33,12 @@ expect { -re /@ { unresolved "$test" } default { unresolved "$test" } } +sync_after_int -sync_after_int +# FIXME: test case for "alias foo=<TAB>" -> "alias foo='bar'", this doesn't work +#assert_complete {foo='bar'} "alias foo=" "" -nospace +#sync_after_int teardown diff --git a/test/lib/completions/apt-get.exp b/test/lib/completions/apt-get.exp index 270d6fe8..8a5d3629 100644 --- a/test/lib/completions/apt-get.exp +++ b/test/lib/completions/apt-get.exp @@ -4,7 +4,7 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified {/OLDPWD=/d} } @@ -22,4 +22,8 @@ expect { sync_after_int +assert_complete_dir "./bash-completion-test-subject.deb" "apt-get install ./" "$::srcdir/fixtures/dpkg" +sync_after_int + + teardown diff --git a/test/lib/completions/bzip2.exp b/test/lib/completions/bzip2.exp index 2813dd0e..d806851a 100644 --- a/test/lib/completions/bzip2.exp +++ b/test/lib/completions/bzip2.exp @@ -17,4 +17,8 @@ assert_complete_any "bzip2 " sync_after_int +assert_complete_homedir "bzip" +sync_after_int + + teardown diff --git a/test/lib/completions/ccze.exp b/test/lib/completions/ccze.exp new file mode 100644 index 00000000..94b51b39 --- /dev/null +++ b/test/lib/completions/ccze.exp @@ -0,0 +1,27 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ccze " +sync_after_int + +assert_no_complete "ccze -? " +sync_after_int + +assert_complete_any "ccze -o " +sync_after_int + +assert_complete_any "ccze --plugin=" +sync_after_int + + +teardown diff --git a/test/lib/completions/cfrun.exp b/test/lib/completions/cfrun.exp new file mode 100644 index 00000000..2cf6a4cb --- /dev/null +++ b/test/lib/completions/cfrun.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "cfrun -" +sync_after_int + + +teardown diff --git a/test/lib/completions/chfn.exp b/test/lib/completions/chfn.exp new file mode 100644 index 00000000..ea977c76 --- /dev/null +++ b/test/lib/completions/chfn.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "chfn " +sync_after_int + + +teardown diff --git a/test/lib/completions/complete.exp b/test/lib/completions/complete.exp new file mode 100644 index 00000000..9d898c51 --- /dev/null +++ b/test/lib/completions/complete.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "complete -" +sync_after_int + + +teardown diff --git a/test/lib/completions/cpan2dist.exp b/test/lib/completions/cpan2dist.exp new file mode 100644 index 00000000..1c7836ad --- /dev/null +++ b/test/lib/completions/cpan2dist.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "cpan2dist -" +sync_after_int + + +teardown diff --git a/test/lib/completions/dpkg.exp b/test/lib/completions/dpkg.exp index 0ea6ded3..b69f79fd 100644 --- a/test/lib/completions/dpkg.exp +++ b/test/lib/completions/dpkg.exp @@ -22,13 +22,7 @@ if {[assert_exec {dpkg --get-selections | command grep \[\[:space:\]\]install$ | sync_after_int -set test "dpkg -i ~part should complete to ~full/ if home dir exists" -# https://bugs.debian.org/864691 -# Create list of users, having existing home dir -assert_bash_exec {for u in $(compgen -u); do \ - eval test -d ~$u && echo $u; unset u; done} {} /@ users -find_unique_completion_pair $users part full -assert_complete "~$full/" "dpkg -i ~$part" $test -nospace +assert_complete_homedir "dpkg -i" sync_after_int diff --git a/test/lib/completions/ebtables.exp b/test/lib/completions/ebtables.exp new file mode 100644 index 00000000..e8feea55 --- /dev/null +++ b/test/lib/completions/ebtables.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ebtables -" +sync_after_int + + +teardown diff --git a/test/lib/completions/flake8.exp b/test/lib/completions/flake8.exp index 469f96ed..146ff04d 100644 --- a/test/lib/completions/flake8.exp +++ b/test/lib/completions/flake8.exp @@ -14,5 +14,11 @@ setup assert_complete_any "flake8 " sync_after_int +assert_complete_any "flake8 -" +sync_after_int + +assert_no_complete "flake8 --doesnt-exist=" +sync_after_int + teardown diff --git a/test/lib/completions/freeciv-gtk2.exp b/test/lib/completions/freeciv-gtk2.exp new file mode 100644 index 00000000..1c0ec474 --- /dev/null +++ b/test/lib/completions/freeciv-gtk2.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "freeciv-gtk2 -" +sync_after_int + + +teardown diff --git a/test/lib/completions/freeciv-server.exp b/test/lib/completions/freeciv-server.exp new file mode 100644 index 00000000..a9431848 --- /dev/null +++ b/test/lib/completions/freeciv-server.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "freeciv-server -" +sync_after_int + + +teardown diff --git a/test/lib/completions/geoiplookup.exp b/test/lib/completions/geoiplookup.exp new file mode 100644 index 00000000..89166401 --- /dev/null +++ b/test/lib/completions/geoiplookup.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "geoiplookup -" +sync_after_int + + +teardown diff --git a/test/lib/completions/getconf.exp b/test/lib/completions/getconf.exp new file mode 100644 index 00000000..a599fed1 --- /dev/null +++ b/test/lib/completions/getconf.exp @@ -0,0 +1,30 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "getconf P" +sync_after_int + +assert_complete_any "getconf -" +sync_after_int + +assert_complete_any "getconf -a " +sync_after_int + +assert_complete_any "getconf -v " +sync_after_int + +assert_complete_any "getconf PATH_MAX " +sync_after_int + + +teardown diff --git a/test/lib/completions/gpg2.exp b/test/lib/completions/gpg2.exp new file mode 100644 index 00000000..3bc0e7a7 --- /dev/null +++ b/test/lib/completions/gpg2.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "gpg2 --h" +sync_after_int + + +teardown diff --git a/test/lib/completions/groupadd.exp b/test/lib/completions/groupadd.exp new file mode 100644 index 00000000..c9a4f067 --- /dev/null +++ b/test/lib/completions/groupadd.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "groupadd " +sync_after_int + +assert_complete_any "groupadd -" +sync_after_int + + +teardown diff --git a/test/lib/completions/groupdel.exp b/test/lib/completions/groupdel.exp new file mode 100644 index 00000000..07c77638 --- /dev/null +++ b/test/lib/completions/groupdel.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "groupdel " +sync_after_int + + +teardown diff --git a/test/lib/completions/groupmems.exp b/test/lib/completions/groupmems.exp new file mode 100644 index 00000000..41c4b43e --- /dev/null +++ b/test/lib/completions/groupmems.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "groupmems -" +sync_after_int + + +teardown diff --git a/test/lib/completions/groupmod.exp b/test/lib/completions/groupmod.exp new file mode 100644 index 00000000..451456b3 --- /dev/null +++ b/test/lib/completions/groupmod.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "groupmod " +sync_after_int + +assert_complete_any "groupmod -" +sync_after_int + + +teardown diff --git a/test/lib/completions/gzip.exp b/test/lib/completions/gzip.exp index 32acf428..95f774c6 100644 --- a/test/lib/completions/gzip.exp +++ b/test/lib/completions/gzip.exp @@ -25,4 +25,8 @@ expect { sync_after_int +assert_complete_homedir "gzip" +sync_after_int + + teardown diff --git a/test/lib/completions/hid2hci.exp b/test/lib/completions/hid2hci.exp new file mode 100644 index 00000000..c090c2c9 --- /dev/null +++ b/test/lib/completions/hid2hci.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "hid2hci -" +sync_after_int + + +teardown diff --git a/test/lib/completions/info.exp b/test/lib/completions/info.exp index e7c79e6e..443a1305 100644 --- a/test/lib/completions/info.exp +++ b/test/lib/completions/info.exp @@ -1,19 +1,22 @@ proc setup {} { + assert_bash_exec {OLDINFOPATH=$INFOPATH; INFOPATH=$INFOPATH:$TESTDIR/fixtures/info:} save_env } proc teardown {} { assert_env_unmodified + assert_bash_exec {INFOPATH="$OLDINFOPATH"; unset -v OLDINFOPATH} } setup -assert_complete_any "info " - +assert_complete_any "info bash" +sync_after_int +assert_complete_any "info -" sync_after_int diff --git a/test/lib/completions/iptables.exp b/test/lib/completions/iptables.exp new file mode 100644 index 00000000..8ab42f56 --- /dev/null +++ b/test/lib/completions/iptables.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "iptables -" +sync_after_int + + +teardown diff --git a/test/lib/completions/java.exp b/test/lib/completions/java.exp index 864aabd6..62f6fd9d 100644 --- a/test/lib/completions/java.exp +++ b/test/lib/completions/java.exp @@ -44,7 +44,7 @@ assert_no_complete "java -cp \"\" " sync_after_int -assert_complete "a/ bashcomp.jar" "java -jar $::srcdir/fixtures/java/" +assert_complete "a/ bashcomp.jar bashcomp.war" "java -jar $::srcdir/fixtures/java/" sync_after_int diff --git a/test/lib/completions/kcov.exp b/test/lib/completions/kcov.exp index c39f53e7..c6c4a06d 100644 --- a/test/lib/completions/kcov.exp +++ b/test/lib/completions/kcov.exp @@ -12,15 +12,13 @@ setup assert_complete_any "kcov " - - sync_after_int - set test "--exclude-patter<TAB> should complete \"--exclude-pattern=\"" assert_complete "--exclude-pattern=" "kcov --exclude-patter" $test -nospace +sync_after_int - +assert_complete_any "kcov -l 42," sync_after_int diff --git a/test/lib/completions/killall.exp b/test/lib/completions/killall.exp index feec9337..a55ac591 100644 --- a/test/lib/completions/killall.exp +++ b/test/lib/completions/killall.exp @@ -11,15 +11,12 @@ proc teardown {} { setup -assert_complete_any "killall " - - +# "p": Assume that our process name completion runs ps +assert_complete_any "killall p" sync_after_int assert_complete [get_signals] "killall --signal " - - sync_after_int diff --git a/test/lib/completions/ktutil.exp b/test/lib/completions/ktutil.exp new file mode 100644 index 00000000..709a0850 --- /dev/null +++ b/test/lib/completions/ktutil.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ktutil " +sync_after_int + +assert_complete_any "ktutil -" +sync_after_int + + +teardown diff --git a/test/lib/completions/lintian-info.exp b/test/lib/completions/lintian-info.exp new file mode 100644 index 00000000..5bde97fd --- /dev/null +++ b/test/lib/completions/lintian-info.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lintian-info " +sync_after_int + +assert_complete_any "lintian-info --" +sync_after_int + + +teardown diff --git a/test/lib/completions/lintian.exp b/test/lib/completions/lintian.exp new file mode 100644 index 00000000..5b1e695c --- /dev/null +++ b/test/lib/completions/lintian.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lintian --" +sync_after_int + + +teardown diff --git a/test/lib/completions/lrzip.exp b/test/lib/completions/lrzip.exp index 97bc1235..2c4218ec 100644 --- a/test/lib/completions/lrzip.exp +++ b/test/lib/completions/lrzip.exp @@ -17,4 +17,8 @@ assert_complete_any "lrzip " sync_after_int +assert_complete_homedir "lrzip" +sync_after_int + + teardown diff --git a/test/lib/completions/ls.exp b/test/lib/completions/ls.exp index e176e13f..24fc46f8 100644 --- a/test/lib/completions/ls.exp +++ b/test/lib/completions/ls.exp @@ -17,12 +17,7 @@ if {[assert_exec {ls --help} "" "" "unsupported"]} { sync_after_int -set test "~part should complete to ~full/ if home dir exists" -# Create list of users, having existing home dir -assert_bash_exec {for u in $(compgen -u); do \ - eval test -d ~$u && echo $u; unset u; done} {} /@ users -find_unique_completion_pair $users part full -assert_complete "~$full/" "ls ~$part" $test -nospace +assert_complete_homedir "ls" sync_after_int @@ -30,8 +25,11 @@ set test "~part should complete to ~full<space> if home dir does not exist" # Create list of users, having non-existing home dir assert_bash_exec {for u in $(compgen -u); do \ eval test -d ~$u || echo $u; unset u; done} {} /@ users -find_unique_completion_pair $users part full -assert_complete "~$full " "ls ~$part" $test -nospace +if {![find_unique_completion_pair $users part full]} { + untested "Not running, no suitable test user found: $test" +} else { + assert_complete "~$full " "ls ~$part" $test -nospace +} sync_after_int diff --git a/test/lib/completions/lspci.exp b/test/lib/completions/lspci.exp new file mode 100644 index 00000000..ea9e859f --- /dev/null +++ b/test/lib/completions/lspci.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lspci -" +sync_after_int + +assert_complete_any "lspci -A " +sync_after_int + + +teardown diff --git a/test/lib/completions/lsscsi.exp b/test/lib/completions/lsscsi.exp new file mode 100644 index 00000000..66603142 --- /dev/null +++ b/test/lib/completions/lsscsi.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "lsscsi " +sync_after_int + +assert_complete_any "lsscsi -" +sync_after_int + + +teardown diff --git a/test/lib/completions/lsusb.exp b/test/lib/completions/lsusb.exp new file mode 100644 index 00000000..dddb6352 --- /dev/null +++ b/test/lib/completions/lsusb.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lsusb -" +sync_after_int + + +teardown diff --git a/test/lib/completions/lz4.exp b/test/lib/completions/lz4.exp index df392939..dc41f919 100644 --- a/test/lib/completions/lz4.exp +++ b/test/lib/completions/lz4.exp @@ -14,5 +14,8 @@ setup assert_complete_any "lz4 " sync_after_int +assert_complete_homedir "lz4" +sync_after_int + teardown diff --git a/test/lib/completions/lzma.exp b/test/lib/completions/lzma.exp index ba57d10b..16b45d0b 100644 --- a/test/lib/completions/lzma.exp +++ b/test/lib/completions/lzma.exp @@ -23,4 +23,8 @@ assert_complete "a/ bashcomp.lzma bashcomp.tlz" "lzma -d $::srcdir/fixtures/xz/" sync_after_int +assert_complete_homedir "lzma" +sync_after_int + + teardown diff --git a/test/lib/completions/lzop.exp b/test/lib/completions/lzop.exp index a7d3da25..3084fd3e 100644 --- a/test/lib/completions/lzop.exp +++ b/test/lib/completions/lzop.exp @@ -17,4 +17,8 @@ assert_complete_any "lzop " sync_after_int +assert_complete_homedir "lzop" +sync_after_int + + teardown diff --git a/test/lib/completions/man.exp b/test/lib/completions/man.exp index 1a031ff1..d601c434 100644 --- a/test/lib/completions/man.exp +++ b/test/lib/completions/man.exp @@ -9,7 +9,10 @@ proc setup {} { proc teardown {} { - assert_env_unmodified {/OLDPWD/d} + assert_env_unmodified { + /OLDPWD/d + /OLDMANPATH/d + } if {! [is_cygwin]} { assert_bash_exec {(cd $TESTDIR/tmp && rm -r man || true)} @@ -20,26 +23,54 @@ proc teardown {} { setup -assert_complete "bar" "man b" - +# Something we assume a system installed man page present for +set assumed_present "man" +assert_complete "bash-completion-testcase" "man bash-completion-testcas" sync_after_int - assert_complete_dir oo.1 "man man1/f" $::srcdir/fixtures/man - - sync_after_int - if {! [is_cygwin]} { assert_complete "Bash::Completion" "man Bash::C" sync_after_int } - assert_complete_dir "man/quux.8" "man man/" $::srcdir/fixtures/man sync_after_int +set desc "man $assumed_present with MANPATH having no leading/trailing colon" +assert_no_complete "man $assumed_present" "$desc should not complete" +sync_after_int + +# Trailing colon in MANPATH: append system default search path +assert_bash_exec "OLDMANPATH=\$MANPATH; MANPATH=\$MANPATH:" +set desc "with trailing colon in MANPATH" + +set cmd "man $assumed_present" +assert_complete_any "$cmd" "$cmd $desc should complete" +sync_after_int + +set cmd "man bash-completion-testcas" +assert_complete "bash-completion-testcase" "$cmd" "$cmd $desc should complete" +sync_after_int + +assert_bash_exec "MANPATH=\$OLDMANPATH" + +# Leading colon in MANPATH: prepend system default search path +assert_bash_exec "OLDMANPATH=\$MANPATH; MANPATH=:\$MANPATH" +set desc "with leading colon in MANPATH" + +set cmd "man $assumed_present" +assert_complete_any "$cmd" "$cmd $desc should complete" +sync_after_int + +set cmd "man bash-completion-testcas" +assert_complete "bash-completion-testcase" "$cmd" "$cmd $desc should complete" +sync_after_int + +assert_bash_exec "MANPATH=\$OLDMANPATH" + teardown diff --git a/test/lib/completions/mencoder.exp b/test/lib/completions/mencoder.exp index db29f66a..cb0ba7c5 100644 --- a/test/lib/completions/mencoder.exp +++ b/test/lib/completions/mencoder.exp @@ -1,10 +1,14 @@ proc setup {} { save_env + assert_bash_exec {OLDHOME=$HOME ; HOME=$SRCDIR/fixtures/mplayer} } proc teardown {} { - assert_env_unmodified + assert_bash_exec {HOME=$OLDHOME} + assert_env_unmodified { + /OLDHOME=/d + } } @@ -12,8 +16,9 @@ setup assert_complete_any "mencoder " +sync_after_int - +assert_complete_any "mencoder -v" sync_after_int diff --git a/test/lib/completions/mkdir.exp b/test/lib/completions/mkdir.exp index 44e87cee..049212f0 100644 --- a/test/lib/completions/mkdir.exp +++ b/test/lib/completions/mkdir.exp @@ -17,14 +17,14 @@ assert_complete_any "mkdir " sync_after_int -assert_complete {"bar bar.d/" foo.d/} "mkdir $::srcdir/fixtures/shared/default/" +assert_complete {bar "bar bar.d/" foo foo.d/} "mkdir $::srcdir/fixtures/shared/default/" sync_after_int -# No subdirs in foo.d and should not complete files in it (_longopt()). -assert_no_complete "mkdir $::srcdir/fixtures/shared/default/foo.d/" +set test "mkdir should complete files with nospace" +assert_complete {foo} "mkdir $::srcdir/fixtures/shared/default/foo.d/" $test -nospace sync_after_int diff --git a/test/lib/completions/mplayer.exp b/test/lib/completions/mplayer.exp index 9230a86d..8c9de756 100644 --- a/test/lib/completions/mplayer.exp +++ b/test/lib/completions/mplayer.exp @@ -1,10 +1,14 @@ proc setup {} { save_env + assert_bash_exec {OLDHOME=$HOME ; HOME=$SRCDIR/fixtures/mplayer} } proc teardown {} { - assert_env_unmodified + assert_bash_exec {HOME=$OLDHOME} + assert_env_unmodified { + /OLDHOME=/d + } } @@ -12,8 +16,9 @@ setup assert_complete_any "mplayer " +sync_after_int - +assert_complete_any "mplayer -h" sync_after_int diff --git a/test/lib/completions/munin-node-configure.exp b/test/lib/completions/munin-node-configure.exp new file mode 100644 index 00000000..2e17f3eb --- /dev/null +++ b/test/lib/completions/munin-node-configure.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "munin-node-configure --libdir " +sync_after_int + + +teardown diff --git a/test/lib/completions/munin-run.exp b/test/lib/completions/munin-run.exp new file mode 100644 index 00000000..25a639bc --- /dev/null +++ b/test/lib/completions/munin-run.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "munin-run -" +sync_after_int + + +teardown diff --git a/test/lib/completions/munindoc.exp b/test/lib/completions/munindoc.exp new file mode 100644 index 00000000..62a4307c --- /dev/null +++ b/test/lib/completions/munindoc.exp @@ -0,0 +1,19 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +# Assume at least munin* available +assert_complete_any "munindoc m" +sync_after_int + + +teardown diff --git a/test/lib/completions/nmap.exp b/test/lib/completions/nmap.exp new file mode 100644 index 00000000..02aab991 --- /dev/null +++ b/test/lib/completions/nmap.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "nmap --v" +sync_after_int + + +teardown diff --git a/test/lib/completions/nproc.exp b/test/lib/completions/nproc.exp new file mode 100644 index 00000000..d6df0472 --- /dev/null +++ b/test/lib/completions/nproc.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "nproc " +sync_after_int + +assert_complete_any "nproc -" +sync_after_int + + +teardown diff --git a/test/lib/completions/oggdec.exp b/test/lib/completions/oggdec.exp new file mode 100644 index 00000000..18b0f949 --- /dev/null +++ b/test/lib/completions/oggdec.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "oggdec " +sync_after_int + +assert_complete_any "oggdec --" +sync_after_int + + +teardown diff --git a/test/lib/completions/perltidy.exp b/test/lib/completions/perltidy.exp new file mode 100644 index 00000000..09fa2b14 --- /dev/null +++ b/test/lib/completions/perltidy.exp @@ -0,0 +1,27 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "perltidy " +sync_after_int + +assert_complete_any "perltidy -h" +sync_after_int + +assert_complete_any "perltidy -ole=" +sync_after_int + +assert_no_complete "perltidy -doesntexist=" +sync_after_int + + +teardown diff --git a/test/lib/completions/pgrep.exp b/test/lib/completions/pgrep.exp index c27c4f21..c6276f71 100644 --- a/test/lib/completions/pgrep.exp +++ b/test/lib/completions/pgrep.exp @@ -11,9 +11,8 @@ proc teardown {} { setup -assert_complete_any "pgrep " - - +# "p": Assume that our process name completion runs ps +assert_complete_any "pgrep p" sync_after_int diff --git a/test/lib/completions/pidof.exp b/test/lib/completions/pidof.exp index 8fdab978..d8ab9e8c 100644 --- a/test/lib/completions/pidof.exp +++ b/test/lib/completions/pidof.exp @@ -11,9 +11,8 @@ proc teardown {} { setup -assert_complete_any "pidof " - - +# "p": Assume that our process name completion runs ps +assert_complete_any "pidof p" sync_after_int diff --git a/test/lib/completions/pinfo.exp b/test/lib/completions/pinfo.exp index 3af44044..de241ff5 100644 --- a/test/lib/completions/pinfo.exp +++ b/test/lib/completions/pinfo.exp @@ -1,19 +1,22 @@ proc setup {} { + assert_bash_exec {OLDINFOPATH=$INFOPATH; INFOPATH=$INFOPATH:$TESTDIR/fixtures/info:} save_env } proc teardown {} { assert_env_unmodified + assert_bash_exec {INFOPATH="$OLDINFOPATH"; unset -v OLDINFOPATH} } setup -assert_complete_any "pinfo " - +assert_complete_any "pinfo bash" +sync_after_int +assert_complete_any "pinfo -" sync_after_int diff --git a/test/lib/completions/pm-hibernate.exp b/test/lib/completions/pm-hibernate.exp new file mode 100644 index 00000000..1a20603d --- /dev/null +++ b/test/lib/completions/pm-hibernate.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pm-hibernate -" +sync_after_int + + +teardown diff --git a/test/lib/completions/pm-is-supported.exp b/test/lib/completions/pm-is-supported.exp new file mode 100644 index 00000000..8bd136ff --- /dev/null +++ b/test/lib/completions/pm-is-supported.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pm-is-supported -" +sync_after_int + + +teardown diff --git a/test/lib/completions/pm-powersave.exp b/test/lib/completions/pm-powersave.exp new file mode 100644 index 00000000..dea37139 --- /dev/null +++ b/test/lib/completions/pm-powersave.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pm-powersave " +sync_after_int + + +teardown diff --git a/test/lib/completions/postconf.exp b/test/lib/completions/postconf.exp index 40349061..a7f26714 100644 --- a/test/lib/completions/postconf.exp +++ b/test/lib/completions/postconf.exp @@ -10,10 +10,19 @@ proc teardown {} { setup +# Broken configs may abort output of postconf halfway through, so use +# something from early output to not trigger false positives because of +# this. For example, inet_protocols=all but no IPv6 configured: +# postconf: fatal: parameter inet_interfaces: no local interface found for ::1 +# ...and output can be cut off somewhere near lmtp_tls_secur*. +# ...or be completely missing, so all we can do is to skip. +set test "\"postconf al\" should complete al* variables" +if {[assert_exec {postconf} "" "" "untested"]} { + assert_complete_any "postconf al" +} +sync_after_int -assert_complete_any "postconf p" - - +assert_complete_any "postconf -" sync_after_int diff --git a/test/lib/completions/pv.exp b/test/lib/completions/pv.exp new file mode 100644 index 00000000..64d685ae --- /dev/null +++ b/test/lib/completions/pv.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pv " +sync_after_int + +assert_complete_any "pv -" +sync_after_int + +assert_complete_any "pv --pidfile " +sync_after_int + + +teardown diff --git a/test/lib/completions/pycodestyle.exp b/test/lib/completions/pycodestyle.exp new file mode 100644 index 00000000..a4d095e0 --- /dev/null +++ b/test/lib/completions/pycodestyle.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pycodestyle " +sync_after_int + +assert_complete_any "pycodestyle -" +sync_after_int + +assert_no_complete "pycodestyle --doesnt-exist=" +sync_after_int + + +teardown diff --git a/test/lib/completions/python.exp b/test/lib/completions/python.exp index 29a10bf6..be0e8a2d 100644 --- a/test/lib/completions/python.exp +++ b/test/lib/completions/python.exp @@ -35,6 +35,9 @@ sync_after_int assert_complete_any "python -m sy" sync_after_int +assert_complete_any "python -m json." +sync_after_int + assert_complete_any "python -W " sync_after_int diff --git a/test/lib/completions/radvdump.exp b/test/lib/completions/radvdump.exp new file mode 100644 index 00000000..ad1363fd --- /dev/null +++ b/test/lib/completions/radvdump.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "radvdump -" +sync_after_int + + +teardown diff --git a/test/lib/completions/resolvconf.exp b/test/lib/completions/resolvconf.exp new file mode 100644 index 00000000..d1eaf246 --- /dev/null +++ b/test/lib/completions/resolvconf.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "resolvconf -" +sync_after_int + + +teardown diff --git a/test/lib/completions/rfkill.exp b/test/lib/completions/rfkill.exp new file mode 100644 index 00000000..ab0f1811 --- /dev/null +++ b/test/lib/completions/rfkill.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "rfkill " +sync_after_int + +assert_complete_any "rfkill -" +sync_after_int + + +teardown diff --git a/test/lib/completions/rrdtool.exp b/test/lib/completions/rrdtool.exp new file mode 100644 index 00000000..3fb392e4 --- /dev/null +++ b/test/lib/completions/rrdtool.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "rrdtool " +sync_after_int + + +teardown diff --git a/test/lib/completions/runuser.exp b/test/lib/completions/runuser.exp new file mode 100644 index 00000000..051abe1d --- /dev/null +++ b/test/lib/completions/runuser.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "runuser " +sync_after_int + + +teardown diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp index f37d5f5f..a5b8c69f 100644 --- a/test/lib/completions/screen.exp +++ b/test/lib/completions/screen.exp @@ -24,7 +24,8 @@ assert_complete_any "screen cat" sync_after_int -assert_complete_any "screen -T " +# Limit number of matches, assume at least vt100 and friends are there +assert_complete_any "screen -T vt" sync_after_int diff --git a/test/lib/completions/ss.exp b/test/lib/completions/ss.exp index f6e711c6..e64e33d9 100644 --- a/test/lib/completions/ss.exp +++ b/test/lib/completions/ss.exp @@ -17,5 +17,8 @@ sync_after_int assert_complete_any "ss -A " sync_after_int +assert_complete_any "ss -A foo," +sync_after_int + teardown diff --git a/test/lib/completions/sshfs.exp b/test/lib/completions/sshfs.exp new file mode 100644 index 00000000..42adbd8b --- /dev/null +++ b/test/lib/completions/sshfs.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified { + /_scp_path_esc=/d + } +} + + +setup + + +assert_complete_any "sshfs ./" +sync_after_int + + +teardown diff --git a/test/lib/completions/tox.exp b/test/lib/completions/tox.exp new file mode 100644 index 00000000..55106326 --- /dev/null +++ b/test/lib/completions/tox.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "tox -" +sync_after_int + +assert_complete "ALL" "tox -e " +sync_after_int + +assert_complete "ALL" "tox -e foo," +sync_after_int + + +teardown diff --git a/test/lib/completions/tshark.exp b/test/lib/completions/tshark.exp index f2419119..9e7d9d31 100644 --- a/test/lib/completions/tshark.exp +++ b/test/lib/completions/tshark.exp @@ -17,5 +17,8 @@ sync_after_int assert_complete_any "tshark -G " sync_after_int +assert_complete_any "tshark -O foo,htt" +sync_after_int + teardown diff --git a/test/lib/completions/uscan.exp b/test/lib/completions/uscan.exp new file mode 100644 index 00000000..f96ee971 --- /dev/null +++ b/test/lib/completions/uscan.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "uscan -" +sync_after_int + + +teardown diff --git a/test/lib/completions/useradd.exp b/test/lib/completions/useradd.exp new file mode 100644 index 00000000..c4f4957e --- /dev/null +++ b/test/lib/completions/useradd.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "useradd " +sync_after_int + +assert_complete_any "useradd -" +sync_after_int + + +teardown diff --git a/test/lib/completions/userdel.exp b/test/lib/completions/userdel.exp new file mode 100644 index 00000000..2a46246c --- /dev/null +++ b/test/lib/completions/userdel.exp @@ -0,0 +1,22 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +# "r": root +assert_complete_any "userdel r" +sync_after_int + +assert_complete_any "userdel -" +sync_after_int + + +teardown diff --git a/test/lib/completions/usermod.exp b/test/lib/completions/usermod.exp new file mode 100644 index 00000000..d7daf992 --- /dev/null +++ b/test/lib/completions/usermod.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "usermod " +sync_after_int + +assert_complete_any "usermod -" +sync_after_int + + +teardown diff --git a/test/lib/completions/wodim.exp b/test/lib/completions/wodim.exp new file mode 100644 index 00000000..55f63c30 --- /dev/null +++ b/test/lib/completions/wodim.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "wodim " +sync_after_int + + +teardown diff --git a/test/lib/completions/write.exp b/test/lib/completions/write.exp new file mode 100644 index 00000000..4503f6cc --- /dev/null +++ b/test/lib/completions/write.exp @@ -0,0 +1,19 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +# "r": root +assert_complete_any "write r" +sync_after_int + + +teardown diff --git a/test/lib/completions/xdg-mime.exp b/test/lib/completions/xdg-mime.exp new file mode 100644 index 00000000..015c586e --- /dev/null +++ b/test/lib/completions/xdg-mime.exp @@ -0,0 +1,39 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "xdg-mime " +sync_after_int + +assert_complete_any "xdg-mime -" +sync_after_int + +assert_complete_any "xdg-mime query " +sync_after_int + +assert_complete_any "xdg-mime query filetype " +sync_after_int + +assert_complete_any "xdg-mime query default " +sync_after_int + +assert_complete_any "xdg-mime default foo.desktop " +sync_after_int + +assert_complete_any "xdg-mime install --mode " +sync_after_int + +assert_complete_any "xdg-mime uninstall " +sync_after_int + + +teardown diff --git a/test/lib/completions/xdg-settings.exp b/test/lib/completions/xdg-settings.exp new file mode 100644 index 00000000..99a5838d --- /dev/null +++ b/test/lib/completions/xdg-settings.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "xdg-settings " +sync_after_int + +assert_complete_any "xdg-settings --" +sync_after_int + +assert_complete_any "xdg-settings get " +sync_after_int + + +teardown diff --git a/test/lib/completions/xm.exp b/test/lib/completions/xm.exp new file mode 100644 index 00000000..5a0c58e0 --- /dev/null +++ b/test/lib/completions/xm.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "xm " +sync_after_int + + +teardown diff --git a/test/lib/completions/xz.exp b/test/lib/completions/xz.exp index 6e6b29ca..ba9ccd3a 100644 --- a/test/lib/completions/xz.exp +++ b/test/lib/completions/xz.exp @@ -30,4 +30,8 @@ assert_complete_dir "a/ bashcomp.tar" "xz " $::srcdir/fixtures/xz sync_after_int +assert_complete_homedir "xz" +sync_after_int + + teardown diff --git a/test/lib/completions/zopfli.exp b/test/lib/completions/zopfli.exp index 15738ff0..8e17e92b 100644 --- a/test/lib/completions/zopfli.exp +++ b/test/lib/completions/zopfli.exp @@ -15,4 +15,8 @@ assert_complete_any "zopfli " sync_after_int +assert_complete_homedir "zopfli" +sync_after_int + + teardown diff --git a/test/lib/library.exp b/test/lib/library.exp index 1e2c7456..9321c5ca 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -584,6 +584,24 @@ proc assert_no_output {{cmd} {test ""} {prompt /@}} { } +# Check that ~part completes to ~full/ if home dir exists. +# @param string $cmd The command to attempt home dir completion for. +# @param string $test Optional parameter with test name. +# @param string $prompt (optional) Bash prompt. Default is "/@" +proc assert_complete_homedir {{cmd} {test ""} {prompt /@}} { + if {[string length $test] == 0} { + set test "$cmd should complete ~part to ~full/ if home dir exists" + } + assert_bash_exec {for u in $(compgen -u); do \ + eval test -d ~$u && echo $u; unset u; done} {} /@ users + if {![find_unique_completion_pair $users part full]} { + untested "Not running, no suitable test user found: $test" + } else { + assert_complete "~$full/" "$cmd ~$part" $test -nospace + } +} + + # Source/run file with additional tests if completion for the specified command # is installed in bash, and the command is available. # @param string $command Command to check completion availability for. @@ -602,21 +620,6 @@ proc assert_source_completions {command {file ""}} { } -# Assert that a _filedir_xspec completion is installed for specified command -# @param string $command Command to check completion installation for. -proc assert_xspec_completion_installed {command} { - set test "Completion via _filedir_xspec() should be installed" - set cmd "complete -p $command" - send "$cmd\r" - - set expected "^$cmd\r\ncomplete -F _filedir_xspec $command\r\n/@$" - expect { - -re $expected { pass "$test" } - -re /@ { fail "$test at prompt" } - } -} - - # Sort list. # `exec sort' is used instead of `lsort' to achieve exactly the # same sort order as in bash. @@ -929,7 +932,8 @@ proc find_unique_completion_pair {{list} {partName} {fullName}} { upvar $partName part upvar $fullName full set bestscore 0 - set list [lsort $list] + # Uniquify the list, that's what completion does too. + set list [lsort -unique $list] set n [llength $list] for {set i 0} {$i < $n} {incr i} { set cur [lindex $list $i] @@ -991,8 +995,23 @@ proc start_bash {} { if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash} set env(SRCDIR) $::srcdir set env(SRCDIRABS) $::srcdirabs - exp_spawn $TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc - assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc" + + # PS1, INPUTRC, TERM and stty columns must be initialized + # *before* starting bash to take proper effect. + + # Set fixed prompt `/@' + set env(PS1) "/@" + # Configure readline + set env(INPUTRC) "$::srcdir/config/inputrc" + # Avoid escape junk at beginning of line from readline, + # see e.g. http://bugs.gentoo.org/246091 + set env(TERM) "dumb" + # Ensure enough columns so expect doesn't have to care about line breaks + set stty_init "columns 150" + + exp_spawn $TOOL_EXECUTABLE --norc + assert_bash_exec {} "$TOOL_EXECUTABLE --norc" + assert_bash_exec "source $::srcdir/config/bashrc" } @@ -1023,6 +1042,11 @@ proc start_interactive_test {} { if {[info exists OPT_BASH_XTRACE]} { init_bash_xtrace } + global OPT_BUFFER_SIZE + if {[info exists OPT_BUFFER_SIZE]} { + verbose "Changing default expect match buffer size to $OPT_BUFFER_SIZE" + match_max $OPT_BUFFER_SIZE + } global OPT_TIMEOUT if {[info exists OPT_TIMEOUT]} { global timeout @@ -10,6 +10,7 @@ usage() { echo echo "Interesting options:" echo " --tool_exec= Test against a different bash executable." + echo " --buffer_size Change expect match buffer size from the default of 2000 bytes." echo " --debug Create a dbg.log in the test directory with detailed expect match information." echo " --timeout Change expect timeout from the default of 10 seconds." echo " --debug-xtrace Create an xtrace.log in the test directory with set -x output." @@ -39,6 +40,8 @@ args=() while [[ $# > 0 ]]; do case "$1" in --help|--usage) usage; exit 1;; + --buffer-size) shift; buffer_size=$1;; + --buffer-size=*) buffer_size=${1/--buffer-size=};; --debug-xtrace) args+=(OPT_BASH_XTRACE=1);; --timeout) shift; timeout=$1;; --timeout=*) timeout=${1/--timeout=};; @@ -54,6 +57,7 @@ while [[ $# > 0 ]]; do shift done +[[ -n $buffer_size ]] && args+=("OPT_BUFFER_SIZE=$buffer_size") [[ -n $timeout ]] && args+=("OPT_TIMEOUT=$timeout") [[ -z $tool ]] && { echo "Must specify tool somehow"; exit 1; } diff --git a/test/unit/__expand_tilde_by_ref.exp b/test/unit/__expand_tilde_by_ref.exp index 60aa7d52..bcb931e1 100644 --- a/test/unit/__expand_tilde_by_ref.exp +++ b/test/unit/__expand_tilde_by_ref.exp @@ -6,7 +6,7 @@ proc setup {home user} { save_env assert_bash_exec {echo "$HOME"} {} /@ _home set _home [string trim $_home] - assert_bash_exec {echo "$USER"} {} /@ _user + assert_bash_exec {id -un 2>/dev/null || echo "$USER"} {} /@ _user set _user [string trim $_user] } @@ -23,64 +23,51 @@ setup home user set test "function should run without errors" assert_bash_exec {__expand_tilde_by_ref > /dev/null} $test - - sync_after_int - set test "function should not pollute environment" # NOTE: A possible environment pollution is detected by assert_env_modified() in teardown() assert_bash_exec {foo() { local aa="~"; __expand_tilde_by_ref aa; }; foo; unset foo} $test - - sync_after_int - set test "~user should return $home" set cmd [format {var="~%s"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home" $cmd $test - - sync_after_int - set test "~/foo should return $home/foo" set cmd {var='~/foo'; __expand_tilde_by_ref var; printf "%s\n" "$var"} assert_bash_list "$home/foo" $cmd $test - - sync_after_int - set test "~user/bar should return $home/bar" set cmd [format {var="~%s/bar"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home/bar" $cmd $test - - sync_after_int - set test "~user/\$HOME should return $home/\$HOME" set cmd [format {var="~%s/\$HOME"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home/\$HOME" $cmd $test - - sync_after_int - set test "'~user/a b' should return '$home/a b'" set cmd [format {var="~%s/a b"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list [list [format {%s/a b} $home]] $cmd $test - - sync_after_int - set test "~user/* should return $home/*" set cmd [format {var="~%s/*"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home/\*" $cmd $test +sync_after_int +set test "'~user;echo hello' should return '~user;echo hello' (not expanded)" +set cmd [format {var="~%s;echo hello"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] +assert_bash_list [format "~%s;echo hello" $user] $cmd $test +sync_after_int +set test "'~user/a;echo hello' should return '$home/a;echo hello'" +set cmd [format {var="~%s/a;echo hello"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] +assert_bash_list "$home/a;echo hello" $cmd $test sync_after_int diff --git a/test/unit/_count_args.exp b/test/unit/_count_args.exp index b615cab8..b528846a 100644 --- a/test/unit/_count_args.exp +++ b/test/unit/_count_args.exp @@ -20,48 +20,31 @@ setup set test "_count_args should run without errors" assert_bash_exec {_count_args > /dev/null} $test - - sync_after_int - set test "a b| should set args to 1"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _count_args; echo $args} assert_bash_list 1 $cmd $test - - sync_after_int - set test "a b|c should set args to 1"; # | = cursor position set cmd {COMP_WORDS=(a bc); COMP_CWORD=1; COMP_LINE='a bc'; COMP_POINT=3; _count_args; echo $args} assert_bash_list 1 $cmd $test - - sync_after_int - set test "a b c| should set args to 2"; # | = cursor position set cmd {COMP_WORDS=(a b c); COMP_CWORD=2; COMP_LINE='a b c'; COMP_POINT=4; _count_args; echo $args} assert_bash_list 2 $cmd $test - - sync_after_int - set test "a b| c should set args to 1"; # | = cursor position set cmd {COMP_WORDS=(a b c); COMP_CWORD=1; COMP_LINE='a b c'; COMP_POINT=3; _count_args; echo $args} assert_bash_list 1 $cmd $test - - sync_after_int - set test "a b -c| d should set args to 2"; # | = cursor position set cmd {COMP_WORDS=(a b -c d); COMP_CWORD=2; COMP_LINE='a b -c d'; COMP_POINT=6; _count_args; echo $args} assert_bash_list 2 $cmd $test - - sync_after_int diff --git a/test/unit/_expand.exp b/test/unit/_expand.exp new file mode 100644 index 00000000..50453868 --- /dev/null +++ b/test/unit/_expand.exp @@ -0,0 +1,42 @@ +proc setup {home user} { + upvar $home _home + upvar $user _user + save_env + assert_bash_exec {echo "$HOME"} {} /@ _home + set _home [string trim $_home] + assert_bash_exec {id -un 2>/dev/null || echo "$USER"} {} /@ _user + set _user [string trim $_user] +} + +proc teardown {} { + assert_env_unmodified { + /COMPREPLY=/d + /cur=/d + } +} + + +setup home user + + +set test "function should run without errors" +assert_bash_exec {_expand > /dev/null} $test +sync_after_int + +set test "function should not pollute environment" +# NOTE: A possible environment pollution is detected by assert_env_modified() in teardown() +assert_bash_exec {foo() { _expand; }; foo; unset foo} $test +sync_after_int + +set test "~$user should set $home to COMPREPLY" +set cmd [format {cur="~%s" ; _expand ; printf "%%s\n" "$COMPREPLY"} $user] +assert_bash_list "$home" $cmd $test +sync_after_int + +set test "~$user/a should set $home/a to cur" +set cmd [format {cur="~%s/a" ; _expand ; printf "%%s\n" "$cur"} $user] +assert_bash_list "$home/a" $cmd $test +sync_after_int + + +teardown diff --git a/test/unit/_filedir.exp b/test/unit/_filedir.exp index fb29af5b..597e4acc 100644 --- a/test/unit/_filedir.exp +++ b/test/unit/_filedir.exp @@ -55,37 +55,25 @@ setup set test "_filedir should run without errors" assert_bash_exec {_filedir > /dev/null} $test - - sync_after_int - foreach name {f f2} { set test "completing $name ab/ should return e" set cmd "$name ab/" assert_complete_dir e $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\\ b/ should return i" set cmd "$name a\\ b/" assert_complete_dir i $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\\\'b/ should return c" set cmd "$name a\\\'b/" assert_complete_dir c $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\\\$b/ should return h" if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} { xfail $test @@ -95,7 +83,6 @@ foreach name {f f2} { sync_after_int } - if {! [is_cygwin]} { # Illegal characters in file/dir names set test "completing $name a\\\"b/ should return d"; #" set cmd "$name a\\\"b/"; #" @@ -108,44 +95,28 @@ foreach name {f f2} { sync_after_int } - set test "completing $name a\\&b/ should return f" set cmd "$name a\\&b/" assert_complete_dir f $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\$ should return a\\\$b/" set cmd "$name a\$" assert_complete_dir "\b\\\\\$b/" $cmd "$::srcdir/fixtures/_filedir" $test -nospace - - sync_after_int - set cmd "$name 'ab/" assert_complete_dir {e'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name 'a b/" assert_complete_dir {i'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name 'a\$b/" assert_complete_dir {h'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - if {! [is_cygwin]} { # Illegal characters in file/dir names set cmd "$name 'a\"b/"; #" assert_complete_dir {d'} $cmd "$TESTDIR/tmp" @@ -156,42 +127,28 @@ foreach name {f f2} { sync_after_int } - set cmd "$name 'a&b/" assert_complete_dir {f'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name \"ab/"; #" assert_complete_dir {e"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - set cmd "$name \"a b/"; #" assert_complete_dir {i"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - set cmd "$name \"a'b/"; #" assert_complete_dir {c"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - if {! [is_cygwin]} { # Illegal characters in file/dir names set cmd "$name \"a\\\"b/"; #" assert_complete_dir {d"} $cmd "$TESTDIR/tmp"; #" sync_after_int } - if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} { xfail "$name \"a\\\$b/ should show completions" } else { @@ -200,44 +157,28 @@ foreach name {f f2} { sync_after_int } - set cmd "$name \"a\\b/"; #" assert_complete_dir "\b\b\bb/e\\\"" $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name \"a\\\\b/"; #" assert_complete_dir {g"} $cmd "$TESTDIR/tmp"; #" - - sync_after_int - set cmd "$name \"a&b/"; #" assert_complete_dir {f"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - set cmd "$name \\\[x" assert_complete_dir {\[x\]} $cmd "$::srcdir/fixtures/_filedir/brackets" - - sync_after_int }; # foreach - set test "completing with filter '.e1' should show completions" assert_complete_dir {ee.e1 foo/ gg.e1 ii.E1} "g " "$::srcdir/fixtures/_filedir/ext" $test - - sync_after_int - set test "completing f aƩ should return g" # Execute this test only with LC_CTYPE matching *UTF-8* # See also: http://www.mail-archive.com/bash-completion-devel\ @@ -252,16 +193,11 @@ if { } else { unsupported "$test" } - - sync_after_int - set test "completing fd a\\ should return a\\ b/" set cmd "fd a\\ " assert_complete_dir "a\\ b/" $cmd "$::srcdir/fixtures/_filedir" $test -nospace - - sync_after_int diff --git a/test/unit/_get_comp_words_by_ref.exp b/test/unit/_get_comp_words_by_ref.exp index c113f6df..2683d163 100644 --- a/test/unit/_get_comp_words_by_ref.exp +++ b/test/unit/_get_comp_words_by_ref.exp @@ -23,122 +23,79 @@ setup set test "_get_comp_words_by_ref should run without errors" assert_bash_exec {_get_comp_words_by_ref cur > /dev/null} $test - - sync_after_int - # See also ./lib/completions/alias.exp. Here `_get_cword' is actually tested # by moving the cursor left into the current word. - set test "a b|"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b a"} $cmd $test - - sync_after_int - set test "a |"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=1; COMP_LINE='a '; COMP_POINT=2; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" a"} $cmd $test - - sync_after_int - set test "|a"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a'; COMP_POINT=0; \ unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - sync_after_int - set test "|a \$"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a '; COMP_POINT=0; \ unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - sync_after_int - set test " | a \$"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE=' a '; COMP_POINT=1; \ unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - sync_after_int - set test "a b |"; # | = cursor position set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" b"} $cmd $test - - sync_after_int - set test "a b | with WORDBREAKS -= :"; # | = cursor position set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref -n : cur; printf %s "$cur"} assert_bash_list {} $cmd $test - - sync_after_int - set test "a b|c"; # | = cursor position set cmd {COMP_WORDS=(a bc); COMP_CWORD=1; COMP_LINE='a bc'; COMP_POINT=3; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b a"} $cmd $test - - sync_after_int - set test "a | b"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=2; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" a"} $cmd $test - - sync_after_int - set test {a b\ c| should return b\ c}; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b\\ c a"} $cmd $test - - sync_after_int - set test {a\ b a\ b| should return a\ b}; # | = cursor position set cmd {COMP_WORDS=('a\ b' 'a\ b'); COMP_CWORD=1; COMP_LINE='a\ b a\ b'; COMP_POINT=9; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"a\\ b a\\ b"} $cmd $test - - sync_after_int - set test {a b\| c should return b\ }; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b\\ a"} $cmd $test - - sync_after_int - -set test {a "b\|}; #"# | = cursor position +set test {a "b\|}; #"# | = cursor position set cmd {COMP_WORDS=(a '"b\'); COMP_CWORD=1; COMP_LINE='a "b\'; COMP_POINT=5; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"\"b\\ a"} $cmd $test - - sync_after_int - set test {a 'b c|}; # | = cursor position set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"} @@ -148,11 +105,8 @@ expect { -ex "'b c a\r\n/@" { pass "$test" } -ex "c b\r\n/@" { fail "$test" } } - - sync_after_int - set test {a "b c|}; #"# | = cursor position set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6} @@ -164,11 +118,8 @@ expect { -ex "\"b c a\r\n/@" { pass "$test" } -ex "c b\r\n/@" { fail "$test" } } - - sync_after_int - set test {a b:c| with WORDBREAKS += :}; # | = cursor position set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} set expected {"c :"} @@ -177,65 +128,47 @@ append cmd {; COMP_LINE='a b:c'; COMP_POINT=5} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a b:c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} assert_bash_list {"b:c a"} $cmd $test - - sync_after_int - set test {a b c:| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} append cmd {; COMP_LINE='a b c:'; COMP_POINT=6} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} assert_bash_list {"c: b"} $cmd $test - - sync_after_int - set test {a b:c | with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c ''); COMP_CWORD=4} append cmd {; COMP_LINE='a b:c '; COMP_POINT=6} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} assert_bash_list {" b:c"} $cmd $test - - sync_after_int - set test {a :| with WORDBREAKS -= : should return :}; # | = cursor position set cmd {COMP_WORDS=(a :); COMP_CWORD=1; COMP_LINE='a :'; COMP_POINT=3} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} assert_bash_list {": a"} $cmd $test - - sync_after_int - set test {a b::| with WORDBREAKS -= : should return b::}; # | = cursor position set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} append cmd {; COMP_LINE='a b::'; COMP_POINT=5} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} assert_bash_list {"b:: a"} $cmd $test - - sync_after_int - # This test makes sure `_get_cword' doesn't use `echo' to return it's value, # because -n might be interpreted by `echo' and thus will not be returned. set test "a -n| should return -n"; # | = cursor position @@ -243,21 +176,15 @@ set cmd {COMP_WORDS=(a -n); COMP_CWORD=1; COMP_LINE='a -n'; COMP_POINT=4} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur; printf "%s\n" $cur} assert_bash_list -n $cmd $test - - sync_after_int - set test {a b>c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b \> c); COMP_CWORD=3; COMP_LINE='a b>c'; COMP_POINT=5} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur prev; echo "$cur"} assert_bash_list c $cmd $test - - sync_after_int - set test {a b=c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} set expected c @@ -265,21 +192,15 @@ append cmd {; COMP_LINE='a b=c'; COMP_POINT=5} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur prev; echo "$cur"} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a *| should return *}; # | = cursor position set cmd {COMP_WORDS=(a \*); COMP_CWORD=1; COMP_LINE='a *'; COMP_POINT=4} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur; echo "$cur"} assert_bash_list * $cmd $test - - sync_after_int - set test {a $(b c| should return $(b c}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c'); COMP_CWORD=1; COMP_LINE='a $(b c'; COMP_POINT=7} assert_bash_exec $cmd @@ -291,11 +212,8 @@ expect { # Expected failure on bash-4 -ex "c/@" { xfail "$test" } } - - sync_after_int - set test {a $(b c\ d| should return $(b c\ d}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c\ d'); COMP_CWORD=1; COMP_LINE='a $(b c\ d'; COMP_POINT=10} assert_bash_exec $cmd @@ -308,11 +226,8 @@ expect { # Expected failure on bash-4 -ex "c\\ d/@" { xfail "$test" } } - - sync_after_int - set test {a 'b&c| should return 'b&c}; # | = cursor position set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6} @@ -324,19 +239,13 @@ expect { -ex "'b&c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - sync_after_int - set test {unknown argument should raise error} set cmd {_get_comp_words_by_ref dummy} assert_bash_list {"bash: _get_comp_words_by_ref(): `dummy': unknown argument"} $cmd $test - - sync_after_int - set test "a b| to all vars"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3} assert_bash_exec $cmd @@ -344,11 +253,8 @@ set cmd { \ _get_comp_words_by_ref words cword prev cur; echo "${words[@]} $cword $cur $prev" \ } assert_bash_list {"a b 1 b a"} $cmd $test - - sync_after_int - set test "a b| to alternate vars"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3;} assert_bash_exec $cmd @@ -356,11 +262,8 @@ set cmd {_get_comp_words_by_ref -c cur2 -p prev2 -w words2 -i cword2} assert_bash_exec $cmd set cmd {echo "$cur2 $prev2 ${words2[@]} $cword2"} assert_bash_list {"b a a b 1"} $cmd $test - - sync_after_int - set test "a b| to alternate vars"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3;} assert_bash_exec $cmd @@ -368,51 +271,37 @@ set cmd {_get_comp_words_by_ref -c cur2 -p prev2 -w words2 -i cword2} assert_bash_exec $cmd set cmd {echo "$cur2 $prev2 ${words2[@]} $cword2"} assert_bash_list {"b a a b 1"} $cmd $test - - sync_after_int - set test {a b : c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3; COMP_LINE='a b : c'; COMP_POINT=7} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {"a b : c"} $cmd $test - - sync_after_int - set test {a b: c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b: c'; COMP_POINT=6} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {"a b: c"} $cmd $test - - sync_after_int - set test {a b :c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b :c'; COMP_POINT=6} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {"a b :c"} $cmd $test - - sync_after_int - set test {a b\ :c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a "b\\ " : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b\ :c'; COMP_POINT=7} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {a "b\\ :c"} $cmd $test - - sync_after_int diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp index 3fd3e20e..9708a870 100644 --- a/test/unit/_get_cword.exp +++ b/test/unit/_get_cword.exp @@ -21,82 +21,54 @@ setup set test "_get_cword should run without errors" assert_bash_exec {_get_cword > /dev/null} $test - - sync_after_int - # See also ./lib/completions/alias.exp. Here `_get_cword' is actually tested # by moving the cursor left into the current word. - set test "a b| should return b"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _get_cword; echo} assert_bash_list b $cmd $test - - sync_after_int - set test "a | should return nothing"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=1; COMP_LINE='a '; COMP_POINT=2; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n/@" {pass "$test"} - - sync_after_int - set test "a b | should return nothing"; # | = cursor position set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n/@" {pass "$test"} - - sync_after_int - set test "a b | with WORDBREAKS -= : should return nothing"; # | = cursor position set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_cword :} send "$cmd\r" expect -ex "$cmd\r\n/@" {pass "$test"} - - sync_after_int - set test "a b|c should return b"; # | = cursor position set cmd {COMP_WORDS=(a bc); COMP_CWORD=1; COMP_LINE='a bc'; COMP_POINT=3; _get_cword; echo} assert_bash_list b $cmd $test - - sync_after_int - set test {a b\ c| should return b\ c}; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=6; _get_cword; echo} assert_bash_list {"b\\ c"} $cmd $test - - sync_after_int - set test {a b\| c should return b\ }; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=4; _get_cword; echo} assert_bash_list {"b\\"} $cmd $test - - sync_after_int - set test {a "b\| should return "b\ }; # | = cursor position set cmd {COMP_WORDS=(a '"b\'); COMP_CWORD=1; COMP_LINE='a "b\'; COMP_POINT=5; _get_cword; echo} assert_bash_list {"\"b\\"} $cmd $test - - sync_after_int - set test {a 'b c| should return 'b c}; # | = cursor position set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_cword} @@ -106,11 +78,8 @@ expect { -ex "'b c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - sync_after_int - set test {a "b c| should return "b c}; # | = cursor position set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6; _get_cword}; @@ -120,92 +89,62 @@ expect { -ex "\"b c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - sync_after_int - set test {a b:c| with WORDBREAKS += : should return c}; # | = cursor position set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} set expected c append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword; echo} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a b:c| with WORDBREAKS -= : should return b:c}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword :; echo} assert_bash_list b:c $cmd $test - - sync_after_int - set test {a b c:| with WORDBREAKS -= : should return c:}; # | = cursor position set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} append cmd {; COMP_LINE='a b c:'; COMP_POINT=6; _get_cword :; echo} assert_bash_list c: $cmd $test - - sync_after_int - set test {a :| with WORDBREAKS -= : should return :}; # | = cursor position set cmd {COMP_WORDS=(a :); COMP_CWORD=1; COMP_LINE='a :'; COMP_POINT=3; _get_cword :; echo} assert_bash_list : $cmd $test - - sync_after_int - set test {a b::| with WORDBREAKS -= : should return b::}; # | = cursor position set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} append cmd {; COMP_LINE='a b::'; COMP_POINT=5; _get_cword :; echo} assert_bash_list b:: $cmd $test - - sync_after_int - # This test makes sure `_get_cword' doesn't use `echo' to return it's value, # because -n might be interpreted by `echo' and thus will not be returned. set test "a -n| should return -n"; # | = cursor position set cmd {COMP_WORDS=(a -n); COMP_CWORD=1; COMP_LINE='a -n'; COMP_POINT=4; _get_cword; echo} assert_bash_list -n $cmd $test - - sync_after_int - set test {a b>c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b \> c); COMP_CWORD=3; COMP_LINE='a b>c'; COMP_POINT=5; _get_cword; echo} assert_bash_list c $cmd $test - - sync_after_int - set test {a b=c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} set expected c append cmd {; COMP_LINE='a b=c'; COMP_POINT=5; _get_cword; echo} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a *| should return *}; # | = cursor position set cmd {COMP_WORDS=(a \*); COMP_CWORD=1; COMP_LINE='a *'; COMP_POINT=4; _get_cword; echo} assert_bash_list * $cmd $test - - sync_after_int - set test {a $(b c| should return $(b c}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c'); COMP_CWORD=1; COMP_LINE='a $(b c'; COMP_POINT=7; _get_cword} #assert_bash_list {{$(b\ c}} $cmd $test @@ -216,11 +155,8 @@ expect { # Expected failure on bash-4 -ex "c/@" { xfail "$test" } } - - sync_after_int - set test {a $(b c\ d| should return $(b c\ d}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c\ d'); COMP_CWORD=1; COMP_LINE='a $(b c\ d'; COMP_POINT=10; _get_cword} #assert_bash_list {{$(b\ c\\\ d}} $cmd $test @@ -231,11 +167,8 @@ expect { # Expected failure on bash-4 -ex "c\\ d/@" { xfail "$test" } } - - sync_after_int - set test {a 'b&c| should return 'b&c}; # | = cursor position set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6; _get_cword} @@ -245,11 +178,8 @@ expect { -ex "'b&c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - sync_after_int - set test "index shouldn't drop below 0" set dir $::srcdir/fixtures/_get_cword set cmd "scp" @@ -259,8 +189,6 @@ expect { -re /@ { pass "$test" } default { unresolved "$test" } } - - sync_after_int diff --git a/test/unit/_init_completion.exp b/test/unit/_init_completion.exp index 75c41255..9408f86f 100644 --- a/test/unit/_init_completion.exp +++ b/test/unit/_init_completion.exp @@ -19,16 +19,11 @@ setup set test "function should not pollute environment" # NOTE: A possible environment pollution is detected by assert_env_modified() in teardown() assert_bash_exec {foo() { local cur prev words cword; _init_completion; }; foo; unset foo} $test - - sync_after_int - set test "|a"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a'; COMP_POINT=0; _init_completion; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - sync_after_int diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp index c065f766..01b09b6b 100644 --- a/test/unit/_known_hosts_real.exp +++ b/test/unit/_known_hosts_real.exp @@ -20,47 +20,47 @@ setup set test "Hosts should be put in COMPREPLY" set hosts [get_hosts -unsorted] - # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config - # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts +# Hosts `gee', `hus' and `jar' are defined in +# ./fixtures/_known_hosts_real/config +# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 +# test cases in ./fixtures/_known_hosts_real/known_hosts lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42 set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY} assert_bash_list $hosts $cmd $test -sort - - sync_after_int - set test "Hosts should have username prefix and colon suffix" set hosts [get_hosts -unsorted] - # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config - # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts +# Hosts `gee', `hus' and `jar' are defined in +# ./fixtures/_known_hosts_real/config +# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 +# test cases in ./fixtures/_known_hosts_real/known_hosts lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42 set hosts [lsort -ascii $hosts] set expected {} foreach host $hosts { lappend expected "user@$host:" } - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -acF fixtures/_known_hosts_real/config 'user@'; echo_array COMPREPLY} assert_bash_list $expected $cmd $test -sort - - sync_after_int - set test "Files containing consecutive spaces should work" set hosts [get_hosts -unsorted] set hosts_orig $hosts - # Hosts `gee' and `hus' are defined in `./fixtures/_known_hosts_real/spaced conf' - # Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 +# Hosts `gee' and `hus' are defined in +#`./fixtures/_known_hosts_real/spaced conf' +# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 lappend hosts gee hus two two2 two3 two4 set hosts_config $hosts - # Hosts `doo' and `ike' are defined in `./fixtures/_known_hosts_/spaced known_hosts' +# Hosts `doo' and `ike' are defined in +# `./fixtures/_known_hosts_/spaced known_hosts' lappend hosts doo ike set hosts [join [bash_sort $hosts ] "\\s+"] set hosts_orig [join [bash_sort $hosts_orig ] "\\s+"] set hosts_config [join [bash_sort $hosts_config] "\\s+"] - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF 'fixtures/_known_hosts_real/spaced conf' ''; echo_array COMPREPLY} send "$cmd\r" expect -ex "$cmd\r\n" @@ -71,23 +71,20 @@ expect { -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } } - - sync_after_int - set test "Files starting with tilde (~) should work" set hosts [get_hosts -unsorted] - # Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 - # Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3 - # Host `four' is defined in ./fixtures/_known_hosts_real/known_hosts4 +# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 +# Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3 +# Host `four' is defined in ./fixtures/_known_hosts_real/known_hosts4 lappend hosts two two2 two3 two4 three four set hosts [join [bash_sort $hosts] "\\s+"] - # Setup environment +# Setup environment set cmd {OLDHOME=$HOME; HOME=$SRCDIRABS} send "$cmd\r" expect -ex "$cmd\r\n/@" - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config_tilde ''; echo_array COMPREPLY} send "$cmd\r" expect -ex "$cmd\r\n" @@ -95,43 +92,41 @@ expect { -re "^$hosts\r\n/@$" { pass "$test" } default { unresolved "$test" } } - # Teardown environment +# Teardown environment set cmd {HOME=$OLDHOME} send "$cmd\r" expect -ex "$cmd\r\n/@" - - sync_after_int - set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE" assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" set hosts [get_hosts_avahi] - # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config - # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts +# Hosts `gee', `hus' and `jar' are defined in +# ./fixtures/_known_hosts_real/config +# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 +# test cases in ./fixtures/_known_hosts_real/known_hosts lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42 - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY} assert_bash_list $hosts $cmd $test -sort sync_after_int assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" - - sync_after_int - set test "Included config files should work" set hosts [get_hosts -unsorted] - # Host 'recursion' is defined in ./fixtures/_known_hosts_real/config_include_recursion - # Host 'relative_path' is defined in ./fixtures/_known_hosts_real/.ssh/config_relative_path +# Host 'recursion' is defined in +# ./fixtures/_known_hosts_real/config_include_recursion +# Host 'relative_path' is defined in +# ./fixtures/_known_hosts_real/.ssh/config_relative_path lappend hosts recursion relative_path set hosts [join [bash_sort $hosts] "\\s+"] - # Setup environment - # Redefined HOME to handle relative path inclusions on $HOME/.ssh +# Setup environment +# Redefined HOME to handle relative path inclusions on $HOME/.ssh set cmd {OLDHOME=$HOME; HOME="$SRCDIRABS/fixtures/_known_hosts_real"} send "$cmd\r" expect -ex "$cmd\r\n/@" - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config_include ''; echo_array COMPREPLY} send "$cmd\r" expect -ex "$cmd\r\n" @@ -139,12 +134,37 @@ expect { -re "^$hosts\r\n/@$" { pass "$test" } default { unresolved "$test" } } - # Teardown environment +# Teardown environment set cmd {HOME=$OLDHOME} send "$cmd\r" expect -ex "$cmd\r\n/@" +sync_after_int +set test "IPv6 filtering should work" +set hosts "127.0.0.1 localhost" +assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" +set cmd {unset COMPREPLY; _known_hosts_real -4F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY} +assert_bash_list $hosts $cmd $test -sort +sync_after_int +assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" +sync_after_int +set test "IPv4 filtering should work" +set hosts "::1 localhost" +assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" +set cmd {unset COMPREPLY; _known_hosts_real -6F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY} +assert_bash_list $hosts $cmd $test -sort +sync_after_int +assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" +sync_after_int + +set test "IPv4+IPv6 filtering should work" +set hosts "localhost" +assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" +set cmd {unset COMPREPLY; _known_hosts_real -46F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY} +assert_bash_list $hosts $cmd $test -sort +sync_after_int +assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" sync_after_int diff --git a/test/unit/_tilde.exp b/test/unit/_tilde.exp index 19f47241..e313dcae 100644 --- a/test/unit/_tilde.exp +++ b/test/unit/_tilde.exp @@ -1,15 +1,7 @@ -# @param string $part Reference to variable to hold partial unique username -# @param string $full Reference to variable to hold full unique username -proc setup {part full} { - upvar $part _part - upvar $full _full - - assert_bash_exec {compgen -u} {} /@ users - find_unique_completion_pair $users _part _full +proc setup {} { save_env } - proc teardown {} { assert_env_unmodified { /COMPREPLY=/d @@ -17,37 +9,41 @@ proc teardown {} { } -setup part full +setup set test "function should run without errors" assert_bash_exec {_tilde > /dev/null} $test - - sync_after_int - set test "function should not pollute environment" # NOTE: A possible environment pollution is detected by assert_env_modified() in teardown() assert_bash_exec {foo() { local aa="~"; _tilde "$aa"; }; foo; unset foo} $test - - sync_after_int +set failed_find_unique_completion 0 +assert_bash_exec {compgen -u} {} /@ users +if {![find_unique_completion_pair $users part full]} { + set failed_find_unique_completion 1 +} set test "~full should complete to ~full unmodified" -set cmd [format {_tilde "~%s"; printf "%%s\n" "${COMPREPLY[@]}"} $full] -assert_bash_list "~$full" $cmd $test - - -sync_after_int - +if {$failed_find_unique_completion} { + untested "Not running, no suitable test user found: $test" +} else { + set cmd [format {_tilde "~%s"; printf "%%s\n" "${COMPREPLY[@]}"} $full] + assert_bash_list "~$full" $cmd $test + sync_after_int +} set test "~part should complete to ~full" -set cmd [format {_tilde "~%s"; printf "%%s\n" "${COMPREPLY[@]}"} $part] -assert_bash_list "~$full" $cmd $test -sync_after_int - +if {$failed_find_unique_completion} { + untested "Not running, no suitable test user found: $test" +} else { + set cmd [format {_tilde "~%s"; printf "%%s\n" "${COMPREPLY[@]}"} $part] + assert_bash_list "~$full" $cmd $test + sync_after_int +} # Debian #766163 assert_no_complete "_tilde ~-o" diff --git a/test/unit/find_unique_completion_pair.exp b/test/unit/find_unique_completion_pair.exp index ec7f040d..4a95c1bf 100644 --- a/test/unit/find_unique_completion_pair.exp +++ b/test/unit/find_unique_completion_pair.exp @@ -24,6 +24,7 @@ proc test_find_ucp {{list} {epart} {econt} {eret 1}} { test_find_ucp {a} 0 0 0 test_find_ucp {ab} a b +test_find_ucp {ab ab ab} a b test_find_ucp {a ab abcd abc} 0 0 0 test_find_ucp {a ab abcde abc} abcd e test_find_ucp {user1 user2} 0 0 0 diff --git a/test/unit/quote.exp b/test/unit/quote.exp index afe670a2..1764e6b0 100644 --- a/test/unit/quote.exp +++ b/test/unit/quote.exp @@ -21,7 +21,6 @@ expect { } sync_after_int - set cmd {quote "a b"} set test {quote "a b" should output 'a b'} send "$cmd\r" @@ -32,7 +31,6 @@ expect { } sync_after_int - set cmd {quote " a "} set test {quote " a " should output ' a '} send "$cmd\r" @@ -43,7 +41,6 @@ expect { } sync_after_int - set cmd {quote "a'b'c"} set test {quote "a'b'c" should output 'a'\''b'\''c'} send "$cmd\r" @@ -54,7 +51,6 @@ expect { } sync_after_int - set cmd {quote "a'"} set test {quote "a'" should output 'a'\'''} send "$cmd\r" |