summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>2017-09-25 23:46:54 -0300
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2017-09-25 23:46:54 -0300
commit6d88f1055806932d9291f96847d2b691cccda2cd (patch)
tree0ff79eedaa8a239331256048981deedbd0721965 /test
parent059a87a5936cfebfd2d71ab8057002cafb2ea051 (diff)
downloadbash-completion-6d88f1055806932d9291f96847d2b691cccda2cd.tar.gz
New upstream version 2.7upstream/2.7
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore4
-rw-r--r--test/Makefile.in387
-rw-r--r--test/completion/2to3.exp1
-rw-r--r--test/completion/7z.exp1
-rw-r--r--test/completion/acroread.exp11
-rw-r--r--test/completion/adb.exp1
-rw-r--r--test/completion/alpine.exp1
-rw-r--r--test/completion/appdata-validate.exp1
-rw-r--r--test/completion/arch.exp2
-rw-r--r--test/completion/bind.exp1
-rw-r--r--test/completion/change_pw.exp2
-rw-r--r--test/completion/checksec.exp1
-rw-r--r--test/completion/chroot.exp1
-rw-r--r--test/completion/cleanarch.exp2
-rw-r--r--test/completion/configure.exp2
-rw-r--r--test/completion/createuser.exp1
-rw-r--r--test/completion/declare.exp1
-rw-r--r--test/completion/deja-dup.exp1
-rw-r--r--test/completion/dropuser.exp1
-rw-r--r--test/completion/dumpdb.exp2
-rw-r--r--test/completion/flake8.exp1
-rw-r--r--test/completion/freebsd-update.exp1
-rw-r--r--test/completion/function.exp1
-rw-r--r--test/completion/genaliases.exp2
-rw-r--r--test/completion/gm.exp1
-rw-r--r--test/completion/gnokii.exp1
-rw-r--r--test/completion/hostname.exp1
-rw-r--r--test/completion/hping3.exp1
-rw-r--r--test/completion/indent.exp1
-rw-r--r--test/completion/inject.exp2
-rw-r--r--test/completion/jpegoptim.exp1
-rw-r--r--test/completion/jshint.exp1
-rw-r--r--test/completion/kdvi.exp4
-rw-r--r--test/completion/kpdf.exp4
-rw-r--r--test/completion/list_owners.exp2
-rw-r--r--test/completion/lz4.exp1
-rw-r--r--test/completion/mailmanctl.exp2
-rw-r--r--test/completion/mock.exp1
-rw-r--r--test/completion/mr.exp1
-rw-r--r--test/completion/newgrp.exp1
-rw-r--r--test/completion/optipng.exp1
-rw-r--r--test/completion/pdftotext.exp1
-rw-r--r--test/completion/pngfix.exp1
-rw-r--r--test/completion/portsnap.exp1
-rw-r--r--test/completion/pushd.exp1
-rw-r--r--test/completion/py.test.exp1
-rw-r--r--test/completion/pyflakes.exp1
-rw-r--r--test/completion/pyvenv.exp1
-rw-r--r--test/completion/qrunner.exp2
-rw-r--r--test/completion/repomanage.exp1
-rw-r--r--test/completion/ssh-keygen.exp1
-rw-r--r--test/completion/synclient.exp1
-rw-r--r--test/completion/timeout.exp1
-rw-r--r--test/completion/tipc.exp1
-rw-r--r--test/completion/udevadm.exp1
-rw-r--r--test/completion/unshunt.exp2
-rw-r--r--test/completion/vi.exp4
-rw-r--r--test/completion/zopfli.exp1
-rw-r--r--test/completion/zopflipng.exp1
-rw-r--r--test/config/bashrc18
-rw-r--r--test/config/default.exp18
-rw-r--r--test/config/inputrc5
-rw-r--r--test/docker/Dockerfile-centos618
-rw-r--r--test/docker/Dockerfile-fedoradev41
-rw-r--r--test/docker/Dockerfile-ubuntu14197
-rwxr-xr-xtest/docker/docker-script.sh19
-rw-r--r--test/fixtures/7z/a.7zbin0 -> 109 bytes
-rw-r--r--test/fixtures/7z/f.txt1
-rw-r--r--test/fixtures/_get_cword/sea (renamed from test/fixtures/_filedir/a"b/d)0
-rw-r--r--test/fixtures/_get_cword/seb (renamed from test/fixtures/make/empty_dir/.nothing_here)0
-rw-r--r--test/fixtures/_get_cword/sec (renamed from test/fixtures/man/man3/Bash::Completion.3pm.gz)0
-rw-r--r--test/fixtures/_get_cword/ääää§0
-rw-r--r--test/fixtures/_known_hosts_real/.ssh/config_relative_path1
-rw-r--r--test/fixtures/_known_hosts_real/config1
-rw-r--r--test/fixtures/_known_hosts_real/config_full_path1
-rw-r--r--test/fixtures/_known_hosts_real/config_include5
-rw-r--r--test/fixtures/_known_hosts_real/config_include_recursion1
-rw-r--r--test/fixtures/ant/.gitignore2
-rw-r--r--test/fixtures/ant/build-with-import.xml8
-rw-r--r--test/fixtures/ant/build.xml4
-rw-r--r--test/fixtures/ant/imported-build.xml6
-rw-r--r--test/fixtures/ant/named-build.xml6
-rw-r--r--test/fixtures/java/no-complete.txt1
-rw-r--r--test/fixtures/make/.gitignore1
-rw-r--r--test/fixtures/make/Makefile34
-rw-r--r--test/fixtures/make/sample.c1
-rw-r--r--test/fixtures/make/sample.d3
-rw-r--r--test/fixtures/make/sample.h0
-rw-r--r--test/fixtures/perl/Devel/BashCompletion.pm1
-rw-r--r--test/fixtures/perldoc/BashCompletionDoc.pod0
-rw-r--r--test/fixtures/perldoc/BashCompletionModule.pm0
-rw-r--r--test/fixtures/ri/BashCompletion/cdesc-BashCompletion.ribin0 -> 197 bytes
-rw-r--r--test/fixtures/ri/cache.ribin0 -> 136 bytes
-rw-r--r--test/fixtures/ri/created.rid1
-rw-r--r--test/fixtures/scp/config2
-rw-r--r--test/fixtures/sftp/config2
-rw-r--r--test/fixtures/shared/empty_dir/.nothing_here0
-rw-r--r--test/fixtures/ssh-copy-id/.ssh/id_rsa.pub1
-rw-r--r--test/fixtures/tar/archive.tar.xzbin0 -> 10240 bytes
-rw-r--r--test/fixtures/tar/dir/fileA0
-rw-r--r--test/fixtures/tar/dir/fileB0
-rw-r--r--test/fixtures/tar/dir/fileC0
-rw-r--r--test/fixtures/tar/dir/hello0
-rw-r--r--test/fixtures/tar/dir2/.nothing_here0
-rw-r--r--test/fixtures/tar/escape.tarbin0 -> 10240 bytes
-rwxr-xr-xtest/generate64
-rw-r--r--test/lib/completions/2to3.exp (renamed from test/lib/completions/indent.exp)4
-rw-r--r--test/lib/completions/7z.exp37
-rw-r--r--test/lib/completions/abook.exp2
-rw-r--r--test/lib/completions/adb.exp18
-rw-r--r--test/lib/completions/alpine.exp18
-rw-r--r--test/lib/completions/ant.exp15
-rw-r--r--test/lib/completions/appdata-validate.exp18
-rw-r--r--test/lib/completions/apt-get.exp13
-rw-r--r--test/lib/completions/arch.exp5
-rw-r--r--test/lib/completions/bind.exp21
-rw-r--r--test/lib/completions/bts.exp21
-rw-r--r--test/lib/completions/ccache.exp25
-rw-r--r--test/lib/completions/cd.exp12
-rw-r--r--test/lib/completions/checksec.exp18
-rw-r--r--test/lib/completions/chkconfig.exp9
-rw-r--r--test/lib/completions/chroot.exp18
-rw-r--r--test/lib/completions/configure.exp8
-rw-r--r--test/lib/completions/createdb.exp4
-rw-r--r--test/lib/completions/createuser.exp18
-rw-r--r--test/lib/completions/curl.exp2
-rw-r--r--test/lib/completions/dcop.exp2
-rw-r--r--test/lib/completions/dd.exp2
-rw-r--r--test/lib/completions/declare.exp26
-rw-r--r--test/lib/completions/deja-dup.exp21
-rw-r--r--test/lib/completions/dpkg.exp14
-rw-r--r--test/lib/completions/dropdb.exp4
-rw-r--r--test/lib/completions/dropuser.exp18
-rw-r--r--test/lib/completions/feh.exp6
-rw-r--r--test/lib/completions/finger.exp4
-rw-r--r--test/lib/completions/flake8.exp18
-rw-r--r--test/lib/completions/freebsd-update.exp18
-rw-r--r--test/lib/completions/function.exp18
-rw-r--r--test/lib/completions/gm.exp27
-rw-r--r--test/lib/completions/gnokii.exp18
-rw-r--r--test/lib/completions/hostname.exp18
-rw-r--r--test/lib/completions/hping3.exp18
-rw-r--r--test/lib/completions/ifdown.exp9
-rw-r--r--test/lib/completions/ifup.exp9
-rw-r--r--test/lib/completions/ip.exp3
-rw-r--r--test/lib/completions/javac.exp3
-rw-r--r--test/lib/completions/jpegoptim.exp18
-rw-r--r--test/lib/completions/jshint.exp18
-rw-r--r--test/lib/completions/kill.exp6
-rw-r--r--test/lib/completions/look.exp2
-rw-r--r--test/lib/completions/ls.exp10
-rw-r--r--test/lib/completions/lz4.exp18
-rw-r--r--test/lib/completions/make.exp38
-rw-r--r--test/lib/completions/man.exp18
-rw-r--r--test/lib/completions/mcrypt.exp4
-rw-r--r--test/lib/completions/mmsitepass.exp2
-rw-r--r--test/lib/completions/mock.exp18
-rw-r--r--test/lib/completions/modinfo.exp7
-rw-r--r--test/lib/completions/modprobe.exp11
-rw-r--r--test/lib/completions/mount.exp81
-rw-r--r--test/lib/completions/mr.exp46
-rw-r--r--test/lib/completions/mysql.exp2
-rw-r--r--test/lib/completions/newgrp.exp18
-rw-r--r--test/lib/completions/newlist.exp2
-rw-r--r--test/lib/completions/openssl.exp3
-rw-r--r--test/lib/completions/optipng.exp18
-rw-r--r--test/lib/completions/pdftotext.exp18
-rw-r--r--test/lib/completions/perl.exp13
-rw-r--r--test/lib/completions/perldoc.exp5
-rw-r--r--test/lib/completions/pine.exp4
-rw-r--r--test/lib/completions/pngfix.exp21
-rw-r--r--test/lib/completions/portsnap.exp18
-rw-r--r--test/lib/completions/puppet.exp3
-rw-r--r--test/lib/completions/pushd.exp18
-rw-r--r--test/lib/completions/py.test.exp21
-rw-r--r--test/lib/completions/pyflakes.exp18
-rw-r--r--test/lib/completions/python.exp24
-rw-r--r--test/lib/completions/pyvenv.exp18
-rw-r--r--test/lib/completions/quotacheck.exp2
-rw-r--r--test/lib/completions/quotaon.exp2
-rw-r--r--test/lib/completions/renice.exp27
-rw-r--r--test/lib/completions/repomanage.exp18
-rw-r--r--test/lib/completions/ri.exp8
-rw-r--r--test/lib/completions/rsync.exp4
-rw-r--r--test/lib/completions/rtcwake.exp2
-rw-r--r--test/lib/completions/scp.exp4
-rw-r--r--test/lib/completions/screen.exp4
-rw-r--r--test/lib/completions/sftp.exp8
-rw-r--r--test/lib/completions/ssh-copy-id.exp8
-rw-r--r--test/lib/completions/ssh-keygen.exp18
-rw-r--r--test/lib/completions/ssh.exp18
-rw-r--r--test/lib/completions/synclient.exp26
-rw-r--r--test/lib/completions/tar.exp118
-rw-r--r--test/lib/completions/timeout.exp21
-rw-r--r--test/lib/completions/tipc.exp18
-rw-r--r--test/lib/completions/udevadm.exp18
-rw-r--r--test/lib/completions/umount.exp83
-rw-r--r--test/lib/completions/unshunt.exp2
-rw-r--r--test/lib/completions/vgcreate.exp2
-rw-r--r--test/lib/completions/wtf.exp2
-rw-r--r--test/lib/completions/zopfli.exp18
-rw-r--r--test/lib/completions/zopflipng.exp18
-rw-r--r--test/lib/library.exp68
-rw-r--r--test/lib/library.sh11
-rw-r--r--test/log/.gitignore1
-rwxr-xr-xtest/run63
-rwxr-xr-xtest/runCompletion8
-rwxr-xr-xtest/runInstall7
-rwxr-xr-xtest/runLint45
-rwxr-xr-xtest/runUnit8
-rw-r--r--test/tmp/.gitignore1
-rw-r--r--test/unit/__expand_tilde_by_ref.exp12
-rw-r--r--test/unit/_filedir.exp95
-rw-r--r--test/unit/_get_cword.exp15
-rw-r--r--test/unit/_known_hosts_real.exp28
-rw-r--r--test/unit/_tilde.exp6
-rw-r--r--test/unit/_variables.exp39
217 files changed, 2154 insertions, 706 deletions
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 00000000..2ea9dc1e
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1,4 @@
+dbg.log
+xtrace.log
+site.exp
+site.bak
diff --git a/test/Makefile.in b/test/Makefile.in
deleted file mode 100644
index 5cdd4f51..00000000
--- a/test/Makefile.in
+++ /dev/null
@@ -1,387 +0,0 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-VPATH = @srcdir@
-am__make_dryrun = \
- { \
- am__dry=no; \
- case $$MAKEFLAGS in \
- *\\[\ \ ]*) \
- echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
- | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
- *) \
- for am__flg in $$MAKEFLAGS; do \
- case $$am__flg in \
- *=*|--*) ;; \
- *n*) am__dry=yes; break;; \
- esac; \
- done;; \
- esac; \
- test $$am__dry = yes; \
- }
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-subdir = test
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-SOURCES =
-DIST_SOURCES =
-am__can_run_installinfo = \
- case $$AM_UPDATE_INFO_DIR in \
- n|no|NO) false;; \
- *) (install-info --version) >/dev/null 2>&1;; \
- esac
-RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
-EXPECT = expect
-RUNTEST = runtest
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-AMTAR = @AMTAR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAKEINFO = @MAKEINFO@
-MKDIR_P = @MKDIR_P@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-am__leading_dot = @am__leading_dot@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build_alias = @build_alias@
-builddir = @builddir@
-compatdir = @compatdir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host_alias = @host_alias@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-DEJATOOL = completion install unit
-AM_RUNTESTFLAGS = --outdir log --ignore $(PACKAGE).log
-EXTRA_DIST = completion \
- config \
- fixtures \
- lib \
- unit
-
-AUTOMAKE_OPTIONS = dejagnu
-all: all-am
-
-.SUFFIXES:
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign test/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-tags: TAGS
-TAGS:
-
-ctags: CTAGS
-CTAGS:
-
-
-check-DEJAGNU: site.exp
- srcdir='$(srcdir)'; export srcdir; \
- EXPECT=$(EXPECT); export EXPECT; \
- runtest=$(RUNTEST); \
- if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
- exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
- if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
- then :; else exit_status=1; fi; \
- done; \
- else echo "WARNING: could not find \`runtest'" 1>&2; :;\
- fi; \
- exit $$exit_status
-site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
- @echo 'Making a new site.exp file...'
- @echo '## these variables are automatically generated by make ##' >site.tmp
- @echo '# Do not edit here. If you wish to override these values' >>site.tmp
- @echo '# edit the last section' >>site.tmp
- @echo 'set srcdir "$(srcdir)"' >>site.tmp
- @echo "set objdir `pwd`" >>site.tmp
- @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
- echo "## Begin content included from file $$f. Do not modify. ##" \
- && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
- && echo "## End content included from file $$f. ##" \
- || exit 1; \
- done >> site.tmp
- @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp
- @if test -f site.exp; then \
- sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \
- fi
- @-rm -f site.bak
- @test ! -f site.exp || mv site.exp site.bak
- @mv site.tmp site.exp
-
-distclean-DEJAGNU:
- -rm -f site.exp site.bak
- -l='$(DEJATOOL)'; for tool in $$l; do \
- rm -f $$tool.sum $$tool.log; \
- done
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
- $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
-check: check-am
-all-am: Makefile
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- if test -z '$(STRIP)'; then \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- install; \
- else \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
- fi
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic mostlyclean-am
-
-distclean: distclean-am
- -rm -f Makefile
-distclean-am: clean-am distclean-DEJAGNU distclean-generic \
- distclean-local
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-generic
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: check-am install-am install-strip
-
-.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
- distclean distclean-DEJAGNU distclean-generic distclean-local \
- distdir dvi dvi-am html html-am info info-am install \
- install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am
-
-
-all:
- $(MKDIR_P) log tmp
-
-distclean-local:
- rm -rf log tmp
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/test/completion/2to3.exp b/test/completion/2to3.exp
new file mode 100644
index 00000000..9efdd77e
--- /dev/null
+++ b/test/completion/2to3.exp
@@ -0,0 +1 @@
+assert_source_completions 2to3
diff --git a/test/completion/7z.exp b/test/completion/7z.exp
new file mode 100644
index 00000000..0796b7a5
--- /dev/null
+++ b/test/completion/7z.exp
@@ -0,0 +1 @@
+assert_source_completions 7z
diff --git a/test/completion/acroread.exp b/test/completion/acroread.exp
index 6ee03d6e..95704601 100644
--- a/test/completion/acroread.exp
+++ b/test/completion/acroread.exp
@@ -1,12 +1,3 @@
-set test "Completion via _filedir_xspec() should be installed"
-set cmd "complete -p acroread"
-send "$cmd\r"
-
-set expected "^$cmd\r\ncomplete -F _filedir_xspec acroread\r\n/@$"
-expect {
- -re $expected { pass "$test" }
- -re /@ { fail "$test at prompt" }
-}; # expect
-
+assert_xspec_completion_installed acroread
source "$::srcdir/lib/completions/acroread.exp"
diff --git a/test/completion/adb.exp b/test/completion/adb.exp
new file mode 100644
index 00000000..0da0ad12
--- /dev/null
+++ b/test/completion/adb.exp
@@ -0,0 +1 @@
+assert_source_completions adb
diff --git a/test/completion/alpine.exp b/test/completion/alpine.exp
new file mode 100644
index 00000000..04ac8b01
--- /dev/null
+++ b/test/completion/alpine.exp
@@ -0,0 +1 @@
+assert_source_completions alpine
diff --git a/test/completion/appdata-validate.exp b/test/completion/appdata-validate.exp
new file mode 100644
index 00000000..5fae5959
--- /dev/null
+++ b/test/completion/appdata-validate.exp
@@ -0,0 +1 @@
+assert_source_completions appdata-validate
diff --git a/test/completion/arch.exp b/test/completion/arch.exp
index 254acd53..25cda56f 100644
--- a/test/completion/arch.exp
+++ b/test/completion/arch.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions arch
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/bind.exp b/test/completion/bind.exp
new file mode 100644
index 00000000..d93003b7
--- /dev/null
+++ b/test/completion/bind.exp
@@ -0,0 +1 @@
+assert_source_completions bind
diff --git a/test/completion/change_pw.exp b/test/completion/change_pw.exp
index 0b152a1c..aed916fb 100644
--- a/test/completion/change_pw.exp
+++ b/test/completion/change_pw.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions change_pw
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/checksec.exp b/test/completion/checksec.exp
new file mode 100644
index 00000000..7e25e898
--- /dev/null
+++ b/test/completion/checksec.exp
@@ -0,0 +1 @@
+assert_source_completions checksec
diff --git a/test/completion/chroot.exp b/test/completion/chroot.exp
new file mode 100644
index 00000000..5cdf8f52
--- /dev/null
+++ b/test/completion/chroot.exp
@@ -0,0 +1 @@
+assert_source_completions chroot
diff --git a/test/completion/cleanarch.exp b/test/completion/cleanarch.exp
index 93646e07..504f6865 100644
--- a/test/completion/cleanarch.exp
+++ b/test/completion/cleanarch.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions cleanarch
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/configure.exp b/test/completion/configure.exp
index cf5611ce..16130d48 100644
--- a/test/completion/configure.exp
+++ b/test/completion/configure.exp
@@ -1 +1 @@
-assert_source_completions configure
+source "$::srcdir/lib/completions/configure.exp"
diff --git a/test/completion/createuser.exp b/test/completion/createuser.exp
new file mode 100644
index 00000000..ad1c24c9
--- /dev/null
+++ b/test/completion/createuser.exp
@@ -0,0 +1 @@
+assert_source_completions createuser
diff --git a/test/completion/declare.exp b/test/completion/declare.exp
new file mode 100644
index 00000000..a62f9891
--- /dev/null
+++ b/test/completion/declare.exp
@@ -0,0 +1 @@
+assert_source_completions declare
diff --git a/test/completion/deja-dup.exp b/test/completion/deja-dup.exp
new file mode 100644
index 00000000..b2dc288d
--- /dev/null
+++ b/test/completion/deja-dup.exp
@@ -0,0 +1 @@
+assert_source_completions deja-dup
diff --git a/test/completion/dropuser.exp b/test/completion/dropuser.exp
new file mode 100644
index 00000000..1be7988a
--- /dev/null
+++ b/test/completion/dropuser.exp
@@ -0,0 +1 @@
+assert_source_completions dropuser
diff --git a/test/completion/dumpdb.exp b/test/completion/dumpdb.exp
index 1bfaecc8..96aee537 100644
--- a/test/completion/dumpdb.exp
+++ b/test/completion/dumpdb.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions dumpdb
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/flake8.exp b/test/completion/flake8.exp
new file mode 100644
index 00000000..8050e8a8
--- /dev/null
+++ b/test/completion/flake8.exp
@@ -0,0 +1 @@
+assert_source_completions flake8
diff --git a/test/completion/freebsd-update.exp b/test/completion/freebsd-update.exp
new file mode 100644
index 00000000..80c35662
--- /dev/null
+++ b/test/completion/freebsd-update.exp
@@ -0,0 +1 @@
+assert_source_completions freebsd-update
diff --git a/test/completion/function.exp b/test/completion/function.exp
new file mode 100644
index 00000000..04c6e2b2
--- /dev/null
+++ b/test/completion/function.exp
@@ -0,0 +1 @@
+assert_source_completions function
diff --git a/test/completion/genaliases.exp b/test/completion/genaliases.exp
index eeee394f..bd33abb3 100644
--- a/test/completion/genaliases.exp
+++ b/test/completion/genaliases.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions genaliases
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/gm.exp b/test/completion/gm.exp
new file mode 100644
index 00000000..82177a28
--- /dev/null
+++ b/test/completion/gm.exp
@@ -0,0 +1 @@
+assert_source_completions gm
diff --git a/test/completion/gnokii.exp b/test/completion/gnokii.exp
new file mode 100644
index 00000000..4cd3055c
--- /dev/null
+++ b/test/completion/gnokii.exp
@@ -0,0 +1 @@
+assert_source_completions gnokii
diff --git a/test/completion/hostname.exp b/test/completion/hostname.exp
new file mode 100644
index 00000000..3c6983ee
--- /dev/null
+++ b/test/completion/hostname.exp
@@ -0,0 +1 @@
+assert_source_completions hostname
diff --git a/test/completion/hping3.exp b/test/completion/hping3.exp
new file mode 100644
index 00000000..5ffb9b06
--- /dev/null
+++ b/test/completion/hping3.exp
@@ -0,0 +1 @@
+assert_source_completions hping3
diff --git a/test/completion/indent.exp b/test/completion/indent.exp
deleted file mode 100644
index 91eae727..00000000
--- a/test/completion/indent.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions indent
diff --git a/test/completion/inject.exp b/test/completion/inject.exp
index c2a18a46..6fcd8093 100644
--- a/test/completion/inject.exp
+++ b/test/completion/inject.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions inject
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/jpegoptim.exp b/test/completion/jpegoptim.exp
new file mode 100644
index 00000000..1d43b944
--- /dev/null
+++ b/test/completion/jpegoptim.exp
@@ -0,0 +1 @@
+assert_source_completions jpegoptim
diff --git a/test/completion/jshint.exp b/test/completion/jshint.exp
new file mode 100644
index 00000000..4416472c
--- /dev/null
+++ b/test/completion/jshint.exp
@@ -0,0 +1 @@
+assert_source_completions jshint
diff --git a/test/completion/kdvi.exp b/test/completion/kdvi.exp
index 9f6aa664..78bd4a94 100644
--- a/test/completion/kdvi.exp
+++ b/test/completion/kdvi.exp
@@ -1 +1,3 @@
-assert_source_completions kdvi
+assert_xspec_completion_installed kdvi
+
+source "$::srcdir/lib/completions/kdvi.exp"
diff --git a/test/completion/kpdf.exp b/test/completion/kpdf.exp
index d0a17749..53417c32 100644
--- a/test/completion/kpdf.exp
+++ b/test/completion/kpdf.exp
@@ -1 +1,3 @@
-assert_source_completions kpdf
+assert_xspec_completion_installed kpdf
+
+source "$::srcdir/lib/completions/kpdf.exp"
diff --git a/test/completion/list_owners.exp b/test/completion/list_owners.exp
index 88262b09..9f6cf03d 100644
--- a/test/completion/list_owners.exp
+++ b/test/completion/list_owners.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions list_owners
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/lz4.exp b/test/completion/lz4.exp
new file mode 100644
index 00000000..9db680ed
--- /dev/null
+++ b/test/completion/lz4.exp
@@ -0,0 +1 @@
+assert_source_completions lz4
diff --git a/test/completion/mailmanctl.exp b/test/completion/mailmanctl.exp
index 2784b27c..58773291 100644
--- a/test/completion/mailmanctl.exp
+++ b/test/completion/mailmanctl.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions mailmanctl
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/mock.exp b/test/completion/mock.exp
new file mode 100644
index 00000000..22910a84
--- /dev/null
+++ b/test/completion/mock.exp
@@ -0,0 +1 @@
+assert_source_completions mock
diff --git a/test/completion/mr.exp b/test/completion/mr.exp
new file mode 100644
index 00000000..85f38ccd
--- /dev/null
+++ b/test/completion/mr.exp
@@ -0,0 +1 @@
+assert_source_completions mr
diff --git a/test/completion/newgrp.exp b/test/completion/newgrp.exp
new file mode 100644
index 00000000..bbd12372
--- /dev/null
+++ b/test/completion/newgrp.exp
@@ -0,0 +1 @@
+assert_source_completions newgrp
diff --git a/test/completion/optipng.exp b/test/completion/optipng.exp
new file mode 100644
index 00000000..b3207543
--- /dev/null
+++ b/test/completion/optipng.exp
@@ -0,0 +1 @@
+assert_source_completions optipng
diff --git a/test/completion/pdftotext.exp b/test/completion/pdftotext.exp
new file mode 100644
index 00000000..d84cee5d
--- /dev/null
+++ b/test/completion/pdftotext.exp
@@ -0,0 +1 @@
+assert_source_completions pdftotext
diff --git a/test/completion/pngfix.exp b/test/completion/pngfix.exp
new file mode 100644
index 00000000..7cea7218
--- /dev/null
+++ b/test/completion/pngfix.exp
@@ -0,0 +1 @@
+assert_source_completions pngfix
diff --git a/test/completion/portsnap.exp b/test/completion/portsnap.exp
new file mode 100644
index 00000000..424004e0
--- /dev/null
+++ b/test/completion/portsnap.exp
@@ -0,0 +1 @@
+assert_source_completions portsnap
diff --git a/test/completion/pushd.exp b/test/completion/pushd.exp
new file mode 100644
index 00000000..44556cdb
--- /dev/null
+++ b/test/completion/pushd.exp
@@ -0,0 +1 @@
+assert_source_completions pushd
diff --git a/test/completion/py.test.exp b/test/completion/py.test.exp
new file mode 100644
index 00000000..8f09927d
--- /dev/null
+++ b/test/completion/py.test.exp
@@ -0,0 +1 @@
+assert_source_completions py.test
diff --git a/test/completion/pyflakes.exp b/test/completion/pyflakes.exp
new file mode 100644
index 00000000..b10445f6
--- /dev/null
+++ b/test/completion/pyflakes.exp
@@ -0,0 +1 @@
+assert_source_completions pyflakes
diff --git a/test/completion/pyvenv.exp b/test/completion/pyvenv.exp
new file mode 100644
index 00000000..ce5c8a62
--- /dev/null
+++ b/test/completion/pyvenv.exp
@@ -0,0 +1 @@
+assert_source_completions pyvenv
diff --git a/test/completion/qrunner.exp b/test/completion/qrunner.exp
index 567dcb4d..e8b30af7 100644
--- a/test/completion/qrunner.exp
+++ b/test/completion/qrunner.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions qrunner
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/repomanage.exp b/test/completion/repomanage.exp
new file mode 100644
index 00000000..79ec53b2
--- /dev/null
+++ b/test/completion/repomanage.exp
@@ -0,0 +1 @@
+assert_source_completions repomanage
diff --git a/test/completion/ssh-keygen.exp b/test/completion/ssh-keygen.exp
new file mode 100644
index 00000000..f074b5a4
--- /dev/null
+++ b/test/completion/ssh-keygen.exp
@@ -0,0 +1 @@
+assert_source_completions ssh-keygen
diff --git a/test/completion/synclient.exp b/test/completion/synclient.exp
new file mode 100644
index 00000000..9a277096
--- /dev/null
+++ b/test/completion/synclient.exp
@@ -0,0 +1 @@
+assert_source_completions synclient
diff --git a/test/completion/timeout.exp b/test/completion/timeout.exp
new file mode 100644
index 00000000..434a291a
--- /dev/null
+++ b/test/completion/timeout.exp
@@ -0,0 +1 @@
+assert_source_completions timeout
diff --git a/test/completion/tipc.exp b/test/completion/tipc.exp
new file mode 100644
index 00000000..51a6a7d7
--- /dev/null
+++ b/test/completion/tipc.exp
@@ -0,0 +1 @@
+assert_source_completions tipc
diff --git a/test/completion/udevadm.exp b/test/completion/udevadm.exp
new file mode 100644
index 00000000..69c980ff
--- /dev/null
+++ b/test/completion/udevadm.exp
@@ -0,0 +1 @@
+assert_source_completions udevadm
diff --git a/test/completion/unshunt.exp b/test/completion/unshunt.exp
index fea1a7a3..9755c784 100644
--- a/test/completion/unshunt.exp
+++ b/test/completion/unshunt.exp
@@ -1 +1,3 @@
+assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/usr/lib/mailman/bin"}
assert_source_completions unshunt
+assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
diff --git a/test/completion/vi.exp b/test/completion/vi.exp
index b0191404..675ea06a 100644
--- a/test/completion/vi.exp
+++ b/test/completion/vi.exp
@@ -1 +1,3 @@
-assert_source_completions vi
+assert_xspec_completion_installed vi
+
+source "$::srcdir/lib/completions/vi.exp"
diff --git a/test/completion/zopfli.exp b/test/completion/zopfli.exp
new file mode 100644
index 00000000..086f78cf
--- /dev/null
+++ b/test/completion/zopfli.exp
@@ -0,0 +1 @@
+assert_source_completions zopfli
diff --git a/test/completion/zopflipng.exp b/test/completion/zopflipng.exp
new file mode 100644
index 00000000..e16a74ab
--- /dev/null
+++ b/test/completion/zopflipng.exp
@@ -0,0 +1 @@
+assert_source_completions zopflipng
diff --git a/test/config/bashrc b/test/config/bashrc
index fd72b816..d16c9033 100644
--- a/test/config/bashrc
+++ b/test/config/bashrc
@@ -4,7 +4,7 @@
set -o emacs
# Use bash strict mode
set -o posix
- # Unset `command_not_found_handle' as defined on Debian/Ubuntu, because this
+ # 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 `/@'
@@ -15,12 +15,21 @@ export PS2='> '
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=dummy
+[ "$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
+ # ...as well as games on some systems not in PATH by default:
+export PATH=$PATH:/usr/games:/usr/local/games
+ # For clean test state, avoid sourcing user's ~/.bash_completion
+export BASH_COMPLETION_USER_FILE=/dev/null
+ # ...and avoid stuff in BASH_COMPLETION_USER_DIR overriding in-tree
+ # completions. The user dir is first in the lookup path, so this should also
+ # give precedence to the in-tree "completions" dir over other ones, e.g.
+ # the one possibly in /usr/share/bash-completion.
+export BASH_COMPLETION_USER_DIR=$(cd "$SRCDIR/.."; pwd)
# Make sure default settings are in effect
unset -v \
@@ -34,8 +43,5 @@ unset -v \
# Local variables:
# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
# End:
-# ex: ts=4 sw=4 et filetype=sh
+# ex: filetype=sh
diff --git a/test/config/default.exp b/test/config/default.exp
index 1eb47a2c..246499b4 100644
--- a/test/config/default.exp
+++ b/test/config/default.exp
@@ -2,20 +2,20 @@
expect_after {
eof {
if {[info exists test]} {
- fail "$test at eof"
+ fail "$test at eof"
} elseif {[info level] > 0} {
- fail "[info level 1] at eof"
+ fail "[info level 1] at eof"
} else {
fail "eof"
- }
- }
+ }
+ }
timeout {
if {[info exists test]} {
- fail "$test at timeout"
+ fail "$test at timeout"
} elseif {[info level] > 0} {
- fail "[info level 1] at timeout"
+ fail "[info level 1] at timeout"
} else {
- fail "timeout"
- }
- }
+ fail "timeout"
+ }
+ }
}
diff --git a/test/config/inputrc b/test/config/inputrc
index 33134da6..5992491a 100644
--- a/test/config/inputrc
+++ b/test/config/inputrc
@@ -14,8 +14,5 @@ set page-completions off
# Local variables:
# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
# End:
-# ex: ts=4 sw=4 et filetype=sh
+# ex: filetype=sh
diff --git a/test/docker/Dockerfile-centos6 b/test/docker/Dockerfile-centos6
new file mode 100644
index 00000000..8686fde4
--- /dev/null
+++ b/test/docker/Dockerfile-centos6
@@ -0,0 +1,18 @@
+FROM centos:6
+
+# 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
+
+WORKDIR /usr/src/bash-completion
+COPY . .
diff --git a/test/docker/Dockerfile-fedoradev b/test/docker/Dockerfile-fedoradev
new file mode 100644
index 00000000..423f836b
--- /dev/null
+++ b/test/docker/Dockerfile-fedoradev
@@ -0,0 +1,41 @@
+FROM fedora:rawhide
+
+# 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
+
+WORKDIR /usr/src/bash-completion
+COPY . .
diff --git a/test/docker/Dockerfile-ubuntu14 b/test/docker/Dockerfile-ubuntu14
new file mode 100644
index 00000000..8db91503
--- /dev/null
+++ b/test/docker/Dockerfile-ubuntu14
@@ -0,0 +1,197 @@
+FROM ubuntu:14.04
+
+# 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
+
+WORKDIR /usr/src/bash-completion
+COPY . .
diff --git a/test/docker/docker-script.sh b/test/docker/docker-script.sh
new file mode 100755
index 00000000..6ba6fa90
--- /dev/null
+++ b/test/docker/docker-script.sh
@@ -0,0 +1,19 @@
+#!/bin/sh -ex
+
+export bashcomp_bash=bash
+env
+
+autoreconf -i
+./configure
+make
+
+make -C completions check
+
+cd test
+xvfb-run ./runCompletion --all
+./runInstall --all
+./runUnit --all
+
+cd ..
+mkdir install-test
+make install DESTDIR=$(pwd)/install-test
diff --git a/test/fixtures/7z/a.7z b/test/fixtures/7z/a.7z
new file mode 100644
index 00000000..33570649
--- /dev/null
+++ b/test/fixtures/7z/a.7z
Binary files differ
diff --git a/test/fixtures/7z/f.txt b/test/fixtures/7z/f.txt
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/test/fixtures/7z/f.txt
@@ -0,0 +1 @@
+
diff --git a/test/fixtures/_filedir/a"b/d b/test/fixtures/_get_cword/sea
index e69de29b..e69de29b 100644
--- a/test/fixtures/_filedir/a"b/d
+++ b/test/fixtures/_get_cword/sea
diff --git a/test/fixtures/make/empty_dir/.nothing_here b/test/fixtures/_get_cword/seb
index e69de29b..e69de29b 100644
--- a/test/fixtures/make/empty_dir/.nothing_here
+++ b/test/fixtures/_get_cword/seb
diff --git a/test/fixtures/man/man3/Bash::Completion.3pm.gz b/test/fixtures/_get_cword/sec
index e69de29b..e69de29b 100644
--- a/test/fixtures/man/man3/Bash::Completion.3pm.gz
+++ b/test/fixtures/_get_cword/sec
diff --git a/test/fixtures/_get_cword/ääää§ b/test/fixtures/_get_cword/ääää§
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/_get_cword/ääää§
diff --git a/test/fixtures/_known_hosts_real/.ssh/config_relative_path b/test/fixtures/_known_hosts_real/.ssh/config_relative_path
new file mode 100644
index 00000000..a7ad4d14
--- /dev/null
+++ b/test/fixtures/_known_hosts_real/.ssh/config_relative_path
@@ -0,0 +1 @@
+Host relative_path
diff --git a/test/fixtures/_known_hosts_real/config b/test/fixtures/_known_hosts_real/config
index 77770ffe..1231dd79 100644
--- a/test/fixtures/_known_hosts_real/config
+++ b/test/fixtures/_known_hosts_real/config
@@ -2,5 +2,6 @@
# Unindented
Host gee jar
+ HostName %h.example.com
# Indented
Host hus # With comment
diff --git a/test/fixtures/_known_hosts_real/config_full_path b/test/fixtures/_known_hosts_real/config_full_path
new file mode 100644
index 00000000..a91649b9
--- /dev/null
+++ b/test/fixtures/_known_hosts_real/config_full_path
@@ -0,0 +1 @@
+Include ~/config_include_recursion
diff --git a/test/fixtures/_known_hosts_real/config_include b/test/fixtures/_known_hosts_real/config_include
new file mode 100644
index 00000000..fe6f537e
--- /dev/null
+++ b/test/fixtures/_known_hosts_real/config_include
@@ -0,0 +1,5 @@
+#$HOME set to fixtures/_known_hosts_real in unit test
+# Include with full path (recursive one)
+Include ~/config_full_path
+# Include with relative path
+Include config_relative_path
diff --git a/test/fixtures/_known_hosts_real/config_include_recursion b/test/fixtures/_known_hosts_real/config_include_recursion
new file mode 100644
index 00000000..27770690
--- /dev/null
+++ b/test/fixtures/_known_hosts_real/config_include_recursion
@@ -0,0 +1 @@
+Host recursion
diff --git a/test/fixtures/ant/.gitignore b/test/fixtures/ant/.gitignore
new file mode 100644
index 00000000..459f1019
--- /dev/null
+++ b/test/fixtures/ant/.gitignore
@@ -0,0 +1,2 @@
+.ant-targets-build.xml
+.ant-targets-named-build.xml
diff --git a/test/fixtures/ant/build-with-import.xml b/test/fixtures/ant/build-with-import.xml
new file mode 100644
index 00000000..881981a5
--- /dev/null
+++ b/test/fixtures/ant/build-with-import.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="build-with-import" name="bash-completion">
+ <import file="imported-build.xml" />
+
+ <target name="build-with-import">
+ <!-- ... -->
+ </target>
+</project>
diff --git a/test/fixtures/ant/build.xml b/test/fixtures/ant/build.xml
index 146c7f3b..09b4cd2a 100644
--- a/test/fixtures/ant/build.xml
+++ b/test/fixtures/ant/build.xml
@@ -8,9 +8,9 @@
<!-- ... -->
</target>
- <target foo="bar" name="init"></target>
+ <target description="bar" name="init"></target>
<target
-foo="bar"
+description="bar"
name='bashcomp' >
<!-- ... -->
</target>
diff --git a/test/fixtures/ant/imported-build.xml b/test/fixtures/ant/imported-build.xml
new file mode 100644
index 00000000..0cc438f0
--- /dev/null
+++ b/test/fixtures/ant/imported-build.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="imported-build" name="bash-completion">
+ <target name="imported-build">
+ <!-- ... -->
+ </target>
+</project>
diff --git a/test/fixtures/ant/named-build.xml b/test/fixtures/ant/named-build.xml
new file mode 100644
index 00000000..e61386d5
--- /dev/null
+++ b/test/fixtures/ant/named-build.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="." default="named-build" name="bash-completion">
+ <target name="named-build">
+ <!-- ... -->
+ </target>
+</project>
diff --git a/test/fixtures/java/no-complete.txt b/test/fixtures/java/no-complete.txt
new file mode 100644
index 00000000..8ca1ef6a
--- /dev/null
+++ b/test/fixtures/java/no-complete.txt
@@ -0,0 +1 @@
+This file should not be included in classpath etc completions.
diff --git a/test/fixtures/make/.gitignore b/test/fixtures/make/.gitignore
new file mode 100644
index 00000000..3d1325c6
--- /dev/null
+++ b/test/fixtures/make/.gitignore
@@ -0,0 +1 @@
+extra_makefile
diff --git a/test/fixtures/make/Makefile b/test/fixtures/make/Makefile
index 1a6416cd..b04a6eb2 100644
--- a/test/fixtures/make/Makefile
+++ b/test/fixtures/make/Makefile
@@ -1,10 +1,15 @@
+$(info confuse: make)
+
+CFLAGS=-MMD -MP
NAME := sample
.PHONY: all
all: $(NAME)
-$(NAME): sample.c
- cc -o $@ $^
+$(NAME): sample.o
+
+.INTERMEDIATE: sample.o
+sample.o: sample.c
.PHONY: install
install: all
@@ -14,3 +19,28 @@ install: all
.PHONY: clean
clean:
-rm -f $(NAME)
+
+.test_passes:
+ ./sample >/dev/null
+ touch ^@
+
+.cache/.1:
+ touch $@
+
+.cache/.2:
+ touch $@
+
+.cache/1:
+ touch $@
+
+.cache/2:
+ touch $@
+
+ifndef __BASH_MAKE_COMPLETION__
+-include sample.d
+endif
+
+VARIABLE_LOOKS_A_BIT_LIKE_A_TARGET := fooled-you
+extra_makefile:
+ touch $@
+include extra_makefile
diff --git a/test/fixtures/make/sample.c b/test/fixtures/make/sample.c
index 2be4600f..4212596a 100644
--- a/test/fixtures/make/sample.c
+++ b/test/fixtures/make/sample.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include "sample.h"
int main(void)
{
diff --git a/test/fixtures/make/sample.d b/test/fixtures/make/sample.d
new file mode 100644
index 00000000..27979ffb
--- /dev/null
+++ b/test/fixtures/make/sample.d
@@ -0,0 +1,3 @@
+sample.o: sample.c sample.h
+
+sample.h:
diff --git a/test/fixtures/make/sample.h b/test/fixtures/make/sample.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/make/sample.h
diff --git a/test/fixtures/perl/Devel/BashCompletion.pm b/test/fixtures/perl/Devel/BashCompletion.pm
new file mode 100644
index 00000000..0afc6045
--- /dev/null
+++ b/test/fixtures/perl/Devel/BashCompletion.pm
@@ -0,0 +1 @@
+1;
diff --git a/test/fixtures/perldoc/BashCompletionDoc.pod b/test/fixtures/perldoc/BashCompletionDoc.pod
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/perldoc/BashCompletionDoc.pod
diff --git a/test/fixtures/perldoc/BashCompletionModule.pm b/test/fixtures/perldoc/BashCompletionModule.pm
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/perldoc/BashCompletionModule.pm
diff --git a/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.ri b/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.ri
new file mode 100644
index 00000000..7263da8c
--- /dev/null
+++ b/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.ri
Binary files differ
diff --git a/test/fixtures/ri/cache.ri b/test/fixtures/ri/cache.ri
new file mode 100644
index 00000000..4a8fc662
--- /dev/null
+++ b/test/fixtures/ri/cache.ri
Binary files differ
diff --git a/test/fixtures/ri/created.rid b/test/fixtures/ri/created.rid
new file mode 100644
index 00000000..ced9a4e0
--- /dev/null
+++ b/test/fixtures/ri/created.rid
@@ -0,0 +1 @@
+Sat, 29 Apr 2017 07:21:09 +0000
diff --git a/test/fixtures/scp/config b/test/fixtures/scp/config
index fea6620e..9f94b9ef 100644
--- a/test/fixtures/scp/config
+++ b/test/fixtures/scp/config
@@ -4,3 +4,5 @@ UserKnownHostsFile known_hosts
Host gee
# Indented, multiple hosts
HostName hus ike
+
+Host hut
diff --git a/test/fixtures/sftp/config b/test/fixtures/sftp/config
index fea6620e..9f94b9ef 100644
--- a/test/fixtures/sftp/config
+++ b/test/fixtures/sftp/config
@@ -4,3 +4,5 @@ UserKnownHostsFile known_hosts
Host gee
# Indented, multiple hosts
HostName hus ike
+
+Host hut
diff --git a/test/fixtures/shared/empty_dir/.nothing_here b/test/fixtures/shared/empty_dir/.nothing_here
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/shared/empty_dir/.nothing_here
diff --git a/test/fixtures/ssh-copy-id/.ssh/id_rsa.pub b/test/fixtures/ssh-copy-id/.ssh/id_rsa.pub
new file mode 100644
index 00000000..4c656eba
--- /dev/null
+++ b/test/fixtures/ssh-copy-id/.ssh/id_rsa.pub
@@ -0,0 +1 @@
+ssh-rsa meh comment
diff --git a/test/fixtures/tar/archive.tar.xz b/test/fixtures/tar/archive.tar.xz
new file mode 100644
index 00000000..c8d27256
--- /dev/null
+++ b/test/fixtures/tar/archive.tar.xz
Binary files differ
diff --git a/test/fixtures/tar/dir/fileA b/test/fixtures/tar/dir/fileA
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/tar/dir/fileA
diff --git a/test/fixtures/tar/dir/fileB b/test/fixtures/tar/dir/fileB
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/tar/dir/fileB
diff --git a/test/fixtures/tar/dir/fileC b/test/fixtures/tar/dir/fileC
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/tar/dir/fileC
diff --git a/test/fixtures/tar/dir/hello b/test/fixtures/tar/dir/hello
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/tar/dir/hello
diff --git a/test/fixtures/tar/dir2/.nothing_here b/test/fixtures/tar/dir2/.nothing_here
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/tar/dir2/.nothing_here
diff --git a/test/fixtures/tar/escape.tar b/test/fixtures/tar/escape.tar
new file mode 100644
index 00000000..7af7e9f2
--- /dev/null
+++ b/test/fixtures/tar/escape.tar
Binary files differ
diff --git a/test/generate b/test/generate
new file mode 100755
index 00000000..deeba05a
--- /dev/null
+++ b/test/generate
@@ -0,0 +1,64 @@
+#!/bin/bash -eu
+# Generate skeleton files for completion of specified command.
+# Test skeleton files are generated as well.
+# @param $1 string Command, e.g. 'make'
+# @param $2 string Completion function, e.g. _command
+# @param $3 string Completion arguments, e.g. '-o filenames'
+
+
+# Generate test code
+# @param $1 string Command, e.g. 'make'
+generate_test_completion() {
+ local path="completion/$1.exp"
+ # Does file already exist?
+ #if [ ! -f "$path" ]; then
+ # No, file doesn't exist; generate file
+ cat <<EXPECT > "$path"
+assert_source_completions $1
+EXPECT
+ #fi
+} # generate_test_completion()
+
+
+# Generate test code
+# @param $1 string Command, e.g. 'make'
+# @param $2 string Completion function, e.g. _command
+# @param $3 string Completion arguments, e.g. ' -o filenames'
+generate_test_lib_completions() {
+ local path="lib/completions/$1.exp"
+ # Does file already exist?
+ #if [ ! -f "$path" ]; then
+ # No, file doesn't exist; generate file
+ cat <<EXPECT > "$path"
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "$1 "
+sync_after_int
+
+
+teardown
+EXPECT
+ #fi
+} # generate_test_lib_completions()
+
+
+ # If argument count is wrong, show help
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 command"
+ echo "Example: $0 make"
+ exit 1
+fi
+
+generate_test_completion "$1"
+generate_test_lib_completions "$1"
diff --git a/test/lib/completions/indent.exp b/test/lib/completions/2to3.exp
index 5c5bb1c7..101fbf87 100644
--- a/test/lib/completions/indent.exp
+++ b/test/lib/completions/2to3.exp
@@ -11,9 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "indent --"
-
-
+assert_complete_any "2to3 "
sync_after_int
diff --git a/test/lib/completions/7z.exp b/test/lib/completions/7z.exp
new file mode 100644
index 00000000..4e7e8689
--- /dev/null
+++ b/test/lib/completions/7z.exp
@@ -0,0 +1,37 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified {/OLDPWD=/d}
+}
+
+
+setup
+
+
+assert_complete_any "7z "
+sync_after_int
+
+
+assert_complete "-tzip" "7z a ar -tzi"
+sync_after_int
+
+
+set dir $::srcdir/fixtures/_filedir
+assert_complete_dir "-wa\\ b/" "7z x -wa\\ " $dir "" -nospace
+sync_after_int
+
+
+set dir $::srcdir/fixtures/7z
+assert_complete_dir "a.7z" "7z x " $dir
+sync_after_int
+
+
+set dir $::srcdir/fixtures/7z
+assert_complete_dir "abc" "7z d a.7z " $dir
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/abook.exp b/test/lib/completions/abook.exp
index 43f62729..463a28c0 100644
--- a/test/lib/completions/abook.exp
+++ b/test/lib/completions/abook.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "abook "
+assert_complete_any "abook -"
sync_after_int
diff --git a/test/lib/completions/adb.exp b/test/lib/completions/adb.exp
new file mode 100644
index 00000000..0d41fd2d
--- /dev/null
+++ b/test/lib/completions/adb.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "adb "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/alpine.exp b/test/lib/completions/alpine.exp
new file mode 100644
index 00000000..5ae1901c
--- /dev/null
+++ b/test/lib/completions/alpine.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "alpine -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ant.exp b/test/lib/completions/ant.exp
index acff23ec..bcf87711 100644
--- a/test/lib/completions/ant.exp
+++ b/test/lib/completions/ant.exp
@@ -6,6 +6,7 @@ proc setup {} {
proc teardown {} {
assert_env_unmodified {
/OLDPWD=/d
+ /ANT_ARGS=/d
}
}
@@ -21,4 +22,18 @@ assert_complete_dir "bashcomp clean init realclean" "ant " $::srcdir/fixtures/an
sync_after_int
+assert_complete_dir "named-build" "ant -f named-build.xml " $::srcdir/fixtures/ant
+sync_after_int
+
+
+assert_complete_dir "build-with-import imported-build" "ant -f build-with-import.xml " $::srcdir/fixtures/ant
+sync_after_int
+
+
+assert_bash_exec {OLD_ANT_ARGS=$ANT_ARGS; ANT_ARGS="-f named-build.xml"}
+assert_complete_dir "named-build" "ant " $::srcdir/fixtures/ant "ant with buildfile from ANT_ARGS"
+sync_after_int
+assert_bash_exec {ANT_ARGS=$OLD_ANT_ARGS; unset -v OLD_ANT_ARGS}
+
+
teardown
diff --git a/test/lib/completions/appdata-validate.exp b/test/lib/completions/appdata-validate.exp
new file mode 100644
index 00000000..583c2952
--- /dev/null
+++ b/test/lib/completions/appdata-validate.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "appdata-validate "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/apt-get.exp b/test/lib/completions/apt-get.exp
index 66887bd0..270d6fe8 100644
--- a/test/lib/completions/apt-get.exp
+++ b/test/lib/completions/apt-get.exp
@@ -11,11 +11,14 @@ proc teardown {} {
setup
-set commands {autoclean autoremove build-dep check clean dist-upgrade
- dselect-upgrade install purge remove source update upgrade}
-assert_complete $commands "apt-get "
-
-
+set test "Tab should complete commands"
+set cmd "apt-get "
+send "$cmd\t"
+set expected "^$cmd\r\n.* install .* update .*\r\n/@$cmd$"
+expect {
+ -re $expected { pass "$test" }
+ default { fail "$test" }
+}
sync_after_int
diff --git a/test/lib/completions/arch.exp b/test/lib/completions/arch.exp
index 0550c76b..5bad0e60 100644
--- a/test/lib/completions/arch.exp
+++ b/test/lib/completions/arch.exp
@@ -11,10 +11,7 @@ proc teardown {} {
setup
-set options {--wipe -s --start= -e --end= -q --quiet -h --help}
-assert_complete $options "arch -"
-
-
+assert_complete_any "arch -"
sync_after_int
diff --git a/test/lib/completions/bind.exp b/test/lib/completions/bind.exp
new file mode 100644
index 00000000..09bbaaa1
--- /dev/null
+++ b/test/lib/completions/bind.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "bind -"
+sync_after_int
+
+assert_complete_any "bind k"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/bts.exp b/test/lib/completions/bts.exp
new file mode 100644
index 00000000..38b92b9d
--- /dev/null
+++ b/test/lib/completions/bts.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "bts -"
+sync_after_int
+
+assert_complete "bts "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ccache.exp b/test/lib/completions/ccache.exp
index 156c881a..7cb3103e 100644
--- a/test/lib/completions/ccache.exp
+++ b/test/lib/completions/ccache.exp
@@ -15,4 +15,29 @@ assert_complete_any "ccache -"
sync_after_int
+set test "Tab should offer correct options from partial option"
+assert_complete_partial [list "--cleanup" "--clear"] "ccache" "--clea" $test
+sync_after_int
+
+
+set test "Tab should complete a command after ccache"
+assert_complete [list "stty"] "ccache stt" $test
+sync_after_int
+
+
+set test "Tab should complete a command after ccache --FLAG"
+assert_complete [list "stty"] "ccache --zero-stats stt" $test
+sync_after_int
+
+
+set test "Tab should complete a command's flags after ccache"
+assert_complete [list "--help"] "ccache ls --hel" $test
+sync_after_int
+
+
+set test "Tab should complete a command's flags after ccache --FLAG"
+assert_complete [list "--help"] "ccache --zero-stats ls --hel" $test
+sync_after_int
+
+
teardown
diff --git a/test/lib/completions/cd.exp b/test/lib/completions/cd.exp
index 55bae158..6f36c881 100644
--- a/test/lib/completions/cd.exp
+++ b/test/lib/completions/cd.exp
@@ -4,7 +4,7 @@ proc setup {} {
proc teardown {} {
- assert_env_unmodified
+ assert_env_unmodified {/OLDPWD=/d}
}
@@ -42,7 +42,15 @@ assert_bash_exec "CDPATH=\$PWD";
assert_complete "$::srcdir/fixtures/shared/default/foo.d/" \
"cd $::srcdir/fixtures/shared/default/fo" $test -nospace -expect-cmd-minus fo
sync_after_int
- # Reset CDPATH
+
+assert_bash_exec "unset CDPATH"
+# Assuming no subdirs here
+assert_bash_exec "cd $::srcdir/fixtures/shared/default/foo.d"
+assert_no_complete "cd " "cd shouldn't complete when there are no subdirs or CDPATH"
+sync_after_int
+
+ # Reset PWD and CDPATH
+assert_bash_exec "cd \"\$OLDPWD\""
assert_bash_exec "declare -p OLDCDPATH &>/dev/null && CDPATH=\$OLDCDPATH || unset CDPATH && unset OLDCDPATH"
diff --git a/test/lib/completions/checksec.exp b/test/lib/completions/checksec.exp
new file mode 100644
index 00000000..03abd575
--- /dev/null
+++ b/test/lib/completions/checksec.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "checksec -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/chkconfig.exp b/test/lib/completions/chkconfig.exp
index dae3b3bd..1714144d 100644
--- a/test/lib/completions/chkconfig.exp
+++ b/test/lib/completions/chkconfig.exp
@@ -11,9 +11,16 @@ proc teardown {} {
setup
-assert_complete_any "chkconfig "
+assert_complete_any "chkconfig -"
+sync_after_int
+# systemd may not be running e.g. in a docker container, and listing services
+# will then fail.
+if {[assert_exec {systemctl list-units} "" "" "unsupported" ]} {
+ # TODO test this also if systemctl command is not available at all
+ assert_complete_any "chkconfig "
+}
sync_after_int
diff --git a/test/lib/completions/chroot.exp b/test/lib/completions/chroot.exp
new file mode 100644
index 00000000..ba9f63a1
--- /dev/null
+++ b/test/lib/completions/chroot.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "chroot "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/configure.exp b/test/lib/completions/configure.exp
index b4399cb1..1be8e167 100644
--- a/test/lib/completions/configure.exp
+++ b/test/lib/completions/configure.exp
@@ -1,19 +1,23 @@
proc setup {} {
+ # Make sure our own ./configure is in PATH
+ assert_bash_exec {OLDPATH="$PATH"; PATH="$SRCDIR/..:$PATH"}
save_env
}
proc teardown {} {
assert_env_unmodified
+ assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
}
setup
-assert_complete_any "configure --prefix "
-
+assert_complete_any "configure --"
+sync_after_int
+assert_complete_any "configure --prefix "
sync_after_int
diff --git a/test/lib/completions/createdb.exp b/test/lib/completions/createdb.exp
index aafff1b6..234817f9 100644
--- a/test/lib/completions/createdb.exp
+++ b/test/lib/completions/createdb.exp
@@ -11,9 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "createdb "
-
-
+assert_complete_any "createdb -"
sync_after_int
diff --git a/test/lib/completions/createuser.exp b/test/lib/completions/createuser.exp
new file mode 100644
index 00000000..87d4ac87
--- /dev/null
+++ b/test/lib/completions/createuser.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "createuser -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/curl.exp b/test/lib/completions/curl.exp
index 53512bc4..e05c023e 100644
--- a/test/lib/completions/curl.exp
+++ b/test/lib/completions/curl.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "curl -"
+assert_complete_any "curl --h"
sync_after_int
diff --git a/test/lib/completions/dcop.exp b/test/lib/completions/dcop.exp
index 1e27346b..dcff2802 100644
--- a/test/lib/completions/dcop.exp
+++ b/test/lib/completions/dcop.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-if {[assert_exec {dcop} words]} {
+if {[assert_exec {dcop} words "" "untested"]} {
assert_complete $words "dcop "
}
diff --git a/test/lib/completions/dd.exp b/test/lib/completions/dd.exp
index e02e037c..4946e54d 100644
--- a/test/lib/completions/dd.exp
+++ b/test/lib/completions/dd.exp
@@ -18,7 +18,7 @@ sync_after_int
set test "option should be suffixed with ="
-set cmd "dd if"
+set cmd "dd bs"
send "$cmd\t"
expect -ex "$cmd"
expect {
diff --git a/test/lib/completions/declare.exp b/test/lib/completions/declare.exp
new file mode 100644
index 00000000..8830b676
--- /dev/null
+++ b/test/lib/completions/declare.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "declare -"
+sync_after_int
+
+assert_complete_any "declare +"
+sync_after_int
+
+assert_complete {BASH_ARGC BASH_ARGV} "declare -p BASH_ARG"
+sync_after_int
+
+assert_complete_any "declare -f _parse_"
+sync_after_int
+
+teardown
diff --git a/test/lib/completions/deja-dup.exp b/test/lib/completions/deja-dup.exp
new file mode 100644
index 00000000..d46549cf
--- /dev/null
+++ b/test/lib/completions/deja-dup.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "deja-dup -"
+sync_after_int
+
+assert_no_complete "deja-dup --help "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/dpkg.exp b/test/lib/completions/dpkg.exp
index f358e172..0ea6ded3 100644
--- a/test/lib/completions/dpkg.exp
+++ b/test/lib/completions/dpkg.exp
@@ -12,17 +12,23 @@ setup
assert_complete_any "dpkg --c"
-
-
sync_after_int
- # Build list of installed packages
-if {[assert_exec {dpkg --get-selections | command grep \[\[:space:\]\]install$ | cut -f1} packages]} {
+# Build list of installed packages
+if {[assert_exec {dpkg --get-selections | command grep \[\[:space:\]\]install$ | cut -f1} packages "" "untested"]} {
assert_complete $packages "dpkg -L "
}
+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
sync_after_int
diff --git a/test/lib/completions/dropdb.exp b/test/lib/completions/dropdb.exp
index 8f2d5bfb..d68cd48a 100644
--- a/test/lib/completions/dropdb.exp
+++ b/test/lib/completions/dropdb.exp
@@ -11,9 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "dropdb "
-
-
+assert_complete_any "dropdb -"
sync_after_int
diff --git a/test/lib/completions/dropuser.exp b/test/lib/completions/dropuser.exp
new file mode 100644
index 00000000..8b36fa5e
--- /dev/null
+++ b/test/lib/completions/dropuser.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "dropuser "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/feh.exp b/test/lib/completions/feh.exp
index 129e1f4d..28e90d99 100644
--- a/test/lib/completions/feh.exp
+++ b/test/lib/completions/feh.exp
@@ -17,8 +17,10 @@ assert_complete_any "feh "
sync_after_int
-set test "--lis<TAB> should complete \"--list\""
-assert_complete "--list" "feh --lis" $test
+if {[assert_exec {feh --help | grep "man feh" || exit 1} "" "" "unsupported"]} {
+ set test "--lis<TAB> should complete \"--list\""
+ assert_complete "--list" "feh --lis" $test
+}
sync_after_int
diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp
index f11d11fe..5a3d3e9e 100644
--- a/test/lib/completions/finger.exp
+++ b/test/lib/completions/finger.exp
@@ -14,7 +14,7 @@ setup
set test "Tab should complete usernames"
# Build string list of usernames
set users {}
-foreach u [exec bash -c "compgen -A user"] {
+foreach u [exec bash -c "compgen -A user -S @"] {
lappend users $u
}
assert_complete $users "finger " $test
@@ -24,7 +24,7 @@ sync_after_int
set test "Tab should complete partial username"
-assert_complete_partial [exec bash -c "compgen -A user"] "finger" "" $test -nospace
+assert_complete_partial [exec bash -c "compgen -A user -S @"] "finger" "" $test -nospace
sync_after_int
diff --git a/test/lib/completions/flake8.exp b/test/lib/completions/flake8.exp
new file mode 100644
index 00000000..469f96ed
--- /dev/null
+++ b/test/lib/completions/flake8.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "flake8 "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/freebsd-update.exp b/test/lib/completions/freebsd-update.exp
new file mode 100644
index 00000000..3657ebfd
--- /dev/null
+++ b/test/lib/completions/freebsd-update.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "freebsd-update "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/function.exp b/test/lib/completions/function.exp
new file mode 100644
index 00000000..823811f1
--- /dev/null
+++ b/test/lib/completions/function.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "function _parse_"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gm.exp b/test/lib/completions/gm.exp
new file mode 100644
index 00000000..43f0bce2
--- /dev/null
+++ b/test/lib/completions/gm.exp
@@ -0,0 +1,27 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "gm "
+sync_after_int
+
+assert_complete_any "gm help "
+sync_after_int
+
+assert_complete_any "gm time "
+sync_after_int
+
+assert_no_complete "gm version "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/gnokii.exp b/test/lib/completions/gnokii.exp
new file mode 100644
index 00000000..11bfeb6c
--- /dev/null
+++ b/test/lib/completions/gnokii.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "gnokii "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/hostname.exp b/test/lib/completions/hostname.exp
new file mode 100644
index 00000000..9d9e4963
--- /dev/null
+++ b/test/lib/completions/hostname.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "hostname -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/hping3.exp b/test/lib/completions/hping3.exp
new file mode 100644
index 00000000..991ee3ad
--- /dev/null
+++ b/test/lib/completions/hping3.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "hping3 "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ifdown.exp b/test/lib/completions/ifdown.exp
index 7849f3f7..7341ceb8 100644
--- a/test/lib/completions/ifdown.exp
+++ b/test/lib/completions/ifdown.exp
@@ -11,9 +11,14 @@ proc teardown {} {
setup
-assert_complete_any "ifdown "
-
+if {[info exists ::env(CI)]} {
+ unsupported "ifdown should show completions"
+} else {
+ assert_complete_any "ifdown "
+ sync_after_int
+}
+assert_no_complete "ifdown bash-completion "
sync_after_int
diff --git a/test/lib/completions/ifup.exp b/test/lib/completions/ifup.exp
index 2c1c010e..31b5ade4 100644
--- a/test/lib/completions/ifup.exp
+++ b/test/lib/completions/ifup.exp
@@ -11,9 +11,14 @@ proc teardown {} {
setup
-assert_complete_any "ifup "
-
+if {[info exists ::env(CI)]} {
+ unsupported "ifup should show completions"
+} else {
+ assert_complete_any "ifup "
+ sync_after_int
+}
+assert_no_complete "ifup bash-completion "
sync_after_int
diff --git a/test/lib/completions/ip.exp b/test/lib/completions/ip.exp
index 8f45f6a3..f57712cb 100644
--- a/test/lib/completions/ip.exp
+++ b/test/lib/completions/ip.exp
@@ -12,8 +12,9 @@ setup
assert_complete_any "ip "
+sync_after_int
-
+assert_complete_any "ip a "
sync_after_int
diff --git a/test/lib/completions/javac.exp b/test/lib/completions/javac.exp
index 948fe8c8..83b11d7f 100644
--- a/test/lib/completions/javac.exp
+++ b/test/lib/completions/javac.exp
@@ -12,8 +12,9 @@ setup
assert_complete_any "javac "
+sync_after_int
-
+assert_complete "a/ bashcomp.jar" "javac -cp $::srcdir/fixtures/java/"
sync_after_int
diff --git a/test/lib/completions/jpegoptim.exp b/test/lib/completions/jpegoptim.exp
new file mode 100644
index 00000000..4b735e80
--- /dev/null
+++ b/test/lib/completions/jpegoptim.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "jpegoptim "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/jshint.exp b/test/lib/completions/jshint.exp
new file mode 100644
index 00000000..553883e1
--- /dev/null
+++ b/test/lib/completions/jshint.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "jshint "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/kill.exp b/test/lib/completions/kill.exp
index bc07bc48..9aeb8412 100644
--- a/test/lib/completions/kill.exp
+++ b/test/lib/completions/kill.exp
@@ -11,8 +11,10 @@ proc teardown {} {
setup
-assert_complete_any "kill 1"
-sync_after_int
+if {[assert_bash_type ps]} {
+ assert_complete_any "kill 1"
+ sync_after_int
+}
assert_complete [get_signals] "kill -s "
diff --git a/test/lib/completions/look.exp b/test/lib/completions/look.exp
index 8f93db24..af9a71a8 100644
--- a/test/lib/completions/look.exp
+++ b/test/lib/completions/look.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-if {[assert_exec {look foo | grep ^foo} words]} {
+if {[assert_exec {look foo | grep ^foo} words {} "unsupported"]} {
assert_complete $words "look foo"
}
diff --git a/test/lib/completions/ls.exp b/test/lib/completions/ls.exp
index 0d16ec03..e176e13f 100644
--- a/test/lib/completions/ls.exp
+++ b/test/lib/completions/ls.exp
@@ -14,30 +14,24 @@ setup
if {[assert_exec {ls --help} "" "" "unsupported"]} {
assert_complete_any "ls --"
}
-
-
sync_after_int
-set test "~part should complete to ~full/ if existing dir"
+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
-
-
sync_after_int
-set test "~part should complete to ~full<space> if non-existing dir"
+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
-
-
sync_after_int
diff --git a/test/lib/completions/lz4.exp b/test/lib/completions/lz4.exp
new file mode 100644
index 00000000..df392939
--- /dev/null
+++ b/test/lib/completions/lz4.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "lz4 "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/make.exp b/test/lib/completions/make.exp
index 977485d2..0c188dba 100644
--- a/test/lib/completions/make.exp
+++ b/test/lib/completions/make.exp
@@ -18,18 +18,50 @@ assert_complete_dir "Makefile" "make -f Ma" $dir $test
sync_after_int
-
set test "\"make <TAB>\" should complete targets"
set dir $::srcdir/fixtures/make
-set targets "all sample install clean"
+set targets "all sample install clean extra_makefile"
+file delete $dir/extra_makefile
assert_complete_dir $targets "make " $dir $test
sync_after_int
+set test "\"make .<TAB>\" should complete hidden targets"
+set dir $::srcdir/fixtures/make
+set targets ".test_passes .cache/"
+assert_complete_dir $targets "make ." $dir $test
+
+
+sync_after_int
+
+
+set test "\"make .cache/<TAB>\" should complete targets"
+set dir $::srcdir/fixtures/make
+set targets "1 2"
+assert_complete_dir $targets "make .cache/" $dir $test
+
+
+sync_after_int
+
+
+# FIXME: for some reason this fails in centos6, even though the behavior
+# appears to be correct; skip in CI for now.
+set test "\"make .cache/.<TAB>\" should complete hidden targets"
+if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} {
+ xfail $test
+} else {
+ set dir $::srcdir/fixtures/make
+ set targets ".1 .2"
+ assert_complete_dir $targets "make .cache/." $dir $test \
+ -expect-cmd-minus "."
+ sync_after_int
+}
+
+
set test "\"make <TAB>\" should not show anything in directory without makefile"
-set dir $::srcdir/fixtures/make/empty_dir
+set dir $::srcdir/fixtures/shared/empty_dir
assert_complete_dir "" "make " $dir $test
diff --git a/test/lib/completions/man.exp b/test/lib/completions/man.exp
index 66b565a2..1a031ff1 100644
--- a/test/lib/completions/man.exp
+++ b/test/lib/completions/man.exp
@@ -1,11 +1,19 @@
proc setup {} {
- assert_bash_exec "export MANPATH=$::srcdirabs/fixtures/man"
+ assert_bash_exec "export MANPATH=$::srcdirabs/fixtures/man:$::srcdirabs/tmp/man"
save_env
+
+ if {! [is_cygwin]} { # Colon not allowed in filenames
+ assert_bash_exec {(cd $TESTDIR/tmp && mkdir -p man/man3 && touch man/man3/Bash::Completion.3pm.gz || true)}
+ }
}
proc teardown {} {
assert_env_unmodified {/OLDPWD/d}
+
+ if {! [is_cygwin]} {
+ assert_bash_exec {(cd $TESTDIR/tmp && rm -r man || true)}
+ }
}
@@ -24,10 +32,10 @@ assert_complete_dir oo.1 "man man1/f" $::srcdir/fixtures/man
sync_after_int
-assert_complete "Bash::Completion" "man Bash::C"
-
-
-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
diff --git a/test/lib/completions/mcrypt.exp b/test/lib/completions/mcrypt.exp
index 525ccbc3..e194446b 100644
--- a/test/lib/completions/mcrypt.exp
+++ b/test/lib/completions/mcrypt.exp
@@ -12,8 +12,12 @@ setup
assert_complete_any "mcrypt "
+sync_after_int
+assert_complete_any "mcrypt -a "
+sync_after_int
+assert_complete_any "mcrypt -m "
sync_after_int
diff --git a/test/lib/completions/mmsitepass.exp b/test/lib/completions/mmsitepass.exp
index 4dde214f..70d2a126 100644
--- a/test/lib/completions/mmsitepass.exp
+++ b/test/lib/completions/mmsitepass.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "mmsitepass "
+assert_complete_any "mmsitepass -"
sync_after_int
diff --git a/test/lib/completions/mock.exp b/test/lib/completions/mock.exp
new file mode 100644
index 00000000..8190264a
--- /dev/null
+++ b/test/lib/completions/mock.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "mock "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/modinfo.exp b/test/lib/completions/modinfo.exp
index bd8f965c..90e9702a 100644
--- a/test/lib/completions/modinfo.exp
+++ b/test/lib/completions/modinfo.exp
@@ -11,8 +11,11 @@ proc teardown {} {
setup
-set test "in<TAB> should complete modulename"
-assert_complete_any "modinfo in" $test
+set uname [exec bash -c "uname -r"]
+if {[assert_exec "ls /lib/modules/$uname" "" "" "unsupported"]} {
+ set test "in<TAB> should complete modulename"
+ assert_complete_any "modinfo in" $test
+}
sync_after_int
diff --git a/test/lib/completions/modprobe.exp b/test/lib/completions/modprobe.exp
index a1cd6987..b0a530ef 100644
--- a/test/lib/completions/modprobe.exp
+++ b/test/lib/completions/modprobe.exp
@@ -11,15 +11,18 @@ proc teardown {} {
setup
-set test "--remov<TAB> should complete \"--remove\""
-assert_complete "--remove" "modprobe --remov" $test
+set test "--al<TAB> should complete \"--all\""
+assert_complete "--all" "modprobe --al" $test
sync_after_int
-set test "in<TAB> should complete modulename"
-assert_complete_any "modprobe in" $test
+set uname [exec bash -c "uname -r"]
+if {[assert_exec "ls /lib/modules/$uname" "" "" "unsupported"]} {
+ set test "in<TAB> should complete modulename"
+ assert_complete_any "modprobe in" $test
+}
sync_after_int
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
index 1298f36f..fea99b85 100644
--- a/test/lib/completions/mount.exp
+++ b/test/lib/completions/mount.exp
@@ -1,35 +1,9 @@
-# mount completion from fstab can't be tested directly because it
-# (correctly) uses absolute paths. So we create a custom completion which
-# reads from a file in our text fixture instead.
-proc setup_dummy_mnt {} {
- assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _mnt}
-
- assert_bash_exec { \
- _mnt() { \
- local cur=$(_get_cword); \
- _linux_fstab $(_get_pword) < "$SRCDIRABS/fixtures/mount/test-fstab"; \
- }; \
- complete -F _mnt mnt \
- }
-}
-
-
-proc teardown_dummy_mnt {} {
- assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _mnt}
- assert_bash_exec {complete -r mnt}
-}
-
-
proc setup {} {
save_env
- setup_dummy_mnt
}
proc teardown {} {
- teardown_dummy_mnt
assert_env_unmodified {/OLDPWD/d}
}
@@ -69,59 +43,4 @@ assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
sync_after_int
-set test "Testing internal __linux_fstab_unescape function for mount"
-# One round of slashes is for bash.
-assert_bash_exec {var=one\'two\\040three\\}
-assert_bash_exec {__linux_fstab_unescape var}
-set cmd {echo $var}
-send "$cmd\r"
-expect {
- -ex "$cmd\r\none'two three\\" { pass $test }
-# default { fail $test }
-}
-sync_after_int
-assert_bash_exec {unset var}
-
-
-sync_after_int
-
-
-# Begin testing through mnt (see setup_dummy_mnt).
-assert_complete {/mnt/nice-test-path} {mnt /mnt/nice-test-p}
-sync_after_int
-
-assert_complete {/mnt/nice\ test-path} {mnt /mnt/nice\ test-p}
-sync_after_int
-
-assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$test-p}
-sync_after_int
-
-assert_complete {/mnt/nice\ test\\path} {mnt /mnt/nice\ test\\p}
-sync_after_int
-
-assert_complete {{/mnt/nice\ test\\path} {/mnt/nice\ test-path}} \
- {mnt /mnt/nice\ } "" -expect-cmd-minus {/mnt/nice\ }
-sync_after_int
-
-assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$}
-sync_after_int
-
-assert_complete {/mnt/nice\'test-path} {mnt /mnt/nice\'}
-sync_after_int
-
-assert_complete {/mnt/other\'test\ path} {mnt /mnt/other}
-sync_after_int
-
-assert_complete {Ubuntu\ Karmic} {mnt -L Ubu}
-sync_after_int
-
-assert_complete {Debian-it\'s\ awesome} {mnt -L Deb}
-sync_after_int
-
-# This does not work. Proper support for this requires smarter parsing of
-# $COMP_LINE and it's not worth doing just for mount.
-#assert_complete {$'/mnt/nice\ntest-path'} {mnt $'/mnt/nice\n}
-#sync_after_int
-
-
teardown
diff --git a/test/lib/completions/mr.exp b/test/lib/completions/mr.exp
new file mode 100644
index 00000000..d7d41bb6
--- /dev/null
+++ b/test/lib/completions/mr.exp
@@ -0,0 +1,46 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+setup
+
+assert_complete_any "mr "
+sync_after_int
+
+# Some versions require man to be around for useful output.
+if {[assert_exec {man -h} "" "" "unsupported"]} {
+
+ assert_complete_any "mr --"
+ sync_after_int
+
+ assert_complete {"foo"} "mr -c $::srcdir/fixtures/shared/default/foo.d/"
+ sync_after_int
+
+ assert_complete {"bar bar.d/" "foo.d/"} "mr -d $::srcdir/fixtures/shared/default/"
+ sync_after_int
+
+ assert_complete {"bar" "bar bar.d/" "foo" "foo.d/"} "mr bootstrap $::srcdir/fixtures/shared/default/"
+ sync_after_int
+
+ # Disabled for now; "clean" doesn't exist before mr 1.20141023
+ #assert_complete "-f" "mr clean -"
+ #sync_after_int
+
+ assert_complete "-m" "mr commit -"
+ sync_after_int
+
+ assert_no_complete "mr status "
+ sync_after_int
+
+ # Disabled temporarily: suggesting all commands produces too much output for
+ # test suite.
+ #assert_complete_any "mr run "
+ #sync_after_int
+}
+
+teardown
diff --git a/test/lib/completions/mysql.exp b/test/lib/completions/mysql.exp
index 62a64fc2..b7a50b81 100644
--- a/test/lib/completions/mysql.exp
+++ b/test/lib/completions/mysql.exp
@@ -12,8 +12,10 @@ setup
assert_complete_any "mysql --"
+sync_after_int
+assert_complete_any "mysql --default-character-set="
sync_after_int
diff --git a/test/lib/completions/newgrp.exp b/test/lib/completions/newgrp.exp
new file mode 100644
index 00000000..a5cddb8c
--- /dev/null
+++ b/test/lib/completions/newgrp.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "newgrp "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/newlist.exp b/test/lib/completions/newlist.exp
index 0696ec5e..dfabdc50 100644
--- a/test/lib/completions/newlist.exp
+++ b/test/lib/completions/newlist.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "newlist "
+assert_complete_any "newlist -"
sync_after_int
diff --git a/test/lib/completions/openssl.exp b/test/lib/completions/openssl.exp
index d1357002..3adbbae7 100644
--- a/test/lib/completions/openssl.exp
+++ b/test/lib/completions/openssl.exp
@@ -28,5 +28,8 @@ sync_after_int
assert_complete_any "openssl pkey -cipher "
sync_after_int
+assert_complete_any "openssl dgst -s"
+sync_after_int
+
teardown
diff --git a/test/lib/completions/optipng.exp b/test/lib/completions/optipng.exp
new file mode 100644
index 00000000..0a079190
--- /dev/null
+++ b/test/lib/completions/optipng.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "optipng "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pdftotext.exp b/test/lib/completions/pdftotext.exp
new file mode 100644
index 00000000..4c5cfca5
--- /dev/null
+++ b/test/lib/completions/pdftotext.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "pdftotext "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/perl.exp b/test/lib/completions/perl.exp
index f3a51841..3a92a6b9 100644
--- a/test/lib/completions/perl.exp
+++ b/test/lib/completions/perl.exp
@@ -4,7 +4,7 @@ proc setup {} {
proc teardown {} {
- assert_env_unmodified
+ assert_env_unmodified {/PERL5LIB=/d}
}
@@ -117,4 +117,15 @@ sync_after_int
assert_complete_any "perl -m-File::"
sync_after_int
+# Make sure at least our mock Devel::* module is around
+assert_bash_exec {OLDPERL5LIB=$PERL5LIB; export PERL5LIB=$TESTDIR/fixtures/perl}
+
+assert_complete_any "perl -d:"
+sync_after_int
+
+assert_complete_any "perl -dt:"
+sync_after_int
+
+assert_bash_exec {export PERL5LIB=$OLDPERL5LIB; unset -v OLDPERL5LIB}
+
teardown
diff --git a/test/lib/completions/perldoc.exp b/test/lib/completions/perldoc.exp
index a745b55d..3197bf5c 100644
--- a/test/lib/completions/perldoc.exp
+++ b/test/lib/completions/perldoc.exp
@@ -1,4 +1,5 @@
proc setup {} {
+ assert_bash_exec {export PERL5LIB=$SRCDIR/fixtures/perldoc}
save_env
}
@@ -31,4 +32,8 @@ assert_complete_any "perldoc -"
sync_after_int
+assert_complete "BashCompletionModule BashCompletionDoc" "perldoc BashCompletion"
+sync_after_int
+
+
teardown
diff --git a/test/lib/completions/pine.exp b/test/lib/completions/pine.exp
index 622bf064..9919a4cb 100644
--- a/test/lib/completions/pine.exp
+++ b/test/lib/completions/pine.exp
@@ -11,9 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "pine "
-
-
+assert_complete_any "pine -"
sync_after_int
diff --git a/test/lib/completions/pngfix.exp b/test/lib/completions/pngfix.exp
new file mode 100644
index 00000000..d492610d
--- /dev/null
+++ b/test/lib/completions/pngfix.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "pngfix "
+sync_after_int
+
+assert_complete_any "pngfix -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/portsnap.exp b/test/lib/completions/portsnap.exp
new file mode 100644
index 00000000..d6028cae
--- /dev/null
+++ b/test/lib/completions/portsnap.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "portsnap "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/puppet.exp b/test/lib/completions/puppet.exp
index 7b7da3e7..8b82a160 100644
--- a/test/lib/completions/puppet.exp
+++ b/test/lib/completions/puppet.exp
@@ -12,8 +12,9 @@ setup
assert_complete_any "puppet "
+sync_after_int
-
+assert_complete_any "puppet agent --"
sync_after_int
diff --git a/test/lib/completions/pushd.exp b/test/lib/completions/pushd.exp
new file mode 100644
index 00000000..54e3ad8b
--- /dev/null
+++ b/test/lib/completions/pushd.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "pushd "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/py.test.exp b/test/lib/completions/py.test.exp
new file mode 100644
index 00000000..736b9828
--- /dev/null
+++ b/test/lib/completions/py.test.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "py.test "
+sync_after_int
+
+assert_complete_any "py.test -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/pyflakes.exp b/test/lib/completions/pyflakes.exp
new file mode 100644
index 00000000..22a8cf7c
--- /dev/null
+++ b/test/lib/completions/pyflakes.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "pyflakes "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/python.exp b/test/lib/completions/python.exp
index 446e3d09..29a10bf6 100644
--- a/test/lib/completions/python.exp
+++ b/test/lib/completions/python.exp
@@ -17,5 +17,29 @@ sync_after_int
assert_complete_any "python -"
sync_after_int
+assert_no_complete "python -c "
+sync_after_int
+
+assert_complete {"bar bar.d/" foo.d/} "python $::srcdir/fixtures/shared/default/"
+sync_after_int
+
+assert_complete {bar "bar bar.d/" foo foo.d/} "python -c foo $::srcdir/fixtures/shared/default/"
+sync_after_int
+
+assert_no_complete "python -c foo -"
+sync_after_int
+
+assert_no_complete "python -m foo -"
+sync_after_int
+
+assert_complete_any "python -m sy"
+sync_after_int
+
+assert_complete_any "python -W "
+sync_after_int
+
+assert_complete_any "python -Wa"
+sync_after_int
+
teardown
diff --git a/test/lib/completions/pyvenv.exp b/test/lib/completions/pyvenv.exp
new file mode 100644
index 00000000..9eca0e4c
--- /dev/null
+++ b/test/lib/completions/pyvenv.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "pyvenv "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/quotacheck.exp b/test/lib/completions/quotacheck.exp
index 4200da32..353d204a 100644
--- a/test/lib/completions/quotacheck.exp
+++ b/test/lib/completions/quotacheck.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "quotacheck "
+assert_complete_any "quotacheck -"
sync_after_int
diff --git a/test/lib/completions/quotaon.exp b/test/lib/completions/quotaon.exp
index 4acc70e1..b8279e59 100644
--- a/test/lib/completions/quotaon.exp
+++ b/test/lib/completions/quotaon.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "quotaon "
+assert_complete_any "quotaon -"
sync_after_int
diff --git a/test/lib/completions/renice.exp b/test/lib/completions/renice.exp
index fdc859b4..5e25ddea 100644
--- a/test/lib/completions/renice.exp
+++ b/test/lib/completions/renice.exp
@@ -11,32 +11,15 @@ proc teardown {} {
setup
-set test "Tab should show complete process ids"
- # Try completion
-set cmd "renice 1"
-send "$cmd\t"
-expect {
- -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- -re eof { unresolved "eof" }
-}
-
+if {[assert_bash_type ps]} {
-sync_after_int
+ assert_complete_any "renice 1"
+ sync_after_int
+ assert_complete_any "renice -g "
+ sync_after_int
-set test "Tab should show complete process group ids"
- # Try completion
-set cmd "renice -g "
-send "$cmd\t"
-expect {
- -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- -re eof { unresolved "eof" }
}
-sync_after_int
-
-
teardown
diff --git a/test/lib/completions/repomanage.exp b/test/lib/completions/repomanage.exp
new file mode 100644
index 00000000..de5169bc
--- /dev/null
+++ b/test/lib/completions/repomanage.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "repomanage "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ri.exp b/test/lib/completions/ri.exp
index e6661d1b..1210685b 100644
--- a/test/lib/completions/ri.exp
+++ b/test/lib/completions/ri.exp
@@ -1,19 +1,25 @@
proc setup {} {
+ assert_bash_exec {OLDRI="$RI"; export RI="-d $SRCDIR/fixtures/ri"}
save_env
}
proc teardown {} {
assert_env_unmodified
+ assert_bash_exec {RI="$OLDRI"; unset -v OLDRI}
}
setup
-assert_complete_any "ri RI"
+assert_complete_any "ri -"
+sync_after_int
+assert_complete "BashCompletion/ cache.ri" "ri --dump=$::srcdir/fixtures/ri/"
+sync_after_int
+assert_complete "BashCompletion" "ri BashCompletio"
sync_after_int
diff --git a/test/lib/completions/rsync.exp b/test/lib/completions/rsync.exp
index 42b7af8e..accc6569 100644
--- a/test/lib/completions/rsync.exp
+++ b/test/lib/completions/rsync.exp
@@ -4,7 +4,9 @@ proc setup {} {
proc teardown {} {
- assert_env_unmodified
+ assert_env_unmodified {
+ /_scp_path_esc=/d
+ }
}
diff --git a/test/lib/completions/rtcwake.exp b/test/lib/completions/rtcwake.exp
index 21c05eab..81ca3206 100644
--- a/test/lib/completions/rtcwake.exp
+++ b/test/lib/completions/rtcwake.exp
@@ -12,8 +12,6 @@ setup
assert_complete_any "rtcwake "
-
-
sync_after_int
diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp
index 7cc6eb07..6b06cb25 100644
--- a/test/lib/completions/scp.exp
+++ b/test/lib/completions/scp.exp
@@ -55,13 +55,13 @@ set test "Tab should complete known-hosts"
# Build string list of expected completions
# Get hostnames and give them a colon (:) suffix
- # Hosts `gee' and `hus' are defined in ./fixtures/scp/config
+ # Hosts `gee' and `hut' are defined in ./fixtures/scp/config
# Hosts `blah', `doo' and `ike' are defined in ./fixtures/scp/known_hosts
set expected {}
foreach host [get_hosts] {
lappend expected "$host:"
}
-lappend expected blah: doo: gee: hus: ike:
+lappend expected blah: doo: gee: hut: ike:
# Append local filenames
lappend expected config known_hosts "spaced\\ \\ conf"
assert_complete $expected "scp -F config " $test
diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp
index 5e585179..f37d5f5f 100644
--- a/test/lib/completions/screen.exp
+++ b/test/lib/completions/screen.exp
@@ -24,6 +24,10 @@ assert_complete_any "screen cat"
sync_after_int
+assert_complete_any "screen -T "
+sync_after_int
+
+
assert_complete_any "screen -T foo cat"
sync_after_int
diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp
index 27fe7511..3c18ddb7 100644
--- a/test/lib/completions/sftp.exp
+++ b/test/lib/completions/sftp.exp
@@ -21,9 +21,9 @@ setup
# Build string list of expected completions
set expected [get_hosts]
- # Hosts `gee' and `hus' are defined in ./fixtures/sftp/config
+ # Hosts `gee' and `hut' are defined in ./fixtures/sftp/config
# Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts
-lappend expected 10.10.10.10 doo gee hus ike
+lappend expected 10.10.10.10 doo gee hut ike
assert_complete $expected "sftp -F config "
@@ -48,9 +48,9 @@ sync_after_int
# Build string list of expected completions
# Get hostnames and give them a colon (:) suffix
set expected [get_hosts]
- # Hosts `gee', `hus' and `jar' are defined in "./fixtures/sftp/spaced conf"
+ # Hosts `gee' and `jar' are defined in "./fixtures/sftp/spaced conf"
# Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts
-lappend expected 10.10.10.10 doo gee hus ike jar
+lappend expected 10.10.10.10 doo gee ike jar
assert_complete $expected "sftp -F spaced\\ \\ conf "
diff --git a/test/lib/completions/ssh-copy-id.exp b/test/lib/completions/ssh-copy-id.exp
index e8b643fd..5abe303d 100644
--- a/test/lib/completions/ssh-copy-id.exp
+++ b/test/lib/completions/ssh-copy-id.exp
@@ -1,10 +1,16 @@
proc setup {} {
save_env
+ # Some old versions of ssh-copy-id won't output even usage if no
+ # identities are found. Try to make sure there is at least one (for CI).
+ assert_bash_exec {OLDHOME=$HOME ; HOME=$SRCDIR/fixtures/ssh-copy-id}
}
proc teardown {} {
- assert_env_unmodified
+ assert_bash_exec {HOME=$OLDHOME}
+ assert_env_unmodified {
+ /OLDHOME=/d
+ }
}
diff --git a/test/lib/completions/ssh-keygen.exp b/test/lib/completions/ssh-keygen.exp
new file mode 100644
index 00000000..fea2529e
--- /dev/null
+++ b/test/lib/completions/ssh-keygen.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "ssh-keygen -"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp
index 3ef0bb69..c082558e 100644
--- a/test/lib/completions/ssh.exp
+++ b/test/lib/completions/ssh.exp
@@ -60,7 +60,23 @@ sync_after_int
set test "First argument should complete partial hostname"
-assert_complete_partial [get_known_hosts] ssh "l" $test -ltrim-colon-completions
+# Build string list of hostnames, starting with the character of the first
+# host, unless host starts with a COMP_WORDBREAKS character, e.g. a colon (:).
+# Hosts starting with a COMP_WORDBREAKS character are left out because these
+# are exceptional cases, requiring specific tests.
+set hosts {}
+set char ""
+foreach h [get_known_hosts] {
+ set first [string range $h 0 0]
+ if {$char == "" && [string first $first $::COMP_WORDBREAKS] == -1} {set char $first}
+ if {$char != ""} {
+ # Only append unique hostnames starting with $char
+ if {$first == $char && [lsearch -exact $hosts "$h"] == -1} {
+ lappend hosts "$h"
+ }
+ }
+}
+assert_complete $hosts "ssh $char" $test -ltrim-colon-completions -expect-cmd-minus "$char"
sync_after_int
diff --git a/test/lib/completions/synclient.exp b/test/lib/completions/synclient.exp
new file mode 100644
index 00000000..1e9c7b5b
--- /dev/null
+++ b/test/lib/completions/synclient.exp
@@ -0,0 +1,26 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "synclient -"
+sync_after_int
+
+
+# synclient -l may error out with e.g.
+# Couldn't find synaptics properties. No synaptics driver loaded?
+if {[assert_exec {synclient -l} "" "" "unsupported"]} {
+ assert_complete_any "synclient "
+}
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tar.exp b/test/lib/completions/tar.exp
index 37f1ae4b..75434e94 100644
--- a/test/lib/completions/tar.exp
+++ b/test/lib/completions/tar.exp
@@ -2,19 +2,131 @@ proc setup {} {
save_env
}
-
proc teardown {} {
- assert_env_unmodified
+ assert_env_unmodified {
+ /OLDPWD=/d
+ /declare -f _tar/d
+ }
}
-
setup
+# Detect whether system's tar is GNU tar
+set cmd "tar --version"
+send "$cmd\r"
+expect "^$cmd\r\n"
+expect {
+ -re "GNU\[^\n\]*\n" {
+ set tar_version gnu
+ }
+ -re ".*\n" {
+ set tar_version unknown
+ }
+}
+sync_after_int
+
+set test "old option: list escaped chars"
+assert_complete_dir "a/b\\'c/" "tar tf escape.tar a/b\\\'" $::srcdir/fixtures/tar $test
+sync_after_int
+
+# TODO: "tar tf escape.tar a/b"
+
+set test "check that any completion done"
assert_complete_any "tar "
+sync_after_int
+
+# Use bsdtar as the it completes to only 'zc zt zx' ('tar' can be GNU tar and it
+# can would have more options)
+set test "old option: mode is not on first place"
+assert_complete {zc zt zx} "bsdtar z" $test
+sync_after_int
+
+set test "old option: test 'f' when mode is not as a first option"
+assert_complete_dir "dir/ dir2/" "tar zfc " $::srcdir/fixtures/tar
+sync_after_int
+
+set test "old option: creating archive and 'f' option"
+assert_complete_dir "dir/ dir2/" "tar cf " $::srcdir/fixtures/tar
+sync_after_int
+
+set test "old option: archive listing"
+assert_complete_dir "dir/fileA dir/fileB dir/fileC" "tar tf archive.tar.xz dir/file" $::srcdir/fixtures/tar
+sync_after_int
+set test "old option: check _second_ option in \"old\" argument"
+assert_complete_dir "dir/ dir2/" "bsdtar cbfvv NOT_EXISTS " $::srcdir/fixtures/tar
+sync_after_int
+
+set test "old option: create and members"
+assert_complete_dir "dir/ dir2/ archive.tar.xz escape.tar" "tar cTfvv NOT_EXISTS DONT_CREATE.tar " $::srcdir/fixtures/tar
+sync_after_int
+set test "old option: extract and archive"
+assert_complete_dir "dir/ dir2/ archive.tar.xz escape.tar" "tar xvf " $::srcdir/fixtures/tar
sync_after_int
+if { "$tar_version" == "gnu" } {
+ set test "check short options"
+ assert_complete_any "tar -c"
+ sync_after_int
+
+ set test "mode not as a first option"
+ assert_complete_dir "dir/ dir2/" "tar -zcf " $::srcdir/fixtures/tar
+ sync_after_int
+
+ # Only directories should be completed.
+ set test "check that we do not suggest re-writing existing archive"
+ assert_complete_dir "dir/ dir2/" "tar -cf " $::srcdir/fixtures/tar
+ sync_after_int
+
+ set test "check --file option"
+ assert_complete_dir "dir/ dir2/" "tar -c --file " $::srcdir/fixtures/tar
+ sync_after_int
+
+ set test "check --file option #2"
+ assert_complete_dir "dir/ dir2/" "tar -cvv --file " $::srcdir/fixtures/tar
+ sync_after_int
+
+ set test "archive listing"
+ assert_complete_dir "dir/fileA dir/fileB dir/fileC" "tar -tf archive.tar.xz dir/file" $::srcdir/fixtures/tar
+ sync_after_int
+
+ set test "archive listing with --file"
+ assert_complete_dir "dir/fileA dir/fileB dir/fileC" "tar -t --file archive.tar.xz dir/file" $::srcdir/fixtures/tar
+ sync_after_int
+
+ # Some random options should work:
+ set test "test random tar's long option #1"
+ assert_complete "--blocking-factor= --block-number" "tar --block" $test
+ sync_after_int
+
+ set test "test random tar's long option #2"
+ assert_complete "--add-file=" "tar --add-fil" $test -nospace
+ sync_after_int
+
+ set test "test random tar's long option #3"
+ assert_complete "--posix" "tar -cf /dev/null --posi" $test
+ sync_after_int
+
+ # --owner
+ set users [exec bash -c "compgen -A user"]
+ set test "test --owner option"
+ assert_complete $users "tar --owner=" $test
+ sync_after_int
+
+ # --group
+ set groups [exec bash -c "compgen -A group"]
+ set test "test --group option"
+ assert_complete $groups "tar --group=" $test
+ sync_after_int
+
+ # use -b for this as -b is still not handled by tar's completion
+ set test "short opt -XXXb <TAB> (arg required)"
+ assert_no_complete "tar -cvvfb " $test
+ sync_after_int
+
+ # TODO: how to test that 'tar -cf<TAB>' completes to 'tar -cf '
+}
teardown
diff --git a/test/lib/completions/timeout.exp b/test/lib/completions/timeout.exp
new file mode 100644
index 00000000..f56c80f3
--- /dev/null
+++ b/test/lib/completions/timeout.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "timeout -"
+sync_after_int
+
+assert_no_complete "timeout " "1st non-option arg=timeout, shouldn't complete"
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/tipc.exp b/test/lib/completions/tipc.exp
new file mode 100644
index 00000000..dd88de31
--- /dev/null
+++ b/test/lib/completions/tipc.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "tipc "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/udevadm.exp b/test/lib/completions/udevadm.exp
new file mode 100644
index 00000000..87a948a8
--- /dev/null
+++ b/test/lib/completions/udevadm.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "udevadm "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/umount.exp b/test/lib/completions/umount.exp
index 21a2dfa5..e7703d12 100644
--- a/test/lib/completions/umount.exp
+++ b/test/lib/completions/umount.exp
@@ -1,10 +1,36 @@
+# umount completion from fstab can't be tested directly because it
+# (correctly) uses absolute paths. So we create a custom completion which
+# reads from a file in our text fixture instead.
+proc setup_dummy_mnt {} {
+ assert_bash_exec {unset COMPREPLY cur}
+ assert_bash_exec {unset -f _mnt}
+
+ assert_bash_exec { \
+ _mnt() { \
+ local cur=$(_get_cword); \
+ _linux_fstab $(_get_pword) < "$SRCDIRABS/fixtures/mount/test-fstab"; \
+ }; \
+ complete -F _mnt mnt \
+ }
+}
+
+
+proc teardown_dummy_mnt {} {
+ assert_bash_exec {unset COMPREPLY cur}
+ assert_bash_exec {unset -f _mnt}
+ assert_bash_exec {complete -r mnt}
+}
+
+
proc setup {} {
save_env
+ setup_dummy_mnt
}
proc teardown {} {
- assert_env_unmodified
+ teardown_dummy_mnt
+ assert_env_unmodified {/OLDPWD/d}
}
@@ -17,4 +43,59 @@ assert_complete_any "umount "
sync_after_int
+set test "Testing internal __linux_fstab_unescape function for umount"
+# One round of slashes is for bash.
+assert_bash_exec {var=one\'two\\040three\\}
+assert_bash_exec {__linux_fstab_unescape var}
+set cmd {echo $var}
+send "$cmd\r"
+expect {
+ -ex "$cmd\r\none'two three\\" { pass $test }
+# default { fail $test }
+}
+sync_after_int
+assert_bash_exec {unset var}
+
+
+sync_after_int
+
+
+# Begin testing through mnt (see setup_dummy_mnt).
+assert_complete {/mnt/nice-test-path} {mnt /mnt/nice-test-p}
+sync_after_int
+
+assert_complete {/mnt/nice\ test-path} {mnt /mnt/nice\ test-p}
+sync_after_int
+
+assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$test-p}
+sync_after_int
+
+assert_complete {/mnt/nice\ test\\path} {mnt /mnt/nice\ test\\p}
+sync_after_int
+
+assert_complete {{/mnt/nice\ test\\path} {/mnt/nice\ test-path}} \
+ {mnt /mnt/nice\ } "" -expect-cmd-minus {/mnt/nice\ }
+sync_after_int
+
+assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$}
+sync_after_int
+
+assert_complete {/mnt/nice\'test-path} {mnt /mnt/nice\'}
+sync_after_int
+
+assert_complete {/mnt/other\'test\ path} {mnt /mnt/other}
+sync_after_int
+
+assert_complete {Ubuntu\ Karmic} {mnt -L Ubu}
+sync_after_int
+
+assert_complete {Debian-it\'s\ awesome} {mnt -L Deb}
+sync_after_int
+
+# This does not work. Proper support for this requires smarter parsing of
+# $COMP_LINE and it's not worth doing just for umount.
+#assert_complete {$'/mnt/nice\ntest-path'} {mnt $'/mnt/nice\n}
+#sync_after_int
+
+
teardown
diff --git a/test/lib/completions/unshunt.exp b/test/lib/completions/unshunt.exp
index 96cd5860..cac4ce65 100644
--- a/test/lib/completions/unshunt.exp
+++ b/test/lib/completions/unshunt.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "unshunt -"
+assert_complete_any "unshunt --"
sync_after_int
diff --git a/test/lib/completions/vgcreate.exp b/test/lib/completions/vgcreate.exp
index 4cb7dd45..6f3b3e37 100644
--- a/test/lib/completions/vgcreate.exp
+++ b/test/lib/completions/vgcreate.exp
@@ -12,8 +12,10 @@ setup
assert_complete_any "vgcreate -"
+sync_after_int
+assert_no_complete "vgcreate __does_not_exist__"
sync_after_int
diff --git a/test/lib/completions/wtf.exp b/test/lib/completions/wtf.exp
index b1693c80..0080967c 100644
--- a/test/lib/completions/wtf.exp
+++ b/test/lib/completions/wtf.exp
@@ -11,7 +11,7 @@ proc teardown {} {
setup
-assert_complete_any "wtf "
+assert_complete_any "wtf A"
sync_after_int
diff --git a/test/lib/completions/zopfli.exp b/test/lib/completions/zopfli.exp
new file mode 100644
index 00000000..15738ff0
--- /dev/null
+++ b/test/lib/completions/zopfli.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "zopfli "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/zopflipng.exp b/test/lib/completions/zopflipng.exp
new file mode 100644
index 00000000..9c421a14
--- /dev/null
+++ b/test/lib/completions/zopflipng.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "zopflipng "
+sync_after_int
+
+
+teardown
diff --git a/test/lib/library.exp b/test/lib/library.exp
index 75bf921c..1e2c7456 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -10,7 +10,7 @@ package require textutil::string
# Execute a bash command and make sure the exit status is successful.
# If not, output the error message.
# @param string $cmd Bash command line to execute. If empty string (""), the
-# exit status of the previously executed bash command will be
+# exit status of the previously executed bash command will be
# checked; specify `title' to adorn the error message.
# @param string $title (optional) Command title. If empty, `cmd' is used.
# @param string $prompt (optional) Bash prompt. Default is "/@"
@@ -51,7 +51,7 @@ proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {out -1}} {
# @param string $command Command to locate
proc assert_bash_type {command} {
set test "$command should be available in bash"
- set cmd "type $command &> /dev/null && echo -n 0 || echo -n 1"
+ set cmd "type $command &> /dev/null && echo -n 0 || echo -n 1"
send "$cmd\r"
expect "$cmd\r\n"
expect {
@@ -74,7 +74,7 @@ proc assert_bash_type {command} {
# @param list $args Options:
# -sort Compare list sorted. Default is unsorted
# -prompt Bash prompt. Default is `/@'
-# -chunk-size N Compare list N items at a time. Default
+# -chunk-size N Compare list N items at a time. Default
# is 20.
proc assert_bash_list {expected cmd test {args {}}} {
array set arg [::cmdline::getoptions args {
@@ -114,7 +114,7 @@ proc assert_bash_list {expected cmd test {args {}}} {
# @param list $args Options:
# -sort Compare list sorted. Default is unsorted
# -prompt Bash prompt. Default is `/@'
-# -chunk-size N Compare list N items at a time. Default
+# -chunk-size N Compare list N items at a time. Default
# is 20.
proc assert_bash_list_dir {expected cmd dir test {args {}}} {
array set arg [::cmdline::getoptions args {
@@ -126,7 +126,7 @@ proc assert_bash_list_dir {expected cmd dir test {args {}}} {
if {$arg(sort)} {set arg_sort "-sort"} else {set arg_sort ""}
assert_bash_exec "cd $dir" "" $prompt
assert_bash_list $expected $cmd $test $arg_sort \
- -chunk-size $arg(chunk-size) -prompt $prompt
+ -chunk-size $arg(chunk-size) -prompt $prompt
sync_after_int $prompt
assert_bash_exec {cd "$TESTDIR"}
}
@@ -253,10 +253,12 @@ proc assert_complete_one {expected cmd {test ""} {args {}}} {
if {$test == ""} {set test "$cmd should show completion"}
send "$cmd\t"
expect -ex "$cmd"
+ set trimmed false
if {$arg(ltrim-colon-completions)} {
# If partial contains colon (:), remove partial from begin of items
- _ltrim_colon_completions $cmd expected cword
- } else {
+ set trimmed [_ltrim_colon_completions $cmd expected cword]
+ }
+ if {! $trimmed} {
set cur ""; # Default to empty word to complete on
set words [split_words_bash $cmd]
if {[llength $words] > 1} {
@@ -346,7 +348,7 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} {
expect {
# Match completion, single word. This word is shown on the
# same line as the command.
- -re "^\\w+ $" { pass "$test" }
+ -re "^\\S* $" { pass "$test" }
# Try matching multiple words again, with new timeout
-re "^\r\n.*$prompt$cmd\\S*$" { pass "$test" }
}
@@ -373,7 +375,7 @@ proc assert_complete_dir {expected cmd dir {test ""} {args {}}} {
sync_after_int $prompt
assert_bash_exec {cd "$TESTDIR"}
}
-
+
# Make sure a partial argument is completed.
@@ -408,7 +410,7 @@ proc assert_complete_partial {expected cmd {partial ""} {test ""} {args {}}} {
# If cword contains colon (:), left-trim completions with cword
-# @param string $cmd Command to complete
+# @param string $cmd Command to complete
# @param list $items Reference to list of completions to trim
# @param string $dword Reference to variable to contain word to remove from
# expected cmd.
@@ -437,7 +439,9 @@ proc _ltrim_colon_completions {cmd items dword} {
lset items_out $i [string range $item [string length $cur] end]
}
}
+ return true
}
+ return false
}
@@ -445,13 +449,13 @@ proc _ltrim_colon_completions {cmd items dword} {
# to `save_env()'.
# @param string $sed Sed commands to preprocess diff output.
# Example calls:
-#
+#
# # Replace `COMP_PATH=.*' with `COMP_PATH=PATH'
# assert_env_unmodified {s/COMP_PATH=.*/COMP_PATH=PATH/}
-#
+#
# # Remove lines containing `OLDPWD='
# assert_env_unmodified {/OLDPWD=/d}
-#
+#
# @param string $file Filename to generate environment save file from. See
# `gen_env_filename()'.
# @param string $diff Expected diff output (after being processed by $sed)
@@ -488,8 +492,8 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} {
expect {
-re "^$diff[wd]@$" { pass "$test" }
- -re [wd]@ {
- fail "$test"
+ -re [wd]@ {
+ fail "$test"
# Show diff to user
@@ -587,7 +591,7 @@ proc assert_no_output {{cmd} {test ""} {prompt /@}} {
# "lib/completions/$cmd.exp".
proc assert_source_completions {command {file ""}} {
if {[assert_bash_type $command]
- && [is_bash_completion_installed_for $command]} {
+ && [assert_install_completion_for $command]} {
if {[string length $file] == 0} {
set file "$::srcdir/lib/completions/$command.exp"
}
@@ -598,6 +602,21 @@ 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.
@@ -690,13 +709,12 @@ proc init_tcl_bash_globals {} {
}
-# Check whether completion is installed for the specified command by executing
-# `complete -p ...' in bash.
-# @param string $command Command to check completion availability for.
+# Try installing completion for the specified command.
+# @param string $command Command to install completion for.
# @return boolean True (1) if completion is installed, False (0) if not.
-proc is_bash_completion_installed_for {command} {
+proc assert_install_completion_for {command} {
set test "$command should have completion installed in bash"
- set cmd "complete -p $command &> /dev/null && echo -n 0 || echo -n 1"
+ set cmd "__load_completion $command ; complete -p $command &> /dev/null && echo -n 0 || echo -n 1"
send "$cmd\r"
expect "$cmd\r\n"
expect {
@@ -716,7 +734,7 @@ proc is_cygwin {} {
# Expect items, a limited number (20) at a time.
# Break items into chunks because `expect' seems to have a limited buffer size
-# @param list $items Expected list items
+# @param list $items Expected list items
# @param list $args Options:
# -bash-sort Compare list bash-sorted. Default is
# unsorted
@@ -846,13 +864,13 @@ proc save_env {{file ""}} {
# @param string File to save the environment to. Default is "$TESTDIR/tmp/env1~".
# @see assert_env_unmodified()
proc _save_env {{file ""}} {
- assert_bash_exec "{ set; declare -F; shopt -p; } > \"$file\""
+ assert_bash_exec "{ (set -o posix ; set); declare -F; shopt -p; set -o; } > \"$file\""
}
# Source bash_completion package
proc source_bash_completion {} {
- assert_bash_exec {BASH_COMPLETION_COMPAT_DIR=$(cd "$SRCDIR/.."; pwd)/completions}
+ assert_bash_exec {BASH_COMPLETION_COMPAT_DIR="$SRCDIR/fixtures/shared/empty_dir"}
assert_bash_exec {source $(cd "$SRCDIR/.."; pwd)/bash_completion}
}
@@ -994,7 +1012,7 @@ proc init_bash_xtrace {{fname xtrace.log}} {
# Setup test environment
-#
+#
# Common initialization for unit and completion tests.
proc start_interactive_test {} {
start_bash
diff --git a/test/lib/library.sh b/test/lib/library.sh
index 290ec813..0a671595 100644
--- a/test/lib/library.sh
+++ b/test/lib/library.sh
@@ -24,6 +24,8 @@ diff_env() {
/[<>] PPID=/d
# Remove BASH_REMATCH bash variable
/[<>] BASH_REMATCH=/d
+# Remove functions starting with underscore
+ /[<>] declare -f _/d
$3"
} # diff_env()
@@ -62,12 +64,3 @@ is_bash_version_minimal() {
remove_comp_wordbreak_char() {
COMP_WORDBREAKS=${COMP_WORDBREAKS//$1}
} # remove_comp_wordbreak_char()
-
-
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
-# ex: ts=4 sw=4 et filetype=sh
diff --git a/test/log/.gitignore b/test/log/.gitignore
new file mode 100644
index 00000000..72e8ffc0
--- /dev/null
+++ b/test/log/.gitignore
@@ -0,0 +1 @@
+*
diff --git a/test/run b/test/run
new file mode 100755
index 00000000..43651654
--- /dev/null
+++ b/test/run
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+
+# Print some helpful messages.
+usage() {
+ echo "Run bash-completion tests"
+ echo
+ echo "The 'tool' is determined automatically from filenames."
+ echo "Unrecognized options are passed through to dejagnu by default."
+ echo
+ echo "Interesting options:"
+ echo " --tool_exec= Test against a different bash executable."
+ 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."
+ echo
+ echo "Example run: ./run unit/_get_cword.exp unit/compgen.exp"
+}
+
+
+# Try to set the tool variable; or fail if trying to set different values.
+set_tool() {
+ if [[ $tool ]]; then
+ if [[ $tool != $1 ]]; then
+ echo "Tool spec mismatch ('$tool' and '$1'). See --usage."
+ exit 1
+ fi
+ else
+ tool=$1
+ fi
+}
+
+
+cd "$(dirname "${BASH_SOURCE[0]}")"
+
+
+# Loop over the arguments.
+args=()
+while [[ $# > 0 ]]; do
+ case "$1" in
+ --help|--usage) usage; exit 1;;
+ --debug-xtrace) args+=(OPT_BASH_XTRACE=1);;
+ --timeout) shift; timeout=$1;;
+ --timeout=*) timeout=${1/--timeout=};;
+ --tool=*) set_tool "${1#/--tool=}";;
+ --tool) shift; set_tool "$1";;
+ completion/*.exp|*/completion/*.exp|unit/*.exp|*/unit/*.exp)
+ arg=${1%/*}
+ set_tool "${arg##*/}"
+ args+=("${1##*/}")
+ ;;
+ *) args+=("$1")
+ esac
+ shift
+done
+
+[[ -n $timeout ]] && args+=("OPT_TIMEOUT=$timeout")
+[[ -z $tool ]] && { echo "Must specify tool somehow"; exit 1; }
+
+runtest --outdir log --tool $tool "${args[@]}"
+rc=$?
+[[ $rc -ne 0 && -n "$CI" ]] && cat log/$tool.log
+exit $rc
diff --git a/test/runCompletion b/test/runCompletion
new file mode 100755
index 00000000..38a82622
--- /dev/null
+++ b/test/runCompletion
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# NOTE: I tried setting up bash_completion_lib within ./lib files, but DejaGnu
+# isn't initialized at that point (i.e. output of `expect' is shown on
+# stdout - `open_logs' hasn't run yet?). And running code from a library
+# file isn't probably a good idea either.
+exec "${bashcomp_bash:-$BASH}" \
+ "$(dirname "${BASH_SOURCE[0]}")/run" --tool completion $*
diff --git a/test/runInstall b/test/runInstall
new file mode 100755
index 00000000..87aea589
--- /dev/null
+++ b/test/runInstall
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# NOTE: I tried setting up bash_completion_lib within ./lib files, but DejaGnu
+# isn't initialized at that point (i.e. output of `expect' is shown on
+# stdout - `open_logs' hasn't run yet?). And running code from a library
+# file isn't probably a good idea either.
+exec runtest --outdir log --tool install $*
diff --git a/test/runLint b/test/runLint
new file mode 100755
index 00000000..2db8f358
--- /dev/null
+++ b/test/runLint
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+gitgrep()
+{
+ local out=$(git grep -I -P -n "$1" | \
+ grep -E '^(bash_completion|completions/|test/)' | \
+ grep -Fv 'test/runLint')
+ if [ -n "$out" ] ; then
+ printf '***** %s\n' "$2"
+ printf '%s\n\n' "$out"
+ fi
+}
+
+unset CDPATH
+cd $(dirname "$0") ; cd ..
+
+cmdstart='(^|[[:space:]]|\()'
+
+gitgrep $cmdstart"awk\b.*-F([[:space:]]|[[:space:]]*[\"'][^\"']{2,})" \
+ 'awk with -F char or -F ERE, use -Fchar instead (Solaris)'
+
+gitgrep $cmdstart"awk\b.*\[:[a-z]*:\]" \
+ 'awk with POSIX character class not supported in mawk (Debian/Ubuntu)'
+
+gitgrep $cmdstart'sed\b.*\\[?+]' \
+ 'sed with ? or +, use POSIX BRE instead (\{m,n\})'
+
+gitgrep $cmdstart'sed\b.*\\\|' \
+ "sed with \|, use POSIX BRE (possibly multiple sed invocations) or another tool instead"
+
+# TODO: really nonportable? appears to work fine in Linux, FreeBSD, Solaris
+#gitgrep $cmdstart'sed\b.*;' \
+# 'sed with ;, use multiple -e options instead (POSIX?) (false positives?)'
+
+gitgrep $cmdstart'sed\b.*-[^[:space:]]*[rE]' \
+ 'sed with -r or -E, drop and use POSIX BRE instead'
+
+gitgrep $cmdstart'[ef]grep\b' \
+ '[ef]grep, use grep -[EF] instead (historical/deprecated)'
+
+# TODO: $ in sed subexpression used as an anchor (POSIX BRE optional, not in
+# Solaris/FreeBSD)
+
+gitgrep '(?<!command)'$cmdstart'(grep|ls|sed)(\s|$)' \
+ 'invoke grep, ls, and sed through "command", e.g. "command grep"'
diff --git a/test/runUnit b/test/runUnit
new file mode 100755
index 00000000..5df06227
--- /dev/null
+++ b/test/runUnit
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# NOTE: I tried setting up bash_completion_lib within ./lib files, but DejaGnu
+# isn't initialized at that point (i.e. output of `expect' is shown on
+# stdout - `open_logs' hasn't run yet?). And running code from a library
+# file isn't probably a good idea either.
+exec "${bashcomp_bash:-$BASH}" \
+ "$(dirname "${BASH_SOURCE[0]}")/run" --tool unit $*
diff --git a/test/tmp/.gitignore b/test/tmp/.gitignore
new file mode 100644
index 00000000..72e8ffc0
--- /dev/null
+++ b/test/tmp/.gitignore
@@ -0,0 +1 @@
+*
diff --git a/test/unit/__expand_tilde_by_ref.exp b/test/unit/__expand_tilde_by_ref.exp
index abd549cb..60aa7d52 100644
--- a/test/unit/__expand_tilde_by_ref.exp
+++ b/test/unit/__expand_tilde_by_ref.exp
@@ -36,7 +36,7 @@ assert_bash_exec {foo() { local aa="~"; __expand_tilde_by_ref aa; }; foo; unset
sync_after_int
-set test "~user should return /home/user"
+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
@@ -44,7 +44,7 @@ assert_bash_list "$home" $cmd $test
sync_after_int
-set test "~/foo should return /home/user/foo"
+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
@@ -52,7 +52,7 @@ assert_bash_list "$home/foo" $cmd $test
sync_after_int
-set test "~user/bar should return /home/user/bar"
+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
@@ -60,7 +60,7 @@ assert_bash_list "$home/bar" $cmd $test
sync_after_int
-set test "~user/\$HOME should return /home/user/\$HOME"
+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
@@ -68,7 +68,7 @@ assert_bash_list "$home/\$HOME" $cmd $test
sync_after_int
-set test "'~user/a b' should return '/home/user/a b'"
+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
@@ -76,7 +76,7 @@ assert_bash_list [list [format {%s/a b} $home]] $cmd $test
sync_after_int
-set test "~user/* should return /home/user/*"
+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
diff --git a/test/unit/_filedir.exp b/test/unit/_filedir.exp
index a736e6ed..fb29af5b 100644
--- a/test/unit/_filedir.exp
+++ b/test/unit/_filedir.exp
@@ -1,6 +1,6 @@
proc setup {} {
assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _f}
+ assert_bash_exec {unset -f _f _fd}
save_env
# Declare bash completion function `_f'
assert_bash_exec { \
@@ -16,9 +16,16 @@ proc setup {} {
_g() { local cur=$(_get_cword); unset COMPREPLY; _filedir e1; }; \
complete -F _g g \
}
- # Create directories `a*b' and `a\b' only when not running on Cygwin/Windows;
- # directories containing `*' or `\' aren't allowed on Cygwin/Windows
+ # Declare bash completion function `_fd' to complete on dirs
+ assert_bash_exec { \
+ _fd() { local cur=$(_get_cword); unset COMPREPLY; _filedir -d; }; \
+ complete -F _fd fd \
+ }
+ # Create directories `a"b', `a*b', and `a\b' only when not running on
+ # Cygwin/Windows (`"', `*', or `\' aren't allowed in filenames there)
if {! [is_cygwin]} {
+ # Create directory `a"b'
+ assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\"b ] && mkdir a\"b && touch a\"b/d || true)}
# Create directory `a*b'
assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\*b ] && mkdir a\*b && touch a\*b/j || true)}
# Create directory `a\b'
@@ -29,12 +36,13 @@ proc setup {} {
proc teardown {} {
if {! [is_cygwin]} {
+ assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\"b/d && rmdir a\"b/ || true)}
assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\\b/g && rmdir a\\b/ || true)}
assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\*b/j && rmdir a\*b/ || true)}
}
assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _f _g}
- assert_bash_exec {complete -r f g}
+ assert_bash_exec {unset -f _f _g _fd}
+ assert_bash_exec {complete -r f g fd}
assert_env_unmodified {
/OLDPWD/d
/OLD_CTYPE/d
@@ -78,31 +86,25 @@ foreach name {f f2} {
sync_after_int
- set test "completing $name a\\\"b/ should return d"; #"
- set cmd "$name a\\\"b/"; #"
- assert_complete_dir d $cmd "$::srcdir/fixtures/_filedir" $test
-
-
- sync_after_int
-
-
set test "completing $name a\\\$b/ should return h"
- set cmd "$name a\\\$b/"
- assert_complete_dir h $cmd "$::srcdir/fixtures/_filedir" $test
-
+ if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} {
+ xfail $test
+ } else {
+ set cmd "$name a\\\$b/"
+ assert_complete_dir h $cmd "$::srcdir/fixtures/_filedir" $test
+ sync_after_int
+ }
- 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/"; #"
+ assert_complete_dir d $cmd "$TESTDIR/tmp" $test
+ sync_after_int
- # Execute these tests only when not running on Cygwin/Windows, because
- # directories containing asterisk (*) or backslash (\) aren't allowed on
- # Cygwin/Windows
- if {! [is_cygwin]} {
set test "completing $name a\\\\b/ should return g"
set cmd "$name a\\\\b/"
assert_complete_dir g $cmd "$TESTDIR/tmp" $test
-
-
sync_after_int
}
@@ -137,13 +139,6 @@ foreach name {f f2} {
sync_after_int
- set cmd "$name 'a\"b/"; #"
- assert_complete_dir {d'} $cmd "$::srcdir/fixtures/_filedir"
-
-
- sync_after_int
-
-
set cmd "$name 'a\$b/"
assert_complete_dir {h'} $cmd "$::srcdir/fixtures/_filedir"
@@ -151,13 +146,13 @@ foreach name {f f2} {
sync_after_int
- # Execute these tests only when not running on Cygwin/Windows, because
- # directories containing `*' or `\' aren't allowed on Cygwin/Windows
- if {! [is_cygwin]} {
+ if {! [is_cygwin]} { # Illegal characters in file/dir names
+ set cmd "$name 'a\"b/"; #"
+ assert_complete_dir {d'} $cmd "$TESTDIR/tmp"
+ sync_after_int
+
set cmd "$name '$TESTDIR/tmp/a\\b/"
assert_complete_dir {g'} $cmd "$TESTDIR/tmp"
-
-
sync_after_int
}
@@ -190,18 +185,20 @@ foreach name {f f2} {
sync_after_int
- set cmd "$name \"a\\\"b/"; #"
- assert_complete_dir {d"} $cmd "$::srcdir/fixtures/_filedir"; #"
-
-
- sync_after_int
-
-
- set cmd "$name \"a\\\$b/"; #"
- assert_complete_dir {h"} $cmd "$::srcdir/fixtures/_filedir"; #"
+ if {! [is_cygwin]} { # Illegal characters in file/dir names
+ set cmd "$name \"a\\\"b/"; #"
+ assert_complete_dir {d"} $cmd "$TESTDIR/tmp"; #"
+ sync_after_int
+ }
- sync_after_int
+ if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} {
+ xfail "$name \"a\\\$b/ should show completions"
+ } else {
+ set cmd "$name \"a\\\$b/"; #"
+ assert_complete_dir {h"} $cmd "$::srcdir/fixtures/_filedir"; #"
+ sync_after_int
+ }
set cmd "$name \"a\\b/"; #"
@@ -260,4 +257,12 @@ if {
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
+
+
teardown
diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp
index 3a582811..3fd3e20e 100644
--- a/test/unit/_get_cword.exp
+++ b/test/unit/_get_cword.exp
@@ -11,6 +11,7 @@ proc teardown {} {
/COMP_WORDBREAKS=/{N
d
}
+ /_scp_path_esc=/d
}
}
@@ -249,4 +250,18 @@ expect {
sync_after_int
+set test "index shouldn't drop below 0"
+set dir $::srcdir/fixtures/_get_cword
+set cmd "scp"
+send "$cmd ääää§ se\t\r\n"
+expect {
+ -re "index: substring expression < 0" { fail "$test" }
+ -re /@ { pass "$test" }
+ default { unresolved "$test" }
+}
+
+
+sync_after_int
+
+
teardown
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
index 30ede41c..c065f766 100644
--- a/test/unit/_known_hosts_real.exp
+++ b/test/unit/_known_hosts_real.exp
@@ -120,4 +120,32 @@ 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
+lappend hosts recursion relative_path
+set hosts [join [bash_sort $hosts] "\\s+"]
+ # 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
+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"
+expect {
+ -re "^$hosts\r\n/@$" { pass "$test" }
+ default { unresolved "$test" }
+}
+ # Teardown environment
+set cmd {HOME=$OLDHOME}
+send "$cmd\r"
+expect -ex "$cmd\r\n/@"
+
+
+sync_after_int
+
+
teardown
diff --git a/test/unit/_tilde.exp b/test/unit/_tilde.exp
index 2e22b848..19f47241 100644
--- a/test/unit/_tilde.exp
+++ b/test/unit/_tilde.exp
@@ -46,6 +46,12 @@ 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
+
+
+# Debian #766163
+assert_no_complete "_tilde ~-o"
+sync_after_int
teardown
diff --git a/test/unit/_variables.exp b/test/unit/_variables.exp
new file mode 100644
index 00000000..31411d53
--- /dev/null
+++ b/test/unit/_variables.exp
@@ -0,0 +1,39 @@
+proc setup {} {
+ assert_bash_exec { unset assoc1 && declare -A assoc1=([idx]=1)}
+ assert_bash_exec { unset assoc2 && declare -A assoc2=([idx1]=1 [idx2]=2)}
+ assert_bash_exec { unset ${!___v*} && declare ___var='' }
+ save_env
+}
+
+
+proc teardown {} {
+ assert_bash_exec {unset assoc1 assoc2}
+}
+
+
+setup
+
+set test "Complete simple variable names"
+assert_complete "\$___var" ": \$___v" $test
+
+set test "Complete single array index"
+assert_complete "\$\{assoc1\[idx\]\}" ": \$\{assoc1\[" $test
+sync_after_int
+
+set test "Complete closing curly bracket after square bracket"
+assert_complete "\$\{assoc1\[bogus\]\}" ": \$\{assoc1\[bogus\]" $test
+sync_after_int
+
+set test "Complete closing brackets after @ index"
+assert_complete "\$\{assoc1\[@\]\}" ": \$\{assoc1\[@" $test
+sync_after_int
+
+# For some reason -expect-cmd-minus is necessary here
+set test "Complete multiple array indexes"
+assert_complete_partial { \$\{assoc2\[idx1\]\} \$\{assoc2\[idx2\]\} } ":" "\$\{assoc2\[" $test -expect-cmd-minus "\${assoc2\["
+sync_after_int
+
+set test "Complete variables prefixed with #"
+assert_complete "\$\{#___var\}" ": \$\{#___v" $test
+
+teardown