diff options
author | Gabriel F. T. Gomes <gabriel@inconstante.net.br> | 2019-08-07 09:17:13 -0300 |
---|---|---|
committer | Gabriel F. T. Gomes <gabriel@inconstante.net.br> | 2019-08-07 09:17:13 -0300 |
commit | 5732da2af736c40cf693354485446ab4867ecb4d (patch) | |
tree | 76d76cdfa16ca62d20fb109da13895ec64fff110 /test/t | |
parent | 9cd22d1df8f0f5b554858471c86faa9f37b8fed4 (diff) | |
download | bash-completion-5732da2af736c40cf693354485446ab4867ecb4d.tar.gz |
New upstream version 2.9upstream/2.9
Diffstat (limited to 'test/t')
683 files changed, 9165 insertions, 0 deletions
diff --git a/test/t/Makefile.am b/test/t/Makefile.am new file mode 100644 index 00000000..fb7665f1 --- /dev/null +++ b/test/t/Makefile.am @@ -0,0 +1,680 @@ +SUBDIRS = unit + +EXTRA_DIST = \ + conftest.py \ + test_2to3.py \ + test_7z.py \ + test_a2ps.py \ + test_a2x.py \ + test_abook.py \ + test_aclocal.py \ + test_acpi.py \ + test_acroread.py \ + test_adb.py \ + test_add_members.py \ + test_alias.py \ + test_alpine.py \ + test_animate.py \ + test_ant.py \ + test_apache2ctl.py \ + test_appdata_validate.py \ + test_apt_build.py \ + test_apt_cache.py \ + test_apt_get.py \ + test_aptitude.py \ + test_arch.py \ + test_arp.py \ + test_arping.py \ + test_arpspoof.py \ + test_asciidoc.py \ + test_aspell.py \ + test_autoconf.py \ + test_autoheader.py \ + test_automake.py \ + test_autoreconf.py \ + test_autorpm.py \ + test_autoscan.py \ + test_autoupdate.py \ + test_avctrl.py \ + test_awk.py \ + test_badblocks.py \ + test_base64.py \ + test_bash.py \ + test_bc.py \ + test_bind.py \ + test_bison.py \ + test_bk.py \ + test_brctl.py \ + test_btdownloadcurses_py.py \ + test_btdownloadgui_py.py \ + test_btdownloadheadless_py.py \ + test_bts.py \ + test_bzip2.py \ + test_cal.py \ + test_cancel.py \ + test_cardctl.py \ + test_cat.py \ + test_cc.py \ + test_ccache.py \ + test_ccze.py \ + test_cd.py \ + test_cdrecord.py \ + test_cfagent.py \ + test_cfrun.py \ + test_chage.py \ + test_change_pw.py \ + test_check_db.py \ + test_check_perms.py \ + test_checksec.py \ + test_chfn.py \ + test_chgrp.py \ + test_chkconfig.py \ + test_chmod.py \ + test_chown.py \ + test_chpasswd.py \ + test_chromium_browser.py \ + test_chronyc.py \ + test_chroot.py \ + test_chrpath.py \ + test_chsh.py \ + test_ci.py \ + test_ciptool.py \ + test_civclient.py \ + test_civserver.py \ + test_cksfv.py \ + test_cleanarch.py \ + test_clisp.py \ + test_clone_member.py \ + test_co.py \ + test_compare.py \ + test_complete.py \ + test_composite.py \ + test_config_list.py \ + test_configure.py \ + test_conjure.py \ + test_convert.py \ + test_cowsay.py \ + test_cp.py \ + test_cpan2dist.py \ + test_cpio.py \ + test_cplusplus.py \ + test_cppcheck.py \ + test_createdb.py \ + test_createuser.py \ + test_crontab.py \ + test_cryptsetup.py \ + test_csplit.py \ + test_curl.py \ + test_cut.py \ + test_cvs.py \ + test_cvsps.py \ + test_date.py \ + test_dcop.py \ + test_dd.py \ + test_declare.py \ + test_deja_dup.py \ + test_desktop_file_validate.py \ + test_df.py \ + test_dfutool.py \ + test_dhclient.py \ + test_dict.py \ + test_diff.py \ + test_dir.py \ + test_display.py \ + test_dmesg.py \ + test_dnssec_keygen.py \ + test_dnsspoof.py \ + test_dot.py \ + test_dpkg.py \ + test_dpkg_deb.py \ + test_dpkg_reconfigure.py \ + test_dpkg_source.py \ + test_dropdb.py \ + test_dropuser.py \ + test_dselect.py \ + test_dsniff.py \ + test_du.py \ + test_dumpdb.py \ + test_dumpe2fs.py \ + test_e2freefrag.py \ + test_e2label.py \ + test_ebtables.py \ + test_ecryptfs_migrate_home.py \ + test_eject.py \ + test_enscript.py \ + test_env.py \ + test_eog.py \ + test_ether_wake.py \ + test_etherwake.py \ + test_evince.py \ + test_expand.py \ + test_explodepkg.py \ + test_export.py \ + test_faillog.py \ + test_fbgs.py \ + test_fbi.py \ + test_feh.py \ + test_file.py \ + test_file_roller.py \ + test_filefrag.py \ + test_filesnarf.py \ + test_find.py \ + test_find_member.py \ + test_finger.py \ + test_fio.py \ + test_firefox.py \ + test_flake8.py \ + test_fmt.py \ + test_fold.py \ + test_freebsd_update.py \ + test_freeciv.py \ + test_freeciv_server.py \ + test_function.py \ + test_fusermount.py \ + test_g4.py \ + test_g77.py \ + test_gcc.py \ + test_gcj.py \ + test_gcl.py \ + test_gdb.py \ + test_genaliases.py \ + test_gendiff.py \ + test_genisoimage.py \ + test_geoiplookup.py \ + test_getconf.py \ + test_getent.py \ + test_gkrellm.py \ + test_gm.py \ + test_gmplayer.py \ + test_gnatmake.py \ + test_gnokii.py \ + test_gnome_mplayer.py \ + test_gnome_screenshot.py \ + test_gpasswd.py \ + test_gpc.py \ + test_gperf.py \ + test_gpg.py \ + test_gpg2.py \ + test_gpgv.py \ + test_gphoto2.py \ + test_gplusplus.py \ + test_gprof.py \ + test_grep.py \ + test_groupadd.py \ + test_groupdel.py \ + test_groupmems.py \ + test_groupmod.py \ + test_growisofs.py \ + test_grpck.py \ + test_grub.py \ + test_gzip.py \ + test_hciattach.py \ + test_hciconfig.py \ + test_hcitool.py \ + test_hddtemp.py \ + test_head.py \ + test_hexdump.py \ + test_hid2hci.py \ + test_host.py \ + test_hostname.py \ + test_hping2.py \ + test_hping3.py \ + test_htop.py \ + test_htpasswd.py \ + test_hunspell.py \ + test_hwclock.py \ + test_iconv.py \ + test_id.py \ + test_identify.py \ + test_idn.py \ + test_ifdown.py \ + test_ifstat.py \ + test_iftop.py \ + test_ifup.py \ + test_import.py \ + test_info.py \ + test_inject.py \ + test_inotifywait.py \ + test_inotifywatch.py \ + test_insmod.py \ + test_installpkg.py \ + test_interdiff.py \ + test_invoke_rc_d.py \ + test_ionice.py \ + test_ip.py \ + test_iperf.py \ + test_ipmitool.py \ + test_ipsec.py \ + test_iptables.py \ + test_ipv6calc.py \ + test_irb.py \ + test_iscsiadm.py \ + test_isort.py \ + test_isql.py \ + test_iwconfig.py \ + test_iwlist.py \ + test_iwpriv.py \ + test_iwspy.py \ + test_jar.py \ + test_jarsigner.py \ + test_java.py \ + test_javac.py \ + test_javadoc.py \ + test_javaws.py \ + test_jpegoptim.py \ + test_jps.py \ + test_jq.py \ + test_jshint.py \ + test_json_xs.py \ + test_jsonschema.py \ + test_k3b.py \ + test_kcov.py \ + test_kdvi.py \ + test_kill.py \ + test_killall.py \ + test_kldload.py \ + test_kldunload.py \ + test_koji.py \ + test_kpdf.py \ + test_kplayer.py \ + test_ktutil.py \ + test_l2ping.py \ + test_larch.py \ + test_lastlog.py \ + test_ld.py \ + test_ldapadd.py \ + test_ldapcompare.py \ + test_ldapdelete.py \ + test_ldapmodrdn.py \ + test_ldappasswd.py \ + test_ldapsearch.py \ + test_ldapvi.py \ + test_ldapwhoami.py \ + test_ldd.py \ + test_less.py \ + test_lftp.py \ + test_lftpget.py \ + test_lilo.py \ + test_links.py \ + test_lintian.py \ + test_lintian_info.py \ + test_lisp.py \ + test_list_admins.py \ + test_list_lists.py \ + test_list_members.py \ + test_list_owners.py \ + test_ln.py \ + test_locale_gen.py \ + test_look.py \ + test_lpq.py \ + test_lpr.py \ + test_lrzip.py \ + test_ls.py \ + test_lsof.py \ + test_lspci.py \ + test_lsscsi.py \ + test_lsusb.py \ + test_lua.py \ + test_luac.py \ + test_luseradd.py \ + test_luserdel.py \ + test_lusermod.py \ + test_lvchange.py \ + test_lvcreate.py \ + test_lvdisplay.py \ + test_lvextend.py \ + test_lvm.py \ + test_lvmdiskscan.py \ + test_lvreduce.py \ + test_lvremove.py \ + test_lvrename.py \ + test_lvresize.py \ + test_lvs.py \ + test_lvscan.py \ + test_lz4.py \ + test_lzip.py \ + test_lzma.py \ + test_lzop.py \ + test_m4.py \ + test_macof.py \ + test_mailmanctl.py \ + test_mailsnarf.py \ + test_make.py \ + test_makepkg.py \ + test_man.py \ + test_mc.py \ + test_mcrypt.py \ + test_md5sum.py \ + test_mdadm.py \ + test_mdecrypt.py \ + test_mdtool.py \ + test_medusa.py \ + test_mencoder.py \ + test_mii_diag.py \ + test_mii_tool.py \ + test_minicom.py \ + test_mkdir.py \ + test_mkfifo.py \ + test_mkinitrd.py \ + test_mkisofs.py \ + test_mknod.py \ + test_mktemp.py \ + test_mmsitepass.py \ + test_mock.py \ + test_modinfo.py \ + test_modprobe.py \ + test_module.py \ + test_mogrify.py \ + test_monodevelop.py \ + test_montage.py \ + test_mount.py \ + test_mplayer.py \ + test_mr.py \ + test_msgsnarf.py \ + test_msynctool.py \ + test_mtx.py \ + test_munin_node_configure.py \ + test_munin_run.py \ + test_munindoc.py \ + test_mussh.py \ + test_mutt.py \ + test_muttng.py \ + test_mv.py \ + test_mypy.py \ + test_mysql.py \ + test_mysqladmin.py \ + test_nc.py \ + test_ncftp.py \ + test_nethogs.py \ + test_netstat.py \ + test_newgrp.py \ + test_newlist.py \ + test_newusers.py \ + test_ngrep.py \ + test_nl.py \ + test_nm.py \ + test_nmap.py \ + test_nmcli.py \ + test_nproc.py \ + test_nslookup.py \ + test_nsupdate.py \ + test_ntpdate.py \ + test_objcopy.py \ + test_objdump.py \ + test_od.py \ + test_oggdec.py \ + test_op.py \ + test_openssl.py \ + test_opera.py \ + test_optipng.py \ + test_p4.py \ + test_pack200.py \ + test_passwd.py \ + test_paste.py \ + test_patch.py \ + test_pdftotext.py \ + test_perl.py \ + test_perlcritic.py \ + test_perldoc.py \ + test_perltidy.py \ + test_pgrep.py \ + test_phing.py \ + test_pidof.py \ + test_pine.py \ + test_pinfo.py \ + test_ping.py \ + test_pkg_config.py \ + test_pkg_deinstall.py \ + test_pkg_delete.py \ + test_pkg_get.py \ + test_pkg_info.py \ + test_pkgadd.py \ + test_pkgrm.py \ + test_pkgtool.py \ + test_pkgutil.py \ + test_pkill.py \ + test_plague_client.py \ + test_pm_hibernate.py \ + test_pm_is_supported.py \ + test_pm_powersave.py \ + test_pngfix.py \ + test_portinstall.py \ + test_portsnap.py \ + test_portupgrade.py \ + test_postcat.py \ + test_postconf.py \ + test_postfix.py \ + test_postmap.py \ + test_postsuper.py \ + test_povray.py \ + test_pr.py \ + test_prelink.py \ + test_protoc.py \ + test_psql.py \ + test_ptx.py \ + test_puppet.py \ + test_pushd.py \ + test_pv.py \ + test_pvchange.py \ + test_pvcreate.py \ + test_pvdisplay.py \ + test_pvmove.py \ + test_pvremove.py \ + test_pvs.py \ + test_pvscan.py \ + test_pwck.py \ + test_pwd.py \ + test_pwdx.py \ + test_pwgen.py \ + test_pycodestyle.py \ + test_pydoc.py \ + test_pydocstyle.py \ + test_pyflakes.py \ + test_pylint.py \ + test_pylint_3.py \ + test_pytest.py \ + test_python.py \ + test_python3.py \ + test_pyvenv.py \ + test_qemu.py \ + test_qrunner.py \ + test_querybts.py \ + test_quota.py \ + test_quotacheck.py \ + test_quotaon.py \ + test_radvdump.py \ + test_rcs.py \ + test_rcsdiff.py \ + test_rdesktop.py \ + test_rdict.py \ + test_readelf.py \ + test_readonly.py \ + test_remove_members.py \ + test_removepkg.py \ + test_renice.py \ + test_repomanage.py \ + test_reportbug.py \ + test_reptyr.py \ + test_resolvconf.py \ + test_rfcomm.py \ + test_rfkill.py \ + test_ri.py \ + test_rlog.py \ + test_rm.py \ + test_rmdir.py \ + test_rmlist.py \ + test_rmmod.py \ + test_route.py \ + test_rpcdebug.py \ + test_rpm.py \ + test_rpm2tgz.py \ + test_rpmbuild.py \ + test_rrdtool.py \ + test_rsync.py \ + test_rtcwake.py \ + test_runuser.py \ + test_sbcl.py \ + test_sbcl_mt.py \ + test_sbopkg.py \ + test_screen.py \ + test_scrub.py \ + test_sdptool.py \ + test_sed.py \ + test_seq.py \ + test_service.py \ + test_set.py \ + test_setquota.py \ + test_sftp.py \ + test_sh.py \ + test_sha1sum.py \ + test_shar.py \ + test_shellcheck.py \ + test_sitecopy.py \ + test_slackpkg.py \ + test_slapt_get.py \ + test_slapt_src.py \ + test_smartctl.py \ + test_smbcacls.py \ + test_smbclient.py \ + test_smbcquotas.py \ + test_smbget.py \ + test_smbpasswd.py \ + test_smbtar.py \ + test_smbtree.py \ + test_snownews.py \ + test_sort.py \ + test_split.py \ + test_spovray.py \ + test_sqlite3.py \ + test_ss.py \ + test_ssh.py \ + test_ssh_add.py \ + test_ssh_copy_id.py \ + test_ssh_keygen.py \ + test_sshfs.py \ + test_sshmitm.py \ + test_sshow.py \ + test_strace.py \ + test_stream.py \ + test_strings.py \ + test_strip.py \ + test_su.py \ + test_sudo.py \ + test_svcadm.py \ + test_svk.py \ + test_svn.py \ + test_svnadmin.py \ + test_svnlook.py \ + test_sync_members.py \ + test_synclient.py \ + test_sysbench.py \ + test_sysctl.py \ + test_tac.py \ + test_tail.py \ + test_tar.py \ + test_tcpdump.py \ + test_tcpkill.py \ + test_tcpnice.py \ + test_tee.py \ + test_texindex.py \ + test_tightvncviewer.py \ + test_time.py \ + test_timeout.py \ + test_tipc.py \ + test_touch.py \ + test_tox.py \ + test_tr.py \ + test_tracepath.py \ + test_tshark.py \ + test_tune2fs.py \ + test_udevadm.py \ + test_ulimit.py \ + test_umount.py \ + test_unace.py \ + test_uname.py \ + test_unexpand.py \ + test_uniq.py \ + test_units.py \ + test_unpack200.py \ + test_unrar.py \ + test_unset.py \ + test_unshunt.py \ + test_update_alternatives.py \ + test_update_rc_d.py \ + test_upgradepkg.py \ + test_urlsnarf.py \ + test_uscan.py \ + test_useradd.py \ + test_userdel.py \ + test_usermod.py \ + test_valgrind.py \ + test_vdir.py \ + test_vgcfgbackup.py \ + test_vgcfgrestore.py \ + test_vgchange.py \ + test_vgck.py \ + test_vgconvert.py \ + test_vgcreate.py \ + test_vgdisplay.py \ + test_vgexport.py \ + test_vgextend.py \ + test_vgimport.py \ + test_vgmerge.py \ + test_vgmknodes.py \ + test_vgreduce.py \ + test_vgremove.py \ + test_vgrename.py \ + test_vgs.py \ + test_vgscan.py \ + test_vgsplit.py \ + test_vi.py \ + test_vipw.py \ + test_vmstat.py \ + test_vncviewer.py \ + test_vpnc.py \ + test_watch.py \ + test_wc.py \ + test_webmitm.py \ + test_wget.py \ + test_who.py \ + test_wine.py \ + test_withlist.py \ + test_wodim.py \ + test_wol.py \ + test_write.py \ + test_wsimport.py \ + test_wtf.py \ + test_wvdial.py \ + test_xdg_mime.py \ + test_xdg_settings.py \ + test_xfreerdp.py \ + test_xgamma.py \ + test_xm.py \ + test_xmllint.py \ + test_xmlwf.py \ + test_xmms.py \ + test_xmodmap.py \ + test_xpovray.py \ + test_xrandr.py \ + test_xrdb.py \ + test_xsltproc.py \ + test_xvnc4viewer.py \ + test_xxd.py \ + test_xz.py \ + test_xzdec.py \ + test_ypcat.py \ + test_ypmatch.py \ + test_yum.py \ + test_yum_arch.py \ + test_zopfli.py \ + test_zopflipng.py + +all: + +PYTEST = pytest + +check-local: + $(PYTEST) $(PYTESTFLAGS) $(srcdir) + +clean-local: + $(RM) -R __pycache__ diff --git a/test/t/conftest.py b/test/t/conftest.py new file mode 100644 index 00000000..0969a313 --- /dev/null +++ b/test/t/conftest.py @@ -0,0 +1,461 @@ +import difflib +import os +import re +import shlex +from typing import Iterable, List, Optional, Tuple, Union + +import pexpect +import pytest + + +PS1 = "/@" +MAGIC_MARK = "__MaGiC-maRKz!__" + + +def find_unique_completion_pair( + items: Iterable[str] +) -> Optional[Tuple[str, str]]: + result = None + bestscore = 0 + sitems = sorted(set(items)) + for i in range(len(sitems)): + cur = sitems[i] + curlen = len(cur) + prv = sitems[i - 1] if i != 0 else "" + prvlen = len(prv) + nxt = sitems[i + 1] if i < len(sitems) - 1 else "" + nxtlen = len(nxt) + diffprv = prv == "" + diffnxt = nxt == "" + # Analyse each item of the list and look for the minimum length of the + # partial prefix which is distinct from both nxt and prv. The list + # is sorted so the prefix will be unique in the entire list. + for j in range(curlen): + curchar = cur[j] + if not diffprv and (j >= prvlen or prv[j] != curchar): + diffprv = True + if not diffnxt and (j >= nxtlen or nxt[j] != curchar): + diffnxt = True + if diffprv and diffnxt: + break + # At the end of the loop, j is the index of last character of + # the unique partial prefix. The length is one plus that. + parlen = j + 1 + if parlen >= curlen: + continue + # Try to find the most "readable pair"; look for a long pair where + # part is about half of full. + if parlen < curlen / 2: + parlen = int(curlen / 2) + score = curlen - parlen + if score > bestscore: + bestscore = score + result = (cur[:parlen], cur) + return result + + +@pytest.fixture(scope="class") +def part_full_user(bash: pexpect.spawn) -> Optional[Tuple[str, str]]: + res = ( + assert_bash_exec(bash, "compgen -u", want_output=True).strip().split() + ) + pair = find_unique_completion_pair(res) + if not pair: + pytest.skip("No suitable test user found") + return pair + + +@pytest.fixture(scope="class") +def part_full_group(bash: pexpect.spawn) -> Optional[Tuple[str, str]]: + res = ( + assert_bash_exec(bash, "compgen -g", want_output=True).strip().split() + ) + pair = find_unique_completion_pair(res) + if not pair: + pytest.skip("No suitable test user found") + return pair + + +@pytest.fixture(scope="class") +def bash(request) -> pexpect.spawn: + + logfile = None + if os.environ.get("BASHCOMP_TEST_LOGFILE"): + logfile = open(os.environ.get("BASHCOMP_TEST_LOGFILE"), "w") + testdir = os.path.abspath( + os.path.join(os.path.dirname(__file__), os.pardir) + ) + env = os.environ.copy() + env.update( + dict( + SRCDIR=testdir, # TODO needed at least by bashrc + SRCDIRABS=testdir, # TODO needed? + PS1=PS1, + INPUTRC="%s/config/inputrc" % testdir, + TERM="dumb", + BASH_COMPLETION_COMPAT_DIR="%s/fixtures/shared/empty_dir" + % testdir, + LC_COLLATE="C", # to match Python's default locale unaware sort + ) + ) + + fixturesdir = os.path.join(testdir, "fixtures") + os.chdir(fixturesdir) + + # Start bash + bash = pexpect.spawn( + "%s --norc" % os.environ.get("BASHCOMP_TEST_BASH", "bash"), + maxread=os.environ.get("BASHCOMP_TEST_PEXPECT_MAXREAD", 20000), + logfile=logfile, + cwd=fixturesdir, + env=env, + encoding="utf-8", # TODO? or native or...? + # FIXME: Tests shouldn't depend on dimensions, but it's difficult to + # expect robustly enough for Bash to wrap lines anywhere (e.g. inside + # MAGIC_MARK). Increase window width to reduce wrapping. + dimensions=(24, 160), + # TODO? codec_errors="replace", + ) + bash.expect_exact(PS1) + + # Load bashrc and bash_completion + assert_bash_exec(bash, "source '%s/config/bashrc'" % testdir) + assert_bash_exec(bash, "source '%s/../bash_completion'" % testdir) + + # Use command name from marker if set, or grab from test filename + cmd = None + cmd_found = False + marker = request.node.get_closest_marker("bashcomp") + if marker: + cmd = marker.kwargs.get("cmd") + cmd_found = "cmd" in marker.kwargs + # Run pre-test commands, early so they're usable in skipif + for pre_cmd in marker.kwargs.get("pre_cmds", []): + assert_bash_exec(bash, pre_cmd) + # Process skip conditions + skipif = marker.kwargs.get("skipif") + if skipif: + try: + assert_bash_exec(bash, skipif) + except AssertionError: + pass + else: + bash.close() + pytest.skip(skipif) + return + if not cmd_found: + match = re.search( + r"^test_(.+)\.py$", os.path.basename(str(request.fspath)) + ) + if match: + cmd = match.group(1) + + if (cmd_found and cmd is None) or is_testable(bash, cmd): + before_env = get_env(bash) + yield bash + # Not exactly sure why, but some errors leave bash in state where + # getting the env here would fail and trash our test output. So + # reset to a good state first (Ctrl+C, expect prompt). + bash.sendintr() + bash.expect_exact(PS1) + diff_env( + before_env, + get_env(bash), + marker.kwargs.get("ignore_env") if marker else "", + ) + + if marker: + for post_cmd in marker.kwargs.get("post_cmds", []): + assert_bash_exec(bash, post_cmd) + + # Clean up + bash.close() + if logfile: + logfile.close() + + +def is_testable(bash: pexpect.spawn, cmd: str) -> bool: + if not cmd: + pytest.fail("Could not resolve name of command to test") + return False + if not is_bash_type(bash, cmd): + pytest.skip("Command %s not found" % cmd) + return False + if not load_completion_for(bash, cmd): + pytest.skip("No completion for command %s" % cmd) + return False + return True + + +def is_bash_type(bash: pexpect.spawn, cmd: str) -> bool: + typecmd = "type %s &>/dev/null && echo -n 0 || echo -n 1" % cmd + bash.sendline(typecmd) + bash.expect_exact(typecmd + "\r\n") + result = bash.expect_exact(["0", "1"]) == 0 + bash.expect_exact(PS1) + return result + + +def load_completion_for(bash: pexpect.spawn, cmd: str) -> bool: + try: + # Allow __load_completion to fail so we can test completions + # that are directly loaded in bash_completion without a separate file. + assert_bash_exec(bash, "__load_completion %s || :" % cmd) + assert_bash_exec(bash, "complete -p %s &>/dev/null" % cmd) + except AssertionError: + return False + return True + + +def assert_bash_exec( + bash: pexpect.spawn, cmd: str, want_output: bool = False +) -> str: + + # Send command + bash.sendline(cmd) + bash.expect_exact(cmd) + + # Find prompt, output is before it + bash.expect_exact("\r\n" + PS1) + output = bash.before + + # Retrieve exit status + echo = "echo $?" + bash.sendline(echo) + got = bash.expect( + [ + r"^%s\r\n(\d+)\r\n%s" % (re.escape(echo), re.escape(PS1)), + PS1, + pexpect.EOF, + pexpect.TIMEOUT, + ] + ) + status = bash.match.group(1) if got == 0 else "unknown" + + assert status == "0", 'Error running "%s": exit status=%s, output="%s"' % ( + cmd, + status, + output, + ) + if output: + assert want_output, ( + 'Unexpected output from "%s": exit status=%s, output="%s"' + % (cmd, status, output) + ) + else: + assert not want_output, ( + 'Expected output from "%s": exit status=%s, output="%s"' + % (cmd, status, output) + ) + + return output + + +def get_env(bash: pexpect.spawn) -> List[str]: + return ( + assert_bash_exec( + bash, + "{ (set -o posix ; set); declare -F; shopt -p; set -o; }", + want_output=True, + ) + .strip() + .splitlines() + ) + + +def diff_env(before: List[str], after: List[str], ignore: str): + diff = [ + x + for x in difflib.unified_diff(before, after, n=0, lineterm="") + # Remove unified diff markers: + if not re.search(r"^(---|\+\+\+|@@ )", x) + # Ignore variables expected to change: + and not re.search("^[-+](_|PPID|BASH_REMATCH|OLDPWD)=", x) + # Ignore likely completion functions added by us: + and not re.search(r"^\+declare -f _.+", x) + # ...and additional specified things: + and not re.search(ignore or "^$", x) + ] + # For some reason, COMP_WORDBREAKS gets added to the list after + # saving. Remove its changes, and note that it may take two lines. + for i in range(0, len(diff)): + if re.match("^[-+]COMP_WORDBREAKS=", diff[i]): + if i < len(diff) and not re.match(r"^\+[\w]+=", diff[i + 1]): + del diff[i + 1] + del diff[i] + break + assert not diff, "Environment should not be modified" + + +class CompletionResult: + """ + Class to hold completion results. + """ + + def __init__(self, output: str, items: Optional[Iterable[str]] = None): + """ + When items are specified, they are used as the base for comparisons + provided by this class. When not, regular expressions are used instead. + This is because it is not always possible to unambiguously split a + completion output string into individual items, for example when the + items contain whitespace. + + :param output: All completion output as-is. + :param items: Completions as individual items. Should be specified + only in cases where the completions are robustly known to be + exactly the specified ones. + """ + self.output = output + self._items = None if items is None else sorted(items) + + def endswith(self, suffix: str) -> bool: + return self.output.endswith(suffix) + + def __eq__(self, expected: Union[str, Iterable[str]]) -> bool: + """ + Returns True if completion contains expected items, and no others. + + Defining __eq__ this way is quite ugly, but facilitates concise + testing code. + """ + expiter = [expected] if isinstance(expected, str) else sorted(expected) + if self._items is not None: + return self._items == expiter + return bool( + re.match( + r"^\s*" + r"\s+".join(re.escape(x) for x in expiter) + r"\s*$", + self.output, + ) + ) + + def __contains__(self, item: str) -> bool: + if self._items is not None: + return item in self._items + return bool( + re.search(r"(^|\s)%s(\s|$)" % re.escape(item), self.output) + ) + + def __iter__(self) -> Iterable[str]: + """ + Note that iteration over items may not be accurate when items were not + specified to the constructor, if individual items in the output contain + whitespace. In those cases, it errs on the side of possibly returning + more items than there actually are, and intends to never return fewer. + """ + return iter( + self._items + if self._items is not None + else re.split(r" {2,}|\r\n", self.output.strip()) + ) + + def __len__(self) -> int: + """ + Uses __iter__, see caveat in it. While possibly inaccurate, this is + good enough for truthiness checks. + """ + return len(list(iter(self))) + + def __repr__(self) -> str: + return "<CompletionResult %s>" % list(self) + + +def assert_complete( + bash: pexpect.spawn, cmd: str, **kwargs +) -> CompletionResult: + skipif = kwargs.get("skipif") + if skipif: + try: + assert_bash_exec(bash, skipif) + except AssertionError: + pass + else: + pytest.skip(skipif) + return CompletionResult("", []) + cwd = kwargs.get("cwd") + if cwd: + assert_bash_exec(bash, "cd '%s'" % cwd) + env_prefix = "_BASHCOMP_TEST_" + env = kwargs.get("env", {}) + if env: + # Back up environment and apply new one + assert_bash_exec( + bash, + " ".join('%s%s="$%s"' % (env_prefix, k, k) for k in env.keys()), + ) + assert_bash_exec( + bash, + "export %s" % " ".join("%s=%s" % (k, v) for k, v in env.items()), + ) + bash.send(cmd + "\t") + bash.expect_exact(cmd) + bash.send(MAGIC_MARK) + got = bash.expect( + [ + # 0: multiple lines, result in .before + r"\r\n" + re.escape(PS1 + cmd) + ".*" + MAGIC_MARK, + # 1: no completion + r"^" + MAGIC_MARK, + # 2: on same line, result in .match + r"^([^\r]+)%s$" % MAGIC_MARK, + pexpect.EOF, + pexpect.TIMEOUT, + ] + ) + if got == 0: + output = bash.before + if output.endswith(MAGIC_MARK): + output = bash.before[: -len(MAGIC_MARK)] + result = CompletionResult(output) + elif got == 2: + output = bash.match.group(1) + result = CompletionResult(output, [shlex.split(cmd + output)[-1]]) + else: + # TODO: warn about EOF/TIMEOUT? + result = CompletionResult("", []) + bash.sendintr() + bash.expect_exact(PS1) + if env: + # Restore environment, and clean up backup + # TODO: Test with declare -p if a var was set, backup only if yes, and + # similarly restore only backed up vars. Should remove some need + # for ignore_env. + assert_bash_exec( + bash, + "export %s" + % " ".join('%s="$%s%s"' % (k, env_prefix, k) for k in env.keys()), + ) + assert_bash_exec( + bash, + "unset -v %s" + % " ".join("%s%s" % (env_prefix, k) for k in env.keys()), + ) + if cwd: + assert_bash_exec(bash, "cd - >/dev/null") + return result + + +@pytest.fixture +def completion(request, bash: pexpect.spawn) -> CompletionResult: + marker = request.node.get_closest_marker("complete") + if not marker: + return CompletionResult("", []) + for pre_cmd in marker.kwargs.get("pre_cmds", []): + assert_bash_exec(bash, pre_cmd) + return assert_complete(bash, marker.args[0], **marker.kwargs) + + +def in_docker() -> bool: + return os.path.exists("/.dockerenv") + + +class TestUnitBase: + def _test_unit( + self, func, bash, comp_words, comp_cword, comp_line, comp_point, arg="" + ): + assert_bash_exec( + bash, + "COMP_WORDS=%s COMP_CWORD=%d COMP_LINE=%s COMP_POINT=%d" + % (comp_words, comp_cword, shlex.quote(comp_line), comp_point), + ) + output = assert_bash_exec(bash, func % arg, want_output=True) + return output.strip() diff --git a/test/t/test_2to3.py b/test/t/test_2to3.py new file mode 100644 index 00000000..966ed1f5 --- /dev/null +++ b/test/t/test_2to3.py @@ -0,0 +1,7 @@ +import pytest + + +class Test2to3: + @pytest.mark.complete("2to3 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_7z.py b/test/t/test_7z.py new file mode 100644 index 00000000..7d68c7b2 --- /dev/null +++ b/test/t/test_7z.py @@ -0,0 +1,34 @@ +import pytest + + +class Test7z: + @pytest.mark.complete("7z ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("7z a ar -tzi") + def test_2(self, completion): + assert completion == "-tzip" + + @pytest.mark.xfail # TODO: whitespace split issue + @pytest.mark.complete(r"7z x -wa\ ", cwd="_filedir") + def test_3(self, completion): + assert completion == r"-wa\ b/" + assert not completion.endswith(" ") + + @pytest.mark.complete("7z x ", cwd="7z") + def test_4(self, completion): + assert completion == "a.7z" + + @pytest.mark.complete("7z d a.7z ", cwd="7z") + def test_5(self, completion): + assert completion == "abc" + + @pytest.mark.complete("7z a -air@", cwd="7z") + def test_6(self, completion): + assert completion == sorted("-air@a.7z -air@f.txt".split()) + + @pytest.mark.complete("7z a -o") + def test_7(self, completion): + assert "-o7z/" in completion + assert all(x.endswith("/") for x in completion) diff --git a/test/t/test_a2ps.py b/test/t/test_a2ps.py new file mode 100644 index 00000000..9d885461 --- /dev/null +++ b/test/t/test_a2ps.py @@ -0,0 +1,7 @@ +import pytest + + +class TestA2ps: + @pytest.mark.complete("a2ps ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_a2x.py b/test/t/test_a2x.py new file mode 100644 index 00000000..3741e28d --- /dev/null +++ b/test/t/test_a2x.py @@ -0,0 +1,7 @@ +import pytest + + +class TestA2x: + @pytest.mark.complete("a2x ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_abook.py b/test/t/test_abook.py new file mode 100644 index 00000000..1df910cf --- /dev/null +++ b/test/t/test_abook.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAbook: + @pytest.mark.complete("abook -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_aclocal.py b/test/t/test_aclocal.py new file mode 100644 index 00000000..cb3aca1b --- /dev/null +++ b/test/t/test_aclocal.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAclocal: + @pytest.mark.complete("aclocal ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_acpi.py b/test/t/test_acpi.py new file mode 100644 index 00000000..8da4eaf4 --- /dev/null +++ b/test/t/test_acpi.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAcpi: + @pytest.mark.complete("acpi -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_acroread.py b/test/t/test_acroread.py new file mode 100644 index 00000000..471b93c2 --- /dev/null +++ b/test/t/test_acroread.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAcroread: + @pytest.mark.complete("acroread ", cwd="fixtures/acroread") + def test_1(self, completion): + assert completion == "foo.d/ t.pdf".split() diff --git a/test/t/test_adb.py b/test/t/test_adb.py new file mode 100644 index 00000000..081a1047 --- /dev/null +++ b/test/t/test_adb.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAdb: + @pytest.mark.complete("adb ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_add_members.py b/test/t/test_add_members.py new file mode 100644 index 00000000..095a5ded --- /dev/null +++ b/test/t/test_add_members.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAddMembers: + @pytest.mark.complete("add_members -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_alias.py b/test/t/test_alias.py new file mode 100644 index 00000000..da9ecc33 --- /dev/null +++ b/test/t/test_alias.py @@ -0,0 +1,17 @@ +import pytest + + +@pytest.mark.bashcomp( + pre_cmds=("unalias -a", "alias foo=bar", "alias bar='foo foo'"), + post_cmds=("unalias -a",), +) +class TestAlias: + @pytest.mark.complete("alias ") + def test_1(self, completion): + assert completion == "bar foo".split() + + @pytest.mark.xfail # TODO: Would like this completion to work + @pytest.mark.complete("alias foo=") + def test_2(self, completion): + assert completion == "foo='bar'" + assert not completion.endswith(" ") diff --git a/test/t/test_alpine.py b/test/t/test_alpine.py new file mode 100644 index 00000000..a8a83a0b --- /dev/null +++ b/test/t/test_alpine.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAlpine: + @pytest.mark.complete("alpine -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_animate.py b/test/t/test_animate.py new file mode 100644 index 00000000..2103606e --- /dev/null +++ b/test/t/test_animate.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAnimate: + @pytest.mark.complete("animate ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ant.py b/test/t/test_ant.py new file mode 100644 index 00000000..e18b6eb4 --- /dev/null +++ b/test/t/test_ant.py @@ -0,0 +1,26 @@ +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^\+ANT_ARGS=") +class TestAnt: + @pytest.mark.complete("ant -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ant ", cwd="ant") + def test_2(self, completion): + assert completion == "bashcomp clean init realclean".split() + + @pytest.mark.complete("ant -f build-with-import.xml ", cwd="ant") + def test_3(self, completion): + assert completion == "build-with-import imported-build".split() + + @pytest.mark.complete( + "ant ", cwd="ant", env=dict(ANT_ARGS="'-f named-build.xml'") + ) + def test_4(self, completion): + assert completion == "named-build" + + @pytest.mark.complete("ant -l ") + def test_5(self, completion): + assert completion diff --git a/test/t/test_apache2ctl.py b/test/t/test_apache2ctl.py new file mode 100644 index 00000000..856a0e4d --- /dev/null +++ b/test/t/test_apache2ctl.py @@ -0,0 +1,7 @@ +import pytest + + +class TestApache2ctl: + @pytest.mark.complete("apache2ctl ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_appdata_validate.py b/test/t/test_appdata_validate.py new file mode 100644 index 00000000..d57aa992 --- /dev/null +++ b/test/t/test_appdata_validate.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="appdata-validate") +class TestAppdataValidate: + @pytest.mark.complete("appdata-validate ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_apt_build.py b/test/t/test_apt_build.py new file mode 100644 index 00000000..8346e110 --- /dev/null +++ b/test/t/test_apt_build.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="apt-build") +class TestAptBuild: + @pytest.mark.complete("apt-build ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_apt_cache.py b/test/t/test_apt_cache.py new file mode 100644 index 00000000..0cb50ef6 --- /dev/null +++ b/test/t/test_apt_cache.py @@ -0,0 +1,13 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="apt-cache") +class TestAptCache: + @pytest.mark.complete("apt-cache ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("apt-cache showsrc [") + def test_2(self, completion): + # Doesn't actually fail on grep errors, but takes a long time. + assert not completion diff --git a/test/t/test_apt_get.py b/test/t/test_apt_get.py new file mode 100644 index 00000000..ccdff6cd --- /dev/null +++ b/test/t/test_apt_get.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="apt-get") +class TestAptGet: + @pytest.mark.complete("apt-get ") + def test_1(self, completion): + assert all(x in completion for x in "install update".split()) + + @pytest.mark.complete("apt-get install ./", cwd="dpkg") + def test_2(self, completion): + assert completion == "./bash-completion-test-subject.deb" diff --git a/test/t/test_aptitude.py b/test/t/test_aptitude.py new file mode 100644 index 00000000..c59c3580 --- /dev/null +++ b/test/t/test_aptitude.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAptitude: + @pytest.mark.complete("aptitude ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_arch.py b/test/t/test_arch.py new file mode 100644 index 00000000..69e0b1ae --- /dev/null +++ b/test/t/test_arch.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestArch: + @pytest.mark.complete("arch -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_arp.py b/test/t/test_arp.py new file mode 100644 index 00000000..35963d75 --- /dev/null +++ b/test/t/test_arp.py @@ -0,0 +1,14 @@ +import pytest + +from conftest import in_docker + + +class TestArp: + @pytest.mark.xfail(in_docker(), reason="Probably fails in docker") + @pytest.mark.complete("arp ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("arp -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_arping.py b/test/t/test_arping.py new file mode 100644 index 00000000..850344be --- /dev/null +++ b/test/t/test_arping.py @@ -0,0 +1,11 @@ +import pytest + + +class TestArping: + @pytest.mark.complete("arping ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("arping -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_arpspoof.py b/test/t/test_arpspoof.py new file mode 100644 index 00000000..9fcf20b7 --- /dev/null +++ b/test/t/test_arpspoof.py @@ -0,0 +1,7 @@ +import pytest + + +class TestArpspoof: + @pytest.mark.complete("arpspoof -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_asciidoc.py b/test/t/test_asciidoc.py new file mode 100644 index 00000000..b295a27d --- /dev/null +++ b/test/t/test_asciidoc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAsciidoc: + @pytest.mark.complete("asciidoc ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_aspell.py b/test/t/test_aspell.py new file mode 100644 index 00000000..b7a03c41 --- /dev/null +++ b/test/t/test_aspell.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAspell: + @pytest.mark.complete("aspell ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_autoconf.py b/test/t/test_autoconf.py new file mode 100644 index 00000000..9b98b625 --- /dev/null +++ b/test/t/test_autoconf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAutoconf: + @pytest.mark.complete("autoconf ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_autoheader.py b/test/t/test_autoheader.py new file mode 100644 index 00000000..57ad8af1 --- /dev/null +++ b/test/t/test_autoheader.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAutoheader: + @pytest.mark.complete("autoheader ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_automake.py b/test/t/test_automake.py new file mode 100644 index 00000000..5d25c6a7 --- /dev/null +++ b/test/t/test_automake.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAutomake: + @pytest.mark.complete("automake ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_autoreconf.py b/test/t/test_autoreconf.py new file mode 100644 index 00000000..10e2a2e8 --- /dev/null +++ b/test/t/test_autoreconf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAutoreconf: + @pytest.mark.complete("autoreconf ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_autorpm.py b/test/t/test_autorpm.py new file mode 100644 index 00000000..185585e0 --- /dev/null +++ b/test/t/test_autorpm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAutorpm: + @pytest.mark.complete("autorpm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_autoscan.py b/test/t/test_autoscan.py new file mode 100644 index 00000000..b2667543 --- /dev/null +++ b/test/t/test_autoscan.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAutoscan: + @pytest.mark.complete("autoscan ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_autoupdate.py b/test/t/test_autoupdate.py new file mode 100644 index 00000000..13fd8d4d --- /dev/null +++ b/test/t/test_autoupdate.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAutoupdate: + @pytest.mark.complete("autoupdate ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_avctrl.py b/test/t/test_avctrl.py new file mode 100644 index 00000000..6ff1ec38 --- /dev/null +++ b/test/t/test_avctrl.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAvctrl: + @pytest.mark.complete("avctrl ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_awk.py b/test/t/test_awk.py new file mode 100644 index 00000000..ad2034d1 --- /dev/null +++ b/test/t/test_awk.py @@ -0,0 +1,7 @@ +import pytest + + +class TestAwk: + @pytest.mark.complete("awk ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_badblocks.py b/test/t/test_badblocks.py new file mode 100644 index 00000000..57a559de --- /dev/null +++ b/test/t/test_badblocks.py @@ -0,0 +1,7 @@ +import pytest + + +class TestBadblocks: + @pytest.mark.complete("badblocks ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_base64.py b/test/t/test_base64.py new file mode 100644 index 00000000..efc35ebb --- /dev/null +++ b/test/t/test_base64.py @@ -0,0 +1,7 @@ +import pytest + + +class TestBase64: + @pytest.mark.complete("base64 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_bash.py b/test/t/test_bash.py new file mode 100644 index 00000000..d6e6959a --- /dev/null +++ b/test/t/test_bash.py @@ -0,0 +1,7 @@ +import pytest + + +class TestBash: + @pytest.mark.complete("bash --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_bc.py b/test/t/test_bc.py new file mode 100644 index 00000000..effcbaea --- /dev/null +++ b/test/t/test_bc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestBc: + @pytest.mark.complete("bc --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_bind.py b/test/t/test_bind.py new file mode 100644 index 00000000..f97a246e --- /dev/null +++ b/test/t/test_bind.py @@ -0,0 +1,11 @@ +import pytest + + +class TestBind: + @pytest.mark.complete("bind -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("bind k") + def test_2(self, completion): + assert completion diff --git a/test/t/test_bison.py b/test/t/test_bison.py new file mode 100644 index 00000000..47c4908c --- /dev/null +++ b/test/t/test_bison.py @@ -0,0 +1,7 @@ +import pytest + + +class TestBison: + @pytest.mark.complete("bison --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_bk.py b/test/t/test_bk.py new file mode 100644 index 00000000..8ab44b68 --- /dev/null +++ b/test/t/test_bk.py @@ -0,0 +1,7 @@ +import pytest + + +class TestBk: + @pytest.mark.complete("bk ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_brctl.py b/test/t/test_brctl.py new file mode 100644 index 00000000..7c773e97 --- /dev/null +++ b/test/t/test_brctl.py @@ -0,0 +1,7 @@ +import pytest + + +class TestBrctl: + @pytest.mark.complete("brctl ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_btdownloadcurses_py.py b/test/t/test_btdownloadcurses_py.py new file mode 100644 index 00000000..0b65519a --- /dev/null +++ b/test/t/test_btdownloadcurses_py.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="btdownloadcurses.py") +class TestBtdownloadcursesPy: + @pytest.mark.complete("btdownloadcurses.py ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_btdownloadgui_py.py b/test/t/test_btdownloadgui_py.py new file mode 100644 index 00000000..c1b1b38a --- /dev/null +++ b/test/t/test_btdownloadgui_py.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="btdownloadgui.py") +class TestBtdownloadguiPy: + @pytest.mark.complete("btdownloadgui.py ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_btdownloadheadless_py.py b/test/t/test_btdownloadheadless_py.py new file mode 100644 index 00000000..f84592fa --- /dev/null +++ b/test/t/test_btdownloadheadless_py.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="btdownloadheadless.py") +class TestBtdownloadheadlessPy: + @pytest.mark.complete("btdownloadheadless.py ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_bts.py b/test/t/test_bts.py new file mode 100644 index 00000000..53dd62fc --- /dev/null +++ b/test/t/test_bts.py @@ -0,0 +1,11 @@ +import pytest + + +class TestBts: + @pytest.mark.complete("bts ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("bts -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_bzip2.py b/test/t/test_bzip2.py new file mode 100644 index 00000000..d1cad249 --- /dev/null +++ b/test/t/test_bzip2.py @@ -0,0 +1,11 @@ +import pytest + + +class TestBzip2: + @pytest.mark.complete("bzip2 ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("bzip2 ~") + def test_2(self, completion): + assert completion diff --git a/test/t/test_cal.py b/test/t/test_cal.py new file mode 100644 index 00000000..27102c7a --- /dev/null +++ b/test/t/test_cal.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCal: + @pytest.mark.complete("cal ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cancel.py b/test/t/test_cancel.py new file mode 100644 index 00000000..4aeafd2c --- /dev/null +++ b/test/t/test_cancel.py @@ -0,0 +1,34 @@ +import pytest + +from conftest import assert_bash_exec + + +class TestCancel: + @pytest.fixture(scope="class") + def added_job(self, request, bash): + try: + got = ( + assert_bash_exec( + bash, "lp -H hold shared/default/foo", want_output=True + ) + .strip() + .split() + ) + except AssertionError: + pytest.skip("Could not add test print job") + return + if len(got) > 3: + request.addfinalizer( + lambda: assert_bash_exec(bash, "cancel %s" % got[3]) + ) + + @pytest.mark.complete("cancel ") + def test_1(self, bash, completion, added_job): + got = ( + assert_bash_exec( + bash, "lpstat | awk '{print $1}'", want_output=True + ) + .strip() + .split() + ) + assert completion == sorted(got) diff --git a/test/t/test_cardctl.py b/test/t/test_cardctl.py new file mode 100644 index 00000000..df28b6bd --- /dev/null +++ b/test/t/test_cardctl.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCardctl: + @pytest.mark.complete("cardctl ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cat.py b/test/t/test_cat.py new file mode 100644 index 00000000..94245e8f --- /dev/null +++ b/test/t/test_cat.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCat: + @pytest.mark.complete("cat ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cc.py b/test/t/test_cc.py new file mode 100644 index 00000000..12f6b2b5 --- /dev/null +++ b/test/t/test_cc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCc: + @pytest.mark.complete("cc ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ccache.py b/test/t/test_ccache.py new file mode 100644 index 00000000..573e3e44 --- /dev/null +++ b/test/t/test_ccache.py @@ -0,0 +1,27 @@ +import pytest + + +class TestCcache: + @pytest.mark.complete("ccache -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ccache --clea") + def test_2(self, completion): + assert all(x in completion for x in "--cleanup --clear".split()) + + @pytest.mark.complete("ccache stt") + def test_3(self, completion): + assert "stty" in completion + + @pytest.mark.complete("ccache --zero-stats stt") + def test_4(self, completion): + assert "stty" in completion + + @pytest.mark.complete("ccache --hel") + def test_5(self, completion): + assert "--help" in completion + + @pytest.mark.complete("ccache --zero-stats ls --hel") + def test_6(self, completion): + assert "--help" in completion diff --git a/test/t/test_ccze.py b/test/t/test_ccze.py new file mode 100644 index 00000000..c54a1fa1 --- /dev/null +++ b/test/t/test_ccze.py @@ -0,0 +1,19 @@ +import pytest + + +class TestCcze: + @pytest.mark.complete("ccze ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ccze -? ") + def test_2(self, completion): + assert not completion + + @pytest.mark.complete("ccze -o ") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("ccze --plugin=") + def test_4(self, completion): + assert completion diff --git a/test/t/test_cd.py b/test/t/test_cd.py new file mode 100644 index 00000000..fd532312 --- /dev/null +++ b/test/t/test_cd.py @@ -0,0 +1,22 @@ +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^\+CDPATH=$") +class TestCd: + @pytest.mark.complete("cd shared/default/") + def test_1(self, completion): + assert completion == ["bar bar.d/", "foo.d/"] + + @pytest.mark.complete("cd fo", env=dict(CDPATH="shared/default")) + def test_2(self, completion): + assert completion == "foo.d/" + + @pytest.mark.complete("cd fo") + def test_3(self, completion): + assert not completion + + @pytest.mark.complete( + "cd ", cwd="shared/default/foo.d", env=dict(CDPATH="") + ) + def test_4(self, completion): + assert not completion # No subdirs nor CDPATH diff --git a/test/t/test_cdrecord.py b/test/t/test_cdrecord.py new file mode 100644 index 00000000..d9d2da1f --- /dev/null +++ b/test/t/test_cdrecord.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCdrecord: + @pytest.mark.complete("cdrecord -d") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cfagent.py b/test/t/test_cfagent.py new file mode 100644 index 00000000..f4b477bc --- /dev/null +++ b/test/t/test_cfagent.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCfagent: + @pytest.mark.complete("cfagent -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cfrun.py b/test/t/test_cfrun.py new file mode 100644 index 00000000..a647d76b --- /dev/null +++ b/test/t/test_cfrun.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCfrun: + @pytest.mark.complete("cfrun -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_chage.py b/test/t/test_chage.py new file mode 100644 index 00000000..6ef34435 --- /dev/null +++ b/test/t/test_chage.py @@ -0,0 +1,7 @@ +import pytest + + +class TestChage: + @pytest.mark.complete("chage ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_change_pw.py b/test/t/test_change_pw.py new file mode 100644 index 00000000..69909af0 --- /dev/null +++ b/test/t/test_change_pw.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestChangePw: + @pytest.mark.complete("change_pw -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_check_db.py b/test/t/test_check_db.py new file mode 100644 index 00000000..a9f4844b --- /dev/null +++ b/test/t/test_check_db.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCheckDb: + @pytest.mark.complete("check_db -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_check_perms.py b/test/t/test_check_perms.py new file mode 100644 index 00000000..813ae4ce --- /dev/null +++ b/test/t/test_check_perms.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCheckPerms: + @pytest.mark.complete("check_perms -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_checksec.py b/test/t/test_checksec.py new file mode 100644 index 00000000..4fce13ff --- /dev/null +++ b/test/t/test_checksec.py @@ -0,0 +1,7 @@ +import pytest + + +class TestChecksec: + @pytest.mark.complete("checksec -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_chfn.py b/test/t/test_chfn.py new file mode 100644 index 00000000..ca719b8e --- /dev/null +++ b/test/t/test_chfn.py @@ -0,0 +1,7 @@ +import pytest + + +class TestChfn: + @pytest.mark.complete("chfn ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_chgrp.py b/test/t/test_chgrp.py new file mode 100644 index 00000000..87a583e7 --- /dev/null +++ b/test/t/test_chgrp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestChgrp: + @pytest.mark.complete("chgrp ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_chkconfig.py b/test/t/test_chkconfig.py new file mode 100644 index 00000000..c610a5d5 --- /dev/null +++ b/test/t/test_chkconfig.py @@ -0,0 +1,15 @@ +import pytest + + +class TestChkconfig: + @pytest.mark.complete("chkconfig -") + def test_1(self, completion): + assert completion + + # systemd may not be running e.g. in a docker container, and listing + # services will then fail. + @pytest.mark.complete( + "chkconfig ", skipif="! systemctl list-units &>/dev/null" + ) + def test_2(self, completion): + assert completion diff --git a/test/t/test_chmod.py b/test/t/test_chmod.py new file mode 100644 index 00000000..ed59cf13 --- /dev/null +++ b/test/t/test_chmod.py @@ -0,0 +1,25 @@ +import pytest + + +class TestChmod: + + # No completion here until mode completion is implemented + @pytest.mark.complete("chmod ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("chmod 755 ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("chmod -") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("chmod -x ") + def test_4(self, completion): + assert completion + + @pytest.mark.complete("chmod -77 ") + def test_5(self, completion): + assert completion diff --git a/test/t/test_chown.py b/test/t/test_chown.py new file mode 100644 index 00000000..37221cfa --- /dev/null +++ b/test/t/test_chown.py @@ -0,0 +1,82 @@ +import getpass + +import pytest + +from conftest import assert_bash_exec, assert_complete + + +@pytest.mark.bashcomp( + pre_cmds=( + # Fake root command to get all users/groups completed at least for now + "root_command=sudo", + ) +) +class TestChown: + @pytest.mark.xfail( + getpass.getuser() != "root", reason="Only root can chown to all users" + ) + @pytest.mark.complete("chown ") + def test_1(self, bash, completion): + users = sorted( + assert_bash_exec(bash, "compgen -A user", want_output=True).split() + ) + assert completion == users + + @pytest.mark.complete("chown foo: shared/default/") + def test_2(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] + + @pytest.mark.complete("chown :foo shared/default/") + def test_3(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] + + def test_4(self, bash, part_full_user): + part, full = part_full_user + completion = assert_complete(bash, "chown %s" % part) + assert completion == full + assert completion.endswith(" ") + + def test_5(self, bash, part_full_user, part_full_group): + _, user = part_full_user + partgroup, fullgroup = part_full_group + completion = assert_complete(bash, "chown %s:%s" % (user, partgroup)) + assert completion == "%s:%s" % (user, fullgroup) + assert completion.output.endswith(" ") + + def test_6(self, bash, part_full_group): + part, full = part_full_group + completion = assert_complete(bash, "chown dot.user:%s" % part) + assert completion == "dot.user:%s" % full + assert completion.output.endswith(" ") + + @pytest.mark.xfail # TODO check escaping, whitespace + def test_7(self, bash, part_full_group): + """Test preserving special chars in $prefix$partgroup<TAB>.""" + part, full = part_full_group + for prefix in ( + r"funky\ user:", + "funky.user:", + r"funky\.user:", + r"fu\ nky.user:", + r"f\ o\ o\.\bar:", + r"foo\_b\ a\.r\ :", + ): + completion = assert_complete(bash, "chown %s%s" % (prefix, part)) + assert completion == "%s%s" % (prefix, full) + assert completion.output.endswith(" ") + + def test_8(self, bash, part_full_user, part_full_group): + """Test giving up on degenerate cases instead of spewing junk.""" + _, user = part_full_user + partgroup, _ = part_full_group + for x in range(2, 5): + completion = assert_complete( + bash, "chown %s%s:%s" % (user, x * "\\", partgroup) + ) + assert not completion + + def test_9(self, bash, part_full_group): + """Test graceful fail on colon in user/group name.""" + part, _ = part_full_group + completion = assert_complete(bash, "chown foo:bar:%s" % part) + assert not completion diff --git a/test/t/test_chpasswd.py b/test/t/test_chpasswd.py new file mode 100644 index 00000000..ce16a75d --- /dev/null +++ b/test/t/test_chpasswd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestChpasswd: + @pytest.mark.complete("chpasswd -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_chromium_browser.py b/test/t/test_chromium_browser.py new file mode 100644 index 00000000..75cabdaf --- /dev/null +++ b/test/t/test_chromium_browser.py @@ -0,0 +1,13 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="chromium-browser") +class TestChromiumBrowser: + @pytest.mark.complete("chromium-browser ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("chromium-browser -") + def test_2(self, completion): + assert completion + assert not completion.endswith(" ") diff --git a/test/t/test_chronyc.py b/test/t/test_chronyc.py new file mode 100644 index 00000000..fdc91ac5 --- /dev/null +++ b/test/t/test_chronyc.py @@ -0,0 +1,11 @@ +import pytest + + +class TestChronyc: + @pytest.mark.complete("chronyc ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("chronyc -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_chroot.py b/test/t/test_chroot.py new file mode 100644 index 00000000..99ca56b0 --- /dev/null +++ b/test/t/test_chroot.py @@ -0,0 +1,12 @@ +import pytest + + +class TestChroot: + @pytest.mark.complete("chroot ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("/bin/chroot shared/default/") + def test_2(self, completion): + """Should complete dirs only, also when invoked using full path.""" + assert completion == ["bar bar.d/", "foo.d/"] diff --git a/test/t/test_chrpath.py b/test/t/test_chrpath.py new file mode 100644 index 00000000..036a1a41 --- /dev/null +++ b/test/t/test_chrpath.py @@ -0,0 +1,11 @@ +import pytest + + +class TestChrpath: + @pytest.mark.complete("chrpath ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("chrpath -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_chsh.py b/test/t/test_chsh.py new file mode 100644 index 00000000..26e3a0a3 --- /dev/null +++ b/test/t/test_chsh.py @@ -0,0 +1,11 @@ +import pytest + + +class TestChsh: + @pytest.mark.complete("chsh ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("chsh -s ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_ci.py b/test/t/test_ci.py new file mode 100644 index 00000000..f941b2cc --- /dev/null +++ b/test/t/test_ci.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCi: + @pytest.mark.complete("ci ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ciptool.py b/test/t/test_ciptool.py new file mode 100644 index 00000000..0ff54442 --- /dev/null +++ b/test/t/test_ciptool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCiptool: + @pytest.mark.complete("ciptool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_civclient.py b/test/t/test_civclient.py new file mode 100644 index 00000000..cff70f47 --- /dev/null +++ b/test/t/test_civclient.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCivclient: + @pytest.mark.complete("civclient -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_civserver.py b/test/t/test_civserver.py new file mode 100644 index 00000000..b822ddef --- /dev/null +++ b/test/t/test_civserver.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCivserver: + @pytest.mark.complete("civserver -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cksfv.py b/test/t/test_cksfv.py new file mode 100644 index 00000000..b4df8767 --- /dev/null +++ b/test/t/test_cksfv.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCksfv: + @pytest.mark.complete("cksfv -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cleanarch.py b/test/t/test_cleanarch.py new file mode 100644 index 00000000..95b268e2 --- /dev/null +++ b/test/t/test_cleanarch.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestCleanarch: + @pytest.mark.complete("cleanarch -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_clisp.py b/test/t/test_clisp.py new file mode 100644 index 00000000..3fcb2593 --- /dev/null +++ b/test/t/test_clisp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestClisp: + @pytest.mark.complete("clisp ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_clone_member.py b/test/t/test_clone_member.py new file mode 100644 index 00000000..8f54298a --- /dev/null +++ b/test/t/test_clone_member.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCloneMember: + @pytest.mark.complete("clone_member -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_co.py b/test/t/test_co.py new file mode 100644 index 00000000..0404b45f --- /dev/null +++ b/test/t/test_co.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCo: + @pytest.mark.complete("co ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_compare.py b/test/t/test_compare.py new file mode 100644 index 00000000..172c8dab --- /dev/null +++ b/test/t/test_compare.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCompare: + @pytest.mark.complete("compare ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_complete.py b/test/t/test_complete.py new file mode 100644 index 00000000..036f954e --- /dev/null +++ b/test/t/test_complete.py @@ -0,0 +1,7 @@ +import pytest + + +class TestComplete: + @pytest.mark.complete("complete -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_composite.py b/test/t/test_composite.py new file mode 100644 index 00000000..58f4e398 --- /dev/null +++ b/test/t/test_composite.py @@ -0,0 +1,7 @@ +import pytest + + +class TestComposite: + @pytest.mark.complete("composite ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_config_list.py b/test/t/test_config_list.py new file mode 100644 index 00000000..d17fadc6 --- /dev/null +++ b/test/t/test_config_list.py @@ -0,0 +1,7 @@ +import pytest + + +class TestConfigList: + @pytest.mark.complete("config_list -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_configure.py b/test/t/test_configure.py new file mode 100644 index 00000000..17bc9d48 --- /dev/null +++ b/test/t/test_configure.py @@ -0,0 +1,17 @@ +import pytest + + +@pytest.mark.bashcomp( + pre_cmds=( + # Make sure our own ./configure is in PATH + "PATH=$PWD/../..:$PATH", + ) +) +class TestConfigure: + @pytest.mark.complete("configure --") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("configure --prefix ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_conjure.py b/test/t/test_conjure.py new file mode 100644 index 00000000..3dcc0dbc --- /dev/null +++ b/test/t/test_conjure.py @@ -0,0 +1,7 @@ +import pytest + + +class TestConjure: + @pytest.mark.complete("conjure ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_convert.py b/test/t/test_convert.py new file mode 100644 index 00000000..90dfb477 --- /dev/null +++ b/test/t/test_convert.py @@ -0,0 +1,11 @@ +import pytest + + +class TestConvert: + @pytest.mark.complete("convert ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("convert -format ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_cowsay.py b/test/t/test_cowsay.py new file mode 100644 index 00000000..2920d9ea --- /dev/null +++ b/test/t/test_cowsay.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCowsay: + @pytest.mark.complete("cowsay ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cp.py b/test/t/test_cp.py new file mode 100644 index 00000000..a25998fc --- /dev/null +++ b/test/t/test_cp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCp: + @pytest.mark.complete("cp ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cpan2dist.py b/test/t/test_cpan2dist.py new file mode 100644 index 00000000..13feae9e --- /dev/null +++ b/test/t/test_cpan2dist.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCpan2dist: + @pytest.mark.complete("cpan2dist -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cpio.py b/test/t/test_cpio.py new file mode 100644 index 00000000..69bb5702 --- /dev/null +++ b/test/t/test_cpio.py @@ -0,0 +1,16 @@ +import pytest + +from conftest import assert_bash_exec + + +class TestCpio: + @pytest.mark.complete("cpio --") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("cpio -R ") + def test_2(self, bash, completion): + users = sorted( + assert_bash_exec(bash, "compgen -A user", want_output=True).split() + ) + assert completion == users diff --git a/test/t/test_cplusplus.py b/test/t/test_cplusplus.py new file mode 100644 index 00000000..a2dd3ede --- /dev/null +++ b/test/t/test_cplusplus.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="c++") +class TestCPlusPlus: + @pytest.mark.complete("c++ ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cppcheck.py b/test/t/test_cppcheck.py new file mode 100644 index 00000000..d5e3af9b --- /dev/null +++ b/test/t/test_cppcheck.py @@ -0,0 +1,31 @@ +import pytest + + +class TestCppcheck: + @pytest.mark.complete("cppcheck ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("cppcheck -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("cppcheck -DFOO=BAR ") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("cppcheck -D ") + def test_4(self, completion): + assert not completion + + @pytest.mark.complete("cppcheck --enable=al") + def test_5(self, completion): + assert completion == "--enable=all" + + @pytest.mark.complete("cppcheck --enable=xx,styl") + def test_6(self, completion): + assert completion == "--enable=xx,style" + + @pytest.mark.complete("cppcheck --enable=xx,yy,styl") + def test_7(self, completion): + assert completion == "--enable=xx,yy,style" diff --git a/test/t/test_createdb.py b/test/t/test_createdb.py new file mode 100644 index 00000000..7e226438 --- /dev/null +++ b/test/t/test_createdb.py @@ -0,0 +1,9 @@ +import pytest + + +class TestCreatedb: + + # --help can fail due to missing package dependencies, e.g. on Ubuntu 14 + @pytest.mark.complete("createdb -", skipif="! createdb --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_createuser.py b/test/t/test_createuser.py new file mode 100644 index 00000000..f25f10f7 --- /dev/null +++ b/test/t/test_createuser.py @@ -0,0 +1,11 @@ +import pytest + + +class TestCreateuser: + + # --help can fail due to missing package dependencies, e.g. on Ubuntu 14 + @pytest.mark.complete( + "createuser -", skipif="! createuser --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_crontab.py b/test/t/test_crontab.py new file mode 100644 index 00000000..098fd9e0 --- /dev/null +++ b/test/t/test_crontab.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCrontab: + @pytest.mark.complete("crontab ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cryptsetup.py b/test/t/test_cryptsetup.py new file mode 100644 index 00000000..235ac4fc --- /dev/null +++ b/test/t/test_cryptsetup.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCryptsetup: + @pytest.mark.complete("cryptsetup ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_csplit.py b/test/t/test_csplit.py new file mode 100644 index 00000000..54eab34c --- /dev/null +++ b/test/t/test_csplit.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCsplit: + @pytest.mark.complete("csplit ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_curl.py b/test/t/test_curl.py new file mode 100644 index 00000000..324fba2a --- /dev/null +++ b/test/t/test_curl.py @@ -0,0 +1,19 @@ +import pytest + + +class TestCurl: + @pytest.mark.complete("curl --h") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("curl -o f", cwd="shared/default/foo.d") + def test_2(self, completion): + assert completion == "foo" + + @pytest.mark.complete("curl -LRo f", cwd="shared/default/foo.d") + def test_3(self, completion): + assert completion == "foo" + + @pytest.mark.complete("curl --o f") + def test_4(self, completion): + assert not completion diff --git a/test/t/test_cut.py b/test/t/test_cut.py new file mode 100644 index 00000000..31fa636a --- /dev/null +++ b/test/t/test_cut.py @@ -0,0 +1,7 @@ +import pytest + + +class TestCut: + @pytest.mark.complete("cut ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_cvs.py b/test/t/test_cvs.py new file mode 100644 index 00000000..825acbf5 --- /dev/null +++ b/test/t/test_cvs.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD/cvs",)) +class TestCvs: + @pytest.mark.complete("cvs ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("cvs -d ") + def test_2(self, completion): + assert [x for x in completion if ":pserver:" in x] + + @pytest.mark.complete("cvs diff foo/", cwd="cvs") + def test_3(self, completion): + assert completion == "foo/bar" diff --git a/test/t/test_cvsps.py b/test/t/test_cvsps.py new file mode 100644 index 00000000..0a4da9ba --- /dev/null +++ b/test/t/test_cvsps.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD/cvs",)) +class TestCvsps: + @pytest.mark.complete("cvsps -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("cvsps ") + def test_2(self, completion): + assert [x for x in completion if ":pserver:" in x] diff --git a/test/t/test_date.py b/test/t/test_date.py new file mode 100644 index 00000000..8df574e9 --- /dev/null +++ b/test/t/test_date.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDate: + @pytest.mark.complete("date ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dcop.py b/test/t/test_dcop.py new file mode 100644 index 00000000..669725e2 --- /dev/null +++ b/test/t/test_dcop.py @@ -0,0 +1,14 @@ +import subprocess + +import pytest + + +class TestDcop: + @pytest.mark.complete("dcop ") + def test_1(self, completion): + try: + subprocess.check_call("dcop &>/dev/null", shell=True) + except BaseException: + assert not completion + else: + assert completion diff --git a/test/t/test_dd.py b/test/t/test_dd.py new file mode 100644 index 00000000..616f4d4a --- /dev/null +++ b/test/t/test_dd.py @@ -0,0 +1,11 @@ +import pytest + + +class TestDd: + @pytest.mark.complete("dd --") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("dd bs") + def test_2(self, completion): + assert completion == "bs=" diff --git a/test/t/test_declare.py b/test/t/test_declare.py new file mode 100644 index 00000000..b17affc2 --- /dev/null +++ b/test/t/test_declare.py @@ -0,0 +1,20 @@ +import pytest + + +class TestDeclare: + @pytest.mark.complete("declare -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("declare +") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("declare -p BASH_ARG") + def test_3(self, completion): + # bash 5.0 has BASH_ARGV0 too + assert all(x in completion for x in "BASH_ARGC BASH_ARGV".split()) + + @pytest.mark.complete("declare -f _parse_") + def test_4(self, completion): + assert "_parse_help" in completion diff --git a/test/t/test_deja_dup.py b/test/t/test_deja_dup.py new file mode 100644 index 00000000..1da29e99 --- /dev/null +++ b/test/t/test_deja_dup.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="deja-dup") +class TestDejaDup: + @pytest.mark.complete("deja-dup -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("deja-dup --help ") + def test_2(self, completion): + assert not completion diff --git a/test/t/test_desktop_file_validate.py b/test/t/test_desktop_file_validate.py new file mode 100644 index 00000000..e007a956 --- /dev/null +++ b/test/t/test_desktop_file_validate.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="desktop-file-validate") +class TestDesktopFileValidate: + @pytest.mark.complete("desktop-file-validate ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_df.py b/test/t/test_df.py new file mode 100644 index 00000000..247311cc --- /dev/null +++ b/test/t/test_df.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDf: + @pytest.mark.complete("df ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dfutool.py b/test/t/test_dfutool.py new file mode 100644 index 00000000..7b450bde --- /dev/null +++ b/test/t/test_dfutool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDfutool: + @pytest.mark.complete("dfutool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dhclient.py b/test/t/test_dhclient.py new file mode 100644 index 00000000..fdfbd473 --- /dev/null +++ b/test/t/test_dhclient.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDhclient: + @pytest.mark.complete("dhclient -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dict.py b/test/t/test_dict.py new file mode 100644 index 00000000..65f6b129 --- /dev/null +++ b/test/t/test_dict.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDict: + @pytest.mark.complete("dict -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_diff.py b/test/t/test_diff.py new file mode 100644 index 00000000..25157bd9 --- /dev/null +++ b/test/t/test_diff.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDiff: + @pytest.mark.complete("diff --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dir.py b/test/t/test_dir.py new file mode 100644 index 00000000..3026d502 --- /dev/null +++ b/test/t/test_dir.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDir: + @pytest.mark.complete("dir ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_display.py b/test/t/test_display.py new file mode 100644 index 00000000..9f5c1004 --- /dev/null +++ b/test/t/test_display.py @@ -0,0 +1,11 @@ +import pytest + + +class TestDisplay: + @pytest.mark.complete("display ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("display -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_dmesg.py b/test/t/test_dmesg.py new file mode 100644 index 00000000..4416fe1c --- /dev/null +++ b/test/t/test_dmesg.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDmesg: + @pytest.mark.complete("dmesg -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dnssec_keygen.py b/test/t/test_dnssec_keygen.py new file mode 100644 index 00000000..d52e3af0 --- /dev/null +++ b/test/t/test_dnssec_keygen.py @@ -0,0 +1,80 @@ +import pytest + + +@pytest.mark.bashcomp( + cmd="dnssec-keygen", pre_cmds=("PATH=$PATH:$PWD/dnssec-keygen",) +) +class TestDnssecKeygen: + @pytest.mark.complete("dnssec-keygen -") + def test_1(self, completion): + assert completion + assert not any(x.endswith(":") for x in completion) + + @pytest.mark.complete("dnssec-keygen -a ") + def test_2(self, completion): + assert completion + assert "HMAC-MD5" in completion + assert "|" not in completion + assert not any(x.startswith("-") for x in completion) + + @pytest.mark.complete("dnssec-keygen -n ") + def test_3(self, completion): + assert completion + assert "HOST" in completion + assert "|" not in completion + assert not any(x.startswith("-") for x in completion) + + @pytest.mark.complete("dnssec-keygen -f ") + def test_4(self, completion): + assert completion + assert "|" not in completion + assert not any(x.startswith("-") for x in completion) + + @pytest.mark.complete("dnssec-keygen ") + def test_5(self, completion): + assert not completion + + @pytest.mark.complete( + "dnssec-keygen -a ", env=dict(PATH="$PWD/dnssec-keygen:$PATH") + ) + def test_6(self, completion): + assert completion == sorted( + "RSA RSAMD5 DSA RSASHA1 NSEC3RSASHA1 NSEC3DSA " + "RSASHA256 RSASHA512 ECCGOST " + "ECDSAP256SHA256 ECDSAP384SHA384 " + "ED25519 ED448 DH " + "HMAC-MD5 HMAC-SHA1 HMAC-SHA224 HMAC-SHA256 " + "HMAC-SHA384 HMAC-SHA512".split() + ) + + @pytest.mark.complete( + "dnssec-keygen -n ", env=dict(PATH="$PWD/dnssec-keygen:$PATH") + ) + def test_7(self, completion): + assert completion == sorted("ZONE HOST ENTITY USER OTHER".split()) + + @pytest.mark.complete( + "dnssec-keygen -f ", env=dict(PATH="$PWD/dnssec-keygen:$PATH") + ) + def test_8(self, completion): + assert completion == sorted("KSK REVOKE".split()) + + @pytest.mark.complete( + "dnssec-keygen -T ", env=dict(PATH="$PWD/dnssec-keygen:$PATH") + ) + def test_9(self, completion): + assert completion == sorted("DNSKEY KEY".split()) + + @pytest.mark.complete( + "dnssec-keygen -t ", env=dict(PATH="$PWD/dnssec-keygen:$PATH") + ) + def test_10(self, completion): + assert completion == sorted( + "AUTHCONF NOAUTHCONF NOAUTH NOCONF".split() + ) + + @pytest.mark.complete( + "dnssec-keygen -m ", env=dict(PATH="$PWD/dnssec-keygen:$PATH") + ) + def test_11(self, completion): + assert completion == sorted("usage trace record size mctx".split()) diff --git a/test/t/test_dnsspoof.py b/test/t/test_dnsspoof.py new file mode 100644 index 00000000..fae6c430 --- /dev/null +++ b/test/t/test_dnsspoof.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDnsspoof: + @pytest.mark.complete("dnsspoof -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dot.py b/test/t/test_dot.py new file mode 100644 index 00000000..a4aa6742 --- /dev/null +++ b/test/t/test_dot.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDot: + @pytest.mark.complete("dot ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dpkg.py b/test/t/test_dpkg.py new file mode 100644 index 00000000..e609ee86 --- /dev/null +++ b/test/t/test_dpkg.py @@ -0,0 +1,17 @@ +import pytest + + +class TestDpkg: + @pytest.mark.complete("dpkg --c") + def test_1(self, completion): + assert completion + + @pytest.mark.complete( + "dpkg -L ", skipif='test -z "$(dpkg -l 2>/dev/null)"' + ) + def test_2(self, completion): + assert completion + + @pytest.mark.complete("dpkg -i ~") + def test_3(self, completion): + assert completion diff --git a/test/t/test_dpkg_deb.py b/test/t/test_dpkg_deb.py new file mode 100644 index 00000000..4bd7368b --- /dev/null +++ b/test/t/test_dpkg_deb.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="dpkg-deb") +class TestDpkgDeb: + @pytest.mark.complete("dpkg-deb --c") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dpkg_reconfigure.py b/test/t/test_dpkg_reconfigure.py new file mode 100644 index 00000000..46347b3f --- /dev/null +++ b/test/t/test_dpkg_reconfigure.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="dpkg-reconfigure") +class TestDpkgReconfigure: + @pytest.mark.complete("dpkg-reconfigure --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dpkg_source.py b/test/t/test_dpkg_source.py new file mode 100644 index 00000000..f2d5f19b --- /dev/null +++ b/test/t/test_dpkg_source.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="dpkg-source") +class TestDpkgSource: + @pytest.mark.complete("dpkg-source -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dropdb.py b/test/t/test_dropdb.py new file mode 100644 index 00000000..7e0b7929 --- /dev/null +++ b/test/t/test_dropdb.py @@ -0,0 +1,9 @@ +import pytest + + +class TestDropdb: + + # --help can fail due to missing package dependencies, e.g. on Ubuntu 14 + @pytest.mark.complete("dropdb -", skipif="! dropdb --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dropuser.py b/test/t/test_dropuser.py new file mode 100644 index 00000000..83a99d94 --- /dev/null +++ b/test/t/test_dropuser.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDropuser: + @pytest.mark.complete("dropuser ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dselect.py b/test/t/test_dselect.py new file mode 100644 index 00000000..3145cc40 --- /dev/null +++ b/test/t/test_dselect.py @@ -0,0 +1,11 @@ +import pytest + + +class TestDselect: + @pytest.mark.complete("dselect ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("dselect -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_dsniff.py b/test/t/test_dsniff.py new file mode 100644 index 00000000..978c4365 --- /dev/null +++ b/test/t/test_dsniff.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDsniff: + @pytest.mark.complete("dsniff -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_du.py b/test/t/test_du.py new file mode 100644 index 00000000..c014b069 --- /dev/null +++ b/test/t/test_du.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDu: + @pytest.mark.complete("du ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dumpdb.py b/test/t/test_dumpdb.py new file mode 100644 index 00000000..50776827 --- /dev/null +++ b/test/t/test_dumpdb.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestDumpdb: + @pytest.mark.complete("dumpdb ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_dumpe2fs.py b/test/t/test_dumpe2fs.py new file mode 100644 index 00000000..fa7590e6 --- /dev/null +++ b/test/t/test_dumpe2fs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestDumpe2fs: + @pytest.mark.complete("dumpe2fs ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_e2freefrag.py b/test/t/test_e2freefrag.py new file mode 100644 index 00000000..6685382d --- /dev/null +++ b/test/t/test_e2freefrag.py @@ -0,0 +1,7 @@ +import pytest + + +class TestE2freefrag: + @pytest.mark.complete("e2freefrag ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_e2label.py b/test/t/test_e2label.py new file mode 100644 index 00000000..ca436a65 --- /dev/null +++ b/test/t/test_e2label.py @@ -0,0 +1,7 @@ +import pytest + + +class TestE2label: + @pytest.mark.complete("e2label ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ebtables.py b/test/t/test_ebtables.py new file mode 100644 index 00000000..bcca3cbe --- /dev/null +++ b/test/t/test_ebtables.py @@ -0,0 +1,7 @@ +import pytest + + +class TestEbtables: + @pytest.mark.complete("ebtables -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ecryptfs_migrate_home.py b/test/t/test_ecryptfs_migrate_home.py new file mode 100644 index 00000000..fd49ca8b --- /dev/null +++ b/test/t/test_ecryptfs_migrate_home.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="ecryptfs-migrate-home") +class TestEcryptfsMigrateHome: + @pytest.mark.complete("ecryptfs-migrate-home ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_eject.py b/test/t/test_eject.py new file mode 100644 index 00000000..037ea98e --- /dev/null +++ b/test/t/test_eject.py @@ -0,0 +1,7 @@ +import pytest + + +class TestEject: + @pytest.mark.complete("eject -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_enscript.py b/test/t/test_enscript.py new file mode 100644 index 00000000..2e4ff51a --- /dev/null +++ b/test/t/test_enscript.py @@ -0,0 +1,7 @@ +import pytest + + +class TestEnscript: + @pytest.mark.complete("enscript --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_env.py b/test/t/test_env.py new file mode 100644 index 00000000..57ed9769 --- /dev/null +++ b/test/t/test_env.py @@ -0,0 +1,7 @@ +import pytest + + +class TestEnv: + @pytest.mark.complete("env --", skipif="! env --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_eog.py b/test/t/test_eog.py new file mode 100644 index 00000000..c095934f --- /dev/null +++ b/test/t/test_eog.py @@ -0,0 +1,7 @@ +import pytest + + +class TestEog: + @pytest.mark.complete("eog ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ether_wake.py b/test/t/test_ether_wake.py new file mode 100644 index 00000000..b9dac0b4 --- /dev/null +++ b/test/t/test_ether_wake.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="ether-wake") +class TestEtherWake: + @pytest.mark.complete("ether-wake ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_etherwake.py b/test/t/test_etherwake.py new file mode 100644 index 00000000..b444b433 --- /dev/null +++ b/test/t/test_etherwake.py @@ -0,0 +1,7 @@ +import pytest + + +class TestEtherwake: + @pytest.mark.complete("etherwake -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_evince.py b/test/t/test_evince.py new file mode 100644 index 00000000..0dc44f38 --- /dev/null +++ b/test/t/test_evince.py @@ -0,0 +1,18 @@ +import pytest + + +class TestEvince: + @pytest.mark.complete("evince ", cwd="evince") + def test_1(self, completion): + # .txt should not be here + assert completion == sorted( + "foo/ .bmp .BMP .cbr .CBR .cbz .CBZ .djv .DJV .djvu .DJVU .dvi " + ".DVI .dvi.bz2 .dvi.BZ2 .DVI.bz2 .DVI.BZ2 .dvi.gz .dvi.GZ " + ".DVI.gz .DVI.GZ .eps .EPS .eps.bz2 .eps.BZ2 .EPS.bz2 .EPS.BZ2 " + ".eps.gz .eps.GZ .EPS.gz .EPS.GZ .gif .GIF .ico .ICO .jpeg " + ".JPEG .jpg .JPG .miff .MIFF .pbm .PBM .pcx .PCX .pdf .PDF " + ".pdf.bz2 .pdf.BZ2 .PDF.bz2 .PDF.BZ2 .pdf.gz .pdf.GZ .PDF.gz " + ".PDF.GZ .pgm .PGM .png .PNG .pnm .PNM .ppm .PPM .ps .PS " + ".ps.bz2 .ps.BZ2 .PS.bz2 .PS.BZ2 .ps.gz .ps.GZ .PS.gz .PS.GZ " + ".tga .TGA .tif .TIF .tiff .TIFF .xpm .XPM .xwd .XWD".split() + ) diff --git a/test/t/test_expand.py b/test/t/test_expand.py new file mode 100644 index 00000000..004c018b --- /dev/null +++ b/test/t/test_expand.py @@ -0,0 +1,7 @@ +import pytest + + +class TestExpand: + @pytest.mark.complete("expand --", skipif="! expand --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_explodepkg.py b/test/t/test_explodepkg.py new file mode 100644 index 00000000..29463dfd --- /dev/null +++ b/test/t/test_explodepkg.py @@ -0,0 +1,18 @@ +import fnmatch +import os + +import pytest + + +class TestExplodepkg: + @pytest.mark.complete("explodepkg ", cwd="slackware/home") + def test_1(self, completion): + expected = sorted( + x + for x in os.listdir("slackware/home") + if os.path.isdir("./%s" % x) + or ( + os.path.isfile("./%s" % x) and fnmatch.fnmatch(x, "*.t[bglx]z") + ) + ) + assert completion == expected diff --git a/test/t/test_export.py b/test/t/test_export.py new file mode 100644 index 00000000..59dfdb2e --- /dev/null +++ b/test/t/test_export.py @@ -0,0 +1,36 @@ +import pytest + + +class TestExport: + @pytest.mark.complete("export BASH") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("export -n BASH") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("export -p ") + def test_3(self, completion): + assert not completion + + @pytest.mark.complete("export FOO=", cwd="shared/default") + def test_4(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] + + @pytest.mark.complete("export FOO=f", cwd="shared/default") + def test_5(self, completion): + assert completion == ["foo", "foo.d/"] + + @pytest.mark.complete("export -fn _ex") + def test_6(self, completion): + assert "_expand" in completion + assert "_export" in completion + + @pytest.mark.complete(r"export FOO=$BASH") + def test_7(self, completion): + assert completion + + @pytest.mark.complete("export -") + def test_8(self, completion): + assert completion diff --git a/test/t/test_faillog.py b/test/t/test_faillog.py new file mode 100644 index 00000000..d9799d57 --- /dev/null +++ b/test/t/test_faillog.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFaillog: + @pytest.mark.complete("faillog -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_fbgs.py b/test/t/test_fbgs.py new file mode 100644 index 00000000..53ff7412 --- /dev/null +++ b/test/t/test_fbgs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFbgs: + @pytest.mark.complete("fbgs ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_fbi.py b/test/t/test_fbi.py new file mode 100644 index 00000000..e27fef51 --- /dev/null +++ b/test/t/test_fbi.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFbi: + @pytest.mark.complete("fbi ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_feh.py b/test/t/test_feh.py new file mode 100644 index 00000000..1802e25f --- /dev/null +++ b/test/t/test_feh.py @@ -0,0 +1,29 @@ +import pytest + + +class TestFeh: + @pytest.mark.complete("feh ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete( + "feh --lis", skipif="feh --help 2>&1 | grep -qF 'man feh'" + ) + def test_2(self, completion): + assert completion + + @pytest.mark.complete("feh -S pix") + def test_3(self, completion): + assert completion == "pixels" + + @pytest.mark.complete("feh --zoom ma") + def test_4(self, completion): + assert completion == "max" + + @pytest.mark.complete("feh -g 640") + def test_5(self, completion): + assert completion == "0 1 2 3 4 5 6 7 8 9 x".split() + + @pytest.mark.complete("feh -g 640x48") + def test_6(self, completion): + assert completion == "0 1 2 3 4 5 6 7 8 9".split() diff --git a/test/t/test_file.py b/test/t/test_file.py new file mode 100644 index 00000000..cfd2c100 --- /dev/null +++ b/test/t/test_file.py @@ -0,0 +1,11 @@ +import pytest + + +class TestFile: + @pytest.mark.complete("file ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("file -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_file_roller.py b/test/t/test_file_roller.py new file mode 100644 index 00000000..80a1bbc7 --- /dev/null +++ b/test/t/test_file_roller.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="file-roller") +class TestFileRoller: + @pytest.mark.complete("file-roller ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_filefrag.py b/test/t/test_filefrag.py new file mode 100644 index 00000000..860b2512 --- /dev/null +++ b/test/t/test_filefrag.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFilefrag: + @pytest.mark.complete("filefrag ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_filesnarf.py b/test/t/test_filesnarf.py new file mode 100644 index 00000000..cd399d4a --- /dev/null +++ b/test/t/test_filesnarf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFilesnarf: + @pytest.mark.complete("filesnarf -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_find.py b/test/t/test_find.py new file mode 100644 index 00000000..a94e0e0d --- /dev/null +++ b/test/t/test_find.py @@ -0,0 +1,28 @@ +import pytest + + +class TestFind: + @pytest.mark.complete("find ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("find -fstype ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("find -") + def test_3(self, completion): + assert completion + + @pytest.mark.xfail # TODO: whitespace split issue + @pytest.mark.complete("find -wholename ", cwd="shared/default") + def test_4(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo foo.d/"] + + @pytest.mark.complete("find -uid ") + def test_5(self, completion): + assert not [x for x in completion if not x.isdigit()] + + @pytest.mark.complete("find -gid ") + def test_6(self, completion): + assert not [x for x in completion if not x.isdigit()] diff --git a/test/t/test_find_member.py b/test/t/test_find_member.py new file mode 100644 index 00000000..bfcf5887 --- /dev/null +++ b/test/t/test_find_member.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFindMember: + @pytest.mark.complete("find_member -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_finger.py b/test/t/test_finger.py new file mode 100644 index 00000000..e3cdfacd --- /dev/null +++ b/test/t/test_finger.py @@ -0,0 +1,14 @@ +import pytest + +from conftest import assert_bash_exec + + +class TestFinger: + @pytest.mark.complete("finger ") + def test_1(self, bash, completion): + users_at = sorted( + assert_bash_exec( + bash, "compgen -A user -S @", want_output=True + ).split() + ) + assert completion == users_at diff --git a/test/t/test_fio.py b/test/t/test_fio.py new file mode 100644 index 00000000..8dd6f789 --- /dev/null +++ b/test/t/test_fio.py @@ -0,0 +1,15 @@ +import pytest + + +class TestFio: + @pytest.mark.complete("fio ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("fio --") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("fio --debug=foo,") + def test_3(self, completion): + assert completion diff --git a/test/t/test_firefox.py b/test/t/test_firefox.py new file mode 100644 index 00000000..cbba2c6c --- /dev/null +++ b/test/t/test_firefox.py @@ -0,0 +1,12 @@ +import pytest + + +class TestFirefox: + @pytest.mark.complete("firefox ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("firefox -") + def test_2(self, completion): + assert completion + assert not completion.endswith(" ") diff --git a/test/t/test_flake8.py b/test/t/test_flake8.py new file mode 100644 index 00000000..9922fb85 --- /dev/null +++ b/test/t/test_flake8.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp(skipif="! flake8 --help &>/dev/null") +class TestFlake8: + @pytest.mark.complete("flake8 ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("flake8 -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("flake8 --doesnt-exist=") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_fmt.py b/test/t/test_fmt.py new file mode 100644 index 00000000..dc3473ba --- /dev/null +++ b/test/t/test_fmt.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFmt: + @pytest.mark.complete("fmt -", skipif="! fmt --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_fold.py b/test/t/test_fold.py new file mode 100644 index 00000000..9a8fd2aa --- /dev/null +++ b/test/t/test_fold.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFold: + @pytest.mark.complete("fold --", skipif="! fold --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_freebsd_update.py b/test/t/test_freebsd_update.py new file mode 100644 index 00000000..911a49a5 --- /dev/null +++ b/test/t/test_freebsd_update.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="freebsd-update") +class TestFreebsdUpdate: + @pytest.mark.complete("freebsd-update ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_freeciv.py b/test/t/test_freeciv.py new file mode 100644 index 00000000..1027e43c --- /dev/null +++ b/test/t/test_freeciv.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFreeciv: + @pytest.mark.complete("freeciv -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_freeciv_server.py b/test/t/test_freeciv_server.py new file mode 100644 index 00000000..5546a5e9 --- /dev/null +++ b/test/t/test_freeciv_server.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="freeciv-server") +class TestFreecivServer: + @pytest.mark.complete("freeciv-server -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_function.py b/test/t/test_function.py new file mode 100644 index 00000000..4401f022 --- /dev/null +++ b/test/t/test_function.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFunction: + @pytest.mark.complete("function _parse_") + def test_1(self, completion): + assert completion diff --git a/test/t/test_fusermount.py b/test/t/test_fusermount.py new file mode 100644 index 00000000..3781586d --- /dev/null +++ b/test/t/test_fusermount.py @@ -0,0 +1,7 @@ +import pytest + + +class TestFusermount: + @pytest.mark.complete("fusermount ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_g4.py b/test/t/test_g4.py new file mode 100644 index 00000000..739c77db --- /dev/null +++ b/test/t/test_g4.py @@ -0,0 +1,7 @@ +import pytest + + +class TestG4: + @pytest.mark.complete("g4 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_g77.py b/test/t/test_g77.py new file mode 100644 index 00000000..45da6244 --- /dev/null +++ b/test/t/test_g77.py @@ -0,0 +1,7 @@ +import pytest + + +class TestG77: + @pytest.mark.complete("g77 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gcc.py b/test/t/test_gcc.py new file mode 100644 index 00000000..67f4ee57 --- /dev/null +++ b/test/t/test_gcc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGcc: + @pytest.mark.complete("gcc ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gcj.py b/test/t/test_gcj.py new file mode 100644 index 00000000..17e2f445 --- /dev/null +++ b/test/t/test_gcj.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGcj: + @pytest.mark.complete("gcj ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gcl.py b/test/t/test_gcl.py new file mode 100644 index 00000000..f1e7a5ff --- /dev/null +++ b/test/t/test_gcl.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGcl: + @pytest.mark.complete("gcl ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gdb.py b/test/t/test_gdb.py new file mode 100644 index 00000000..2ad12c48 --- /dev/null +++ b/test/t/test_gdb.py @@ -0,0 +1,14 @@ +import pytest + + +class TestGdb: + @pytest.mark.complete("gdb - ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("gdb foo ", cwd="gdb") + def test_2(self, completion): + assert completion == sorted( + "core core.12345 " + "core.weston.1000.deadbeef.5308.1555362132000000".split() + ) diff --git a/test/t/test_genaliases.py b/test/t/test_genaliases.py new file mode 100644 index 00000000..e2f24d65 --- /dev/null +++ b/test/t/test_genaliases.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestGenaliases: + @pytest.mark.complete("genaliases -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gendiff.py b/test/t/test_gendiff.py new file mode 100644 index 00000000..0e2ab4c3 --- /dev/null +++ b/test/t/test_gendiff.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGendiff: + @pytest.mark.complete("gendiff ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_genisoimage.py b/test/t/test_genisoimage.py new file mode 100644 index 00000000..ba16cea2 --- /dev/null +++ b/test/t/test_genisoimage.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGenisoimage: + @pytest.mark.complete("genisoimage ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_geoiplookup.py b/test/t/test_geoiplookup.py new file mode 100644 index 00000000..d114d55f --- /dev/null +++ b/test/t/test_geoiplookup.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGeoiplookup: + @pytest.mark.complete("geoiplookup -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_getconf.py b/test/t/test_getconf.py new file mode 100644 index 00000000..6f9192d2 --- /dev/null +++ b/test/t/test_getconf.py @@ -0,0 +1,23 @@ +import pytest + + +class TestGetconf: + @pytest.mark.complete("getconf P") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("getconf -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("getconf -a ") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("getconf -v ") + def test_4(self, completion): + assert completion + + @pytest.mark.complete("getconf PATH_MAX ") + def test_5(self, completion): + assert completion diff --git a/test/t/test_getent.py b/test/t/test_getent.py new file mode 100644 index 00000000..fa84880c --- /dev/null +++ b/test/t/test_getent.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGetent: + @pytest.mark.complete("getent ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gkrellm.py b/test/t/test_gkrellm.py new file mode 100644 index 00000000..8ab4b5a7 --- /dev/null +++ b/test/t/test_gkrellm.py @@ -0,0 +1,10 @@ +import os + +import pytest + + +@pytest.mark.xfail(not os.environ.get("DISPLAY"), reason="X display required") +class TestGkrellm: + @pytest.mark.complete("gkrellm -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gm.py b/test/t/test_gm.py new file mode 100644 index 00000000..82d16702 --- /dev/null +++ b/test/t/test_gm.py @@ -0,0 +1,19 @@ +import pytest + + +class TestGm: + @pytest.mark.complete("gm ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("gm help ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("gm time ") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("gm version ") + def test_4(self, completion): + assert not completion diff --git a/test/t/test_gmplayer.py b/test/t/test_gmplayer.py new file mode 100644 index 00000000..211ef515 --- /dev/null +++ b/test/t/test_gmplayer.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGmplayer: + @pytest.mark.complete("gmplayer ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gnatmake.py b/test/t/test_gnatmake.py new file mode 100644 index 00000000..c9f5609f --- /dev/null +++ b/test/t/test_gnatmake.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGnatmake: + @pytest.mark.complete("gnatmake ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gnokii.py b/test/t/test_gnokii.py new file mode 100644 index 00000000..106005f9 --- /dev/null +++ b/test/t/test_gnokii.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGnokii: + @pytest.mark.complete("gnokii ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gnome_mplayer.py b/test/t/test_gnome_mplayer.py new file mode 100644 index 00000000..5ee952c1 --- /dev/null +++ b/test/t/test_gnome_mplayer.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="gnome-mplayer") +class TestGnomeMplayer: + @pytest.mark.complete("gnome-mplayer ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gnome_screenshot.py b/test/t/test_gnome_screenshot.py new file mode 100644 index 00000000..476f57f1 --- /dev/null +++ b/test/t/test_gnome_screenshot.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="gnome-screenshot") +class TestGnomeScreenshot: + @pytest.mark.complete("gnome-screenshot --help") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gpasswd.py b/test/t/test_gpasswd.py new file mode 100644 index 00000000..43826a58 --- /dev/null +++ b/test/t/test_gpasswd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGpasswd: + @pytest.mark.complete("gpasswd ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gpc.py b/test/t/test_gpc.py new file mode 100644 index 00000000..9903ef45 --- /dev/null +++ b/test/t/test_gpc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGpc: + @pytest.mark.complete("gpc ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gperf.py b/test/t/test_gperf.py new file mode 100644 index 00000000..f8267bf7 --- /dev/null +++ b/test/t/test_gperf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGperf: + @pytest.mark.complete("gperf --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gpg.py b/test/t/test_gpg.py new file mode 100644 index 00000000..8ead5e9a --- /dev/null +++ b/test/t/test_gpg.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGpg: + @pytest.mark.complete("gpg ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gpg2.py b/test/t/test_gpg2.py new file mode 100644 index 00000000..6a7ff333 --- /dev/null +++ b/test/t/test_gpg2.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGpg2: + @pytest.mark.complete("gpg2 --h") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gpgv.py b/test/t/test_gpgv.py new file mode 100644 index 00000000..05feb71f --- /dev/null +++ b/test/t/test_gpgv.py @@ -0,0 +1,15 @@ +import pytest + + +class TestGpgv: + @pytest.mark.complete("gpgv ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("gpgv -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("gpgv foo.sig foo ") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_gphoto2.py b/test/t/test_gphoto2.py new file mode 100644 index 00000000..830e6f6f --- /dev/null +++ b/test/t/test_gphoto2.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGphoto2: + @pytest.mark.complete("gphoto2 --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gplusplus.py b/test/t/test_gplusplus.py new file mode 100644 index 00000000..eeeb1bff --- /dev/null +++ b/test/t/test_gplusplus.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="g++") +class TestGPlusPlus: + @pytest.mark.complete("g++ ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gprof.py b/test/t/test_gprof.py new file mode 100644 index 00000000..417e0914 --- /dev/null +++ b/test/t/test_gprof.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGprof: + @pytest.mark.complete("gprof --", skipif="! gprof --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_grep.py b/test/t/test_grep.py new file mode 100644 index 00000000..d7d742ec --- /dev/null +++ b/test/t/test_grep.py @@ -0,0 +1,16 @@ +import pytest + + +class TestGrep: + @pytest.mark.complete("grep --") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("grep --no-complete-dir f", cwd="shared/default") + def test_2(self, completion): + """ + Test --no-*dir isn't restricted to dirs only. + + Not really a grep option, but tests _longopt. + """ + assert completion == "foo foo.d/".split() diff --git a/test/t/test_groupadd.py b/test/t/test_groupadd.py new file mode 100644 index 00000000..efea4677 --- /dev/null +++ b/test/t/test_groupadd.py @@ -0,0 +1,11 @@ +import pytest + + +class TestGroupadd: + @pytest.mark.complete("groupadd ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("groupadd -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_groupdel.py b/test/t/test_groupdel.py new file mode 100644 index 00000000..1409e6cc --- /dev/null +++ b/test/t/test_groupdel.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGroupdel: + @pytest.mark.complete("groupdel ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_groupmems.py b/test/t/test_groupmems.py new file mode 100644 index 00000000..2faff633 --- /dev/null +++ b/test/t/test_groupmems.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGroupmems: + @pytest.mark.complete("groupmems -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_groupmod.py b/test/t/test_groupmod.py new file mode 100644 index 00000000..08b1d2e2 --- /dev/null +++ b/test/t/test_groupmod.py @@ -0,0 +1,11 @@ +import pytest + + +class TestGroupmod: + @pytest.mark.complete("groupmod ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("groupmod -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_growisofs.py b/test/t/test_growisofs.py new file mode 100644 index 00000000..7ce19f6b --- /dev/null +++ b/test/t/test_growisofs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGrowisofs: + @pytest.mark.complete("growisofs ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_grpck.py b/test/t/test_grpck.py new file mode 100644 index 00000000..0d6a5cef --- /dev/null +++ b/test/t/test_grpck.py @@ -0,0 +1,11 @@ +import pytest + + +class TestGrpck: + @pytest.mark.complete("grpck ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("grpck -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_grub.py b/test/t/test_grub.py new file mode 100644 index 00000000..8ecd0209 --- /dev/null +++ b/test/t/test_grub.py @@ -0,0 +1,7 @@ +import pytest + + +class TestGrub: + @pytest.mark.complete("grub --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_gzip.py b/test/t/test_gzip.py new file mode 100644 index 00000000..3c2ecb6f --- /dev/null +++ b/test/t/test_gzip.py @@ -0,0 +1,11 @@ +import pytest + + +class TestGzip: + @pytest.mark.complete("gzip ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("gzip ~") + def test_2(self, completion): + assert completion diff --git a/test/t/test_hciattach.py b/test/t/test_hciattach.py new file mode 100644 index 00000000..2dc10956 --- /dev/null +++ b/test/t/test_hciattach.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHciattach: + @pytest.mark.complete("hciattach ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hciconfig.py b/test/t/test_hciconfig.py new file mode 100644 index 00000000..2a3f1fdf --- /dev/null +++ b/test/t/test_hciconfig.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHciconfig: + @pytest.mark.complete("hciconfig ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hcitool.py b/test/t/test_hcitool.py new file mode 100644 index 00000000..8725533f --- /dev/null +++ b/test/t/test_hcitool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHcitool: + @pytest.mark.complete("hcitool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hddtemp.py b/test/t/test_hddtemp.py new file mode 100644 index 00000000..e80a46cc --- /dev/null +++ b/test/t/test_hddtemp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHddtemp: + @pytest.mark.complete("hddtemp -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_head.py b/test/t/test_head.py new file mode 100644 index 00000000..a287034a --- /dev/null +++ b/test/t/test_head.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHead: + @pytest.mark.complete("head --", skipif="! head --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hexdump.py b/test/t/test_hexdump.py new file mode 100644 index 00000000..82b6d2ba --- /dev/null +++ b/test/t/test_hexdump.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHexdump: + @pytest.mark.complete("hexdump -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hid2hci.py b/test/t/test_hid2hci.py new file mode 100644 index 00000000..66766fbd --- /dev/null +++ b/test/t/test_hid2hci.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/lib/udev:$PATH",)) +class TestHid2hci: + @pytest.mark.complete("hid2hci -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_host.py b/test/t/test_host.py new file mode 100644 index 00000000..555a36f5 --- /dev/null +++ b/test/t/test_host.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHost: + @pytest.mark.complete("host -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hostname.py b/test/t/test_hostname.py new file mode 100644 index 00000000..5ccdf458 --- /dev/null +++ b/test/t/test_hostname.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHostname: + @pytest.mark.complete("hostname -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hping2.py b/test/t/test_hping2.py new file mode 100644 index 00000000..77e2ee26 --- /dev/null +++ b/test/t/test_hping2.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHping2: + @pytest.mark.complete("hping2 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_hping3.py b/test/t/test_hping3.py new file mode 100644 index 00000000..a979cfa7 --- /dev/null +++ b/test/t/test_hping3.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHping3: + @pytest.mark.complete("hping3 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_htop.py b/test/t/test_htop.py new file mode 100644 index 00000000..62022bbd --- /dev/null +++ b/test/t/test_htop.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHtop: + @pytest.mark.complete("htop -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_htpasswd.py b/test/t/test_htpasswd.py new file mode 100644 index 00000000..c17c0585 --- /dev/null +++ b/test/t/test_htpasswd.py @@ -0,0 +1,19 @@ +import pytest + + +class TestHtpasswd: + @pytest.mark.complete("htpasswd ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("htpasswd -n htpasswd/ht") + def test_2(self, completion): + assert not completion + + @pytest.mark.complete("htpasswd ", cwd="htpasswd") + def test_3(self, completion): + assert completion == "htpasswd" + + @pytest.mark.complete("htpasswd -D htpasswd ", cwd="htpasswd") + def test_4(self, completion): + assert completion == "foo quux".split() diff --git a/test/t/test_hunspell.py b/test/t/test_hunspell.py new file mode 100644 index 00000000..94ea1020 --- /dev/null +++ b/test/t/test_hunspell.py @@ -0,0 +1,11 @@ +import pytest + + +class TestHunspell: + @pytest.mark.complete("hunspell ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("hunspell -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_hwclock.py b/test/t/test_hwclock.py new file mode 100644 index 00000000..a9cb30fa --- /dev/null +++ b/test/t/test_hwclock.py @@ -0,0 +1,7 @@ +import pytest + + +class TestHwclock: + @pytest.mark.complete("hwclock -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_iconv.py b/test/t/test_iconv.py new file mode 100644 index 00000000..dc5f8961 --- /dev/null +++ b/test/t/test_iconv.py @@ -0,0 +1,11 @@ +import pytest + + +class TestIconv: + @pytest.mark.complete("iconv -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("iconv -f UTF") + def test_2(self, completion): + assert completion diff --git a/test/t/test_id.py b/test/t/test_id.py new file mode 100644 index 00000000..41f2868a --- /dev/null +++ b/test/t/test_id.py @@ -0,0 +1,7 @@ +import pytest + + +class TestId: + @pytest.mark.complete("id -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_identify.py b/test/t/test_identify.py new file mode 100644 index 00000000..12fba008 --- /dev/null +++ b/test/t/test_identify.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIdentify: + @pytest.mark.complete("identify -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_idn.py b/test/t/test_idn.py new file mode 100644 index 00000000..1fd1ce02 --- /dev/null +++ b/test/t/test_idn.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIdn: + @pytest.mark.complete("idn -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ifdown.py b/test/t/test_ifdown.py new file mode 100644 index 00000000..16447be5 --- /dev/null +++ b/test/t/test_ifdown.py @@ -0,0 +1,14 @@ +import pytest + +from conftest import in_docker + + +class TestIfdown: + @pytest.mark.xfail(in_docker(), reason="Probably fails in docker") + @pytest.mark.complete("ifdown ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ifdown bash-completion ") + def test_2(self, completion): + assert not completion diff --git a/test/t/test_ifstat.py b/test/t/test_ifstat.py new file mode 100644 index 00000000..e4d828ee --- /dev/null +++ b/test/t/test_ifstat.py @@ -0,0 +1,19 @@ +import pytest + + +class TestIfstat: + @pytest.mark.complete("ifstat -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete( + "ifstat -i ", skipif="ifstat -v | command grep -qF iproute2" + ) + def test_2(self, completion): + assert completion + + @pytest.mark.complete( + "ifstat -d ", skipif="ifstat -v | command grep -qF iproute2" + ) + def test_3(self, completion): + assert completion diff --git a/test/t/test_iftop.py b/test/t/test_iftop.py new file mode 100644 index 00000000..9a25c28a --- /dev/null +++ b/test/t/test_iftop.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIftop: + @pytest.mark.complete("iftop ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ifup.py b/test/t/test_ifup.py new file mode 100644 index 00000000..62d8eb4a --- /dev/null +++ b/test/t/test_ifup.py @@ -0,0 +1,18 @@ +import pytest + +from conftest import in_docker + + +class TestIfup: + @pytest.mark.xfail(in_docker(), reason="Probably fails in docker") + @pytest.mark.complete("ifup ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ifup --", skipif="! ifup --help &>/dev/null") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("ifup bash-completion ") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_import.py b/test/t/test_import.py new file mode 100644 index 00000000..2e860650 --- /dev/null +++ b/test/t/test_import.py @@ -0,0 +1,7 @@ +import pytest + + +class TestImport: + @pytest.mark.complete("import ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_info.py b/test/t/test_info.py new file mode 100644 index 00000000..b52b682e --- /dev/null +++ b/test/t/test_info.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("INFOPATH+=:$PWD/info:",)) +class TestInfo: + @pytest.mark.complete("info bash") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("info -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_inject.py b/test/t/test_inject.py new file mode 100644 index 00000000..37680dca --- /dev/null +++ b/test/t/test_inject.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestInject: + @pytest.mark.complete("inject ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_inotifywait.py b/test/t/test_inotifywait.py new file mode 100644 index 00000000..fe647ad6 --- /dev/null +++ b/test/t/test_inotifywait.py @@ -0,0 +1,15 @@ +import pytest + + +class TestInotifywait: + @pytest.mark.complete("inotifywait ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("inotifywait --") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("inotifywait -e ") + def test_3(self, completion): + assert completion diff --git a/test/t/test_inotifywatch.py b/test/t/test_inotifywatch.py new file mode 100644 index 00000000..e0e686e8 --- /dev/null +++ b/test/t/test_inotifywatch.py @@ -0,0 +1,15 @@ +import pytest + + +class TestInotifywatch: + @pytest.mark.complete("inotifywatch ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("inotifywatch --") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("inotifywatch -e ") + def test_3(self, completion): + assert len(completion) > 1 diff --git a/test/t/test_insmod.py b/test/t/test_insmod.py new file mode 100644 index 00000000..9636185d --- /dev/null +++ b/test/t/test_insmod.py @@ -0,0 +1,7 @@ +import pytest + + +class TestInsmod: + @pytest.mark.complete("insmod ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_installpkg.py b/test/t/test_installpkg.py new file mode 100644 index 00000000..4e5ab27c --- /dev/null +++ b/test/t/test_installpkg.py @@ -0,0 +1,39 @@ +import fnmatch +import os + +import pytest + + +class TestInstallpkg: + @pytest.mark.complete("installpkg -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("installpkg --") + def test_2(self, completion): + assert ( + completion == "--ask --infobox --md5sum --menu " + "--priority --root --tagfile --terse --warn".split() + ) + + @pytest.mark.complete("installpkg --root ") + def test_3(self, completion): + dirs = sorted(x for x in os.listdir(".") if os.path.isdir("./%s" % x)) + assert completion == ["%s/" % x for x in dirs] + + @pytest.mark.complete("installpkg --root ") + def test_4(self, completion): + expected = sorted( + [ + "%s/" % x + for x in os.listdir("slackware/home") + if os.path.isdir("./%s" % x) + ] + + [ + x + for x in os.listdir("slackware/home") + if os.path.isfile("./%s" % x) + and fnmatch.fnmatch(x, "*.t[bglx]z") + ] + ) + assert completion == expected diff --git a/test/t/test_interdiff.py b/test/t/test_interdiff.py new file mode 100644 index 00000000..e681fd6c --- /dev/null +++ b/test/t/test_interdiff.py @@ -0,0 +1,7 @@ +import pytest + + +class TestInterdiff: + @pytest.mark.complete("interdiff ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_invoke_rc_d.py b/test/t/test_invoke_rc_d.py new file mode 100644 index 00000000..61e2987b --- /dev/null +++ b/test/t/test_invoke_rc_d.py @@ -0,0 +1,14 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="invoke-rc.d") +class TestInvokeRcD: + @pytest.mark.complete("invoke-rc.d ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("invoke-rc.d --no-fallback --") + def test_2(self, completion): + """Test already specified option is not offered.""" + assert completion + assert "--no-fallback" not in completion diff --git a/test/t/test_ionice.py b/test/t/test_ionice.py new file mode 100644 index 00000000..ae047043 --- /dev/null +++ b/test/t/test_ionice.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIonice: + @pytest.mark.complete("ionice -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ip.py b/test/t/test_ip.py new file mode 100644 index 00000000..20752505 --- /dev/null +++ b/test/t/test_ip.py @@ -0,0 +1,11 @@ +import pytest + + +class TestIp: + @pytest.mark.complete("ip ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ip a ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_iperf.py b/test/t/test_iperf.py new file mode 100644 index 00000000..23f4df55 --- /dev/null +++ b/test/t/test_iperf.py @@ -0,0 +1,20 @@ +import pytest + + +class TestIperf: + @pytest.mark.complete("iperf ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("iperf --bind ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("iperf --client foo --") + def test_3(self, completion): + assert completion + assert "--daemon" not in completion + + @pytest.mark.complete("iperf --server --") + def test_4(self, completion): + assert "--daemon" in completion diff --git a/test/t/test_iperf3.py b/test/t/test_iperf3.py new file mode 100644 index 00000000..cd93a996 --- /dev/null +++ b/test/t/test_iperf3.py @@ -0,0 +1,20 @@ +import pytest + + +class TestIperf3: + @pytest.mark.complete("iperf3 ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("iperf3 --bind ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("iperf3 --client foo --") + def test_3(self, completion): + assert completion + assert "--daemon" not in completion + + @pytest.mark.complete("iperf3 --server --") + def test_4(self, completion): + assert "--daemon" in completion diff --git a/test/t/test_ipmitool.py b/test/t/test_ipmitool.py new file mode 100644 index 00000000..5f50ec79 --- /dev/null +++ b/test/t/test_ipmitool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIpmitool: + @pytest.mark.complete("ipmitool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ipsec.py b/test/t/test_ipsec.py new file mode 100644 index 00000000..5ff29c74 --- /dev/null +++ b/test/t/test_ipsec.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIpsec: + @pytest.mark.complete("ipsec ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_iptables.py b/test/t/test_iptables.py new file mode 100644 index 00000000..7a30bb82 --- /dev/null +++ b/test/t/test_iptables.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIptables: + @pytest.mark.complete("iptables -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ipv6calc.py b/test/t/test_ipv6calc.py new file mode 100644 index 00000000..435af149 --- /dev/null +++ b/test/t/test_ipv6calc.py @@ -0,0 +1,11 @@ +import pytest + + +class TestIpv6calc: + @pytest.mark.complete("ipv6calc -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ipv6calc --in ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_irb.py b/test/t/test_irb.py new file mode 100644 index 00000000..31c46e20 --- /dev/null +++ b/test/t/test_irb.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIrb: + @pytest.mark.complete("irb ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_iscsiadm.py b/test/t/test_iscsiadm.py new file mode 100644 index 00000000..932ffeb5 --- /dev/null +++ b/test/t/test_iscsiadm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIscsiadm: + @pytest.mark.complete("iscsiadm --mode") + def test_1(self, completion): + assert completion diff --git a/test/t/test_isort.py b/test/t/test_isort.py new file mode 100644 index 00000000..4fae3244 --- /dev/null +++ b/test/t/test_isort.py @@ -0,0 +1,11 @@ +import pytest + + +class TestIsort: + @pytest.mark.complete("isort ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("isort -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_isql.py b/test/t/test_isql.py new file mode 100644 index 00000000..7ff0bdb4 --- /dev/null +++ b/test/t/test_isql.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("ODBCINI=isql/odbc.ini",)) +class TestIsql: + @pytest.mark.complete("isql ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_iwconfig.py b/test/t/test_iwconfig.py new file mode 100644 index 00000000..3ac4b31a --- /dev/null +++ b/test/t/test_iwconfig.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIwconfig: + @pytest.mark.complete("iwconfig --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_iwlist.py b/test/t/test_iwlist.py new file mode 100644 index 00000000..77ffb99c --- /dev/null +++ b/test/t/test_iwlist.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIwlist: + @pytest.mark.complete("iwlist --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_iwpriv.py b/test/t/test_iwpriv.py new file mode 100644 index 00000000..dac214ae --- /dev/null +++ b/test/t/test_iwpriv.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIwpriv: + @pytest.mark.complete("iwpriv --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_iwspy.py b/test/t/test_iwspy.py new file mode 100644 index 00000000..398df371 --- /dev/null +++ b/test/t/test_iwspy.py @@ -0,0 +1,7 @@ +import pytest + + +class TestIwspy: + @pytest.mark.complete("iwspy --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_jar.py b/test/t/test_jar.py new file mode 100644 index 00000000..5d4ed8a9 --- /dev/null +++ b/test/t/test_jar.py @@ -0,0 +1,7 @@ +import pytest + + +class TestJar: + @pytest.mark.complete("jar ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_jarsigner.py b/test/t/test_jarsigner.py new file mode 100644 index 00000000..a6efa6a3 --- /dev/null +++ b/test/t/test_jarsigner.py @@ -0,0 +1,7 @@ +import pytest + + +class TestJarsigner: + @pytest.mark.complete("jarsigner ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_java.py b/test/t/test_java.py new file mode 100644 index 00000000..81f07c68 --- /dev/null +++ b/test/t/test_java.py @@ -0,0 +1,30 @@ +import pytest + + +@pytest.mark.bashcomp( + pre_cmds=("CLASSPATH=$PWD/java/a:$PWD/java/bashcomp.jar",) +) +class TestJava: + @pytest.mark.complete("java -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("java ") + def test_2(self, completion): + assert completion == "b bashcomp.jarred c. toplevel".split() + + @pytest.mark.complete("java -classpath java/bashcomp.jar ") + def test_3(self, completion): + assert completion == "bashcomp.jarred toplevel".split() + + @pytest.mark.complete("java -cp java/bashcomp.jar:java/a/c ") + def test_4(self, completion): + assert completion == "bashcomp.jarred d toplevel".split() + + @pytest.mark.complete("java -cp '' ") + def test_5(self, completion): + assert not completion + + @pytest.mark.complete("java -jar java/") + def test_6(self, completion): + assert completion == "a/ bashcomp.jar bashcomp.war".split() diff --git a/test/t/test_javac.py b/test/t/test_javac.py new file mode 100644 index 00000000..197004e7 --- /dev/null +++ b/test/t/test_javac.py @@ -0,0 +1,11 @@ +import pytest + + +class TestJavac: + @pytest.mark.complete("javac ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("javac -cp java/") + def test_2(self, completion): + assert completion == "a/ bashcomp.jar".split() diff --git a/test/t/test_javadoc.py b/test/t/test_javadoc.py new file mode 100644 index 00000000..395d196d --- /dev/null +++ b/test/t/test_javadoc.py @@ -0,0 +1,17 @@ +import pytest + + +class TestJavadoc: + @pytest.mark.complete("javadoc ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("javadoc -linkoffline shared/default/") + def test_2(self, completion): + assert completion == ["bar bar.d/", "foo.d/"] + + @pytest.mark.complete( + "javadoc -nodeprecated -linkoffline foo shared/default/" + ) + def test_3(self, completion): + assert completion == ["bar bar.d/", "foo.d/"] diff --git a/test/t/test_javaws.py b/test/t/test_javaws.py new file mode 100644 index 00000000..9f51c58b --- /dev/null +++ b/test/t/test_javaws.py @@ -0,0 +1,7 @@ +import pytest + + +class TestJavaws: + @pytest.mark.complete("javaws ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_jpegoptim.py b/test/t/test_jpegoptim.py new file mode 100644 index 00000000..01eb739c --- /dev/null +++ b/test/t/test_jpegoptim.py @@ -0,0 +1,7 @@ +import pytest + + +class TestJpegoptim: + @pytest.mark.complete("jpegoptim ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_jps.py b/test/t/test_jps.py new file mode 100644 index 00000000..add9ef97 --- /dev/null +++ b/test/t/test_jps.py @@ -0,0 +1,7 @@ +import pytest + + +class TestJps: + @pytest.mark.complete("jps -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_jq.py b/test/t/test_jq.py new file mode 100644 index 00000000..c858411f --- /dev/null +++ b/test/t/test_jq.py @@ -0,0 +1,31 @@ +import pytest + + +class TestJq: + @pytest.mark.complete("jq ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("jq . ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete( + "jq -", + skipif="! (jq --help 2>&1 || :) | " + "command grep -qF 'options include'", + ) + def test_3(self, completion): + assert completion + + @pytest.mark.complete("jq --arg ") + def test_4(self, completion): + assert not completion + + @pytest.mark.complete("jq --slurpfile ") + def test_5(self, completion): + assert not completion + + @pytest.mark.complete("jq --slurpfile foo ") + def test_6(self, completion): + assert completion diff --git a/test/t/test_jshint.py b/test/t/test_jshint.py new file mode 100644 index 00000000..511e7c9d --- /dev/null +++ b/test/t/test_jshint.py @@ -0,0 +1,7 @@ +import pytest + + +class TestJshint: + @pytest.mark.complete("jshint ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_json_xs.py b/test/t/test_json_xs.py new file mode 100644 index 00000000..f6174b10 --- /dev/null +++ b/test/t/test_json_xs.py @@ -0,0 +1,11 @@ +import pytest + + +class TestJsonXs: + @pytest.mark.complete("json_xs ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("json_xs -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_jsonschema.py b/test/t/test_jsonschema.py new file mode 100644 index 00000000..0905fd7f --- /dev/null +++ b/test/t/test_jsonschema.py @@ -0,0 +1,11 @@ +import pytest + + +class TestJsonschema: + @pytest.mark.complete("jsonschema ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("jsonschema -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_k3b.py b/test/t/test_k3b.py new file mode 100644 index 00000000..d9940ba5 --- /dev/null +++ b/test/t/test_k3b.py @@ -0,0 +1,7 @@ +import pytest + + +class TestK3b: + @pytest.mark.complete("k3b ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_kcov.py b/test/t/test_kcov.py new file mode 100644 index 00000000..ce985a78 --- /dev/null +++ b/test/t/test_kcov.py @@ -0,0 +1,16 @@ +import pytest + + +class TestKcov: + @pytest.mark.complete("kcov ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("kcov --exclude-patter") + def test_2(self, completion): + assert completion == "--exclude-pattern=" + assert completion.endswith("=") + + @pytest.mark.complete("kcov -l 42,") + def test_3(self, completion): + assert completion diff --git a/test/t/test_kdvi.py b/test/t/test_kdvi.py new file mode 100644 index 00000000..7fb11cb0 --- /dev/null +++ b/test/t/test_kdvi.py @@ -0,0 +1,10 @@ +import pytest + + +class TestKdvi: + @pytest.mark.complete("kdvi ", cwd="kdvi") + def test_1(self, completion): + assert ( + completion == "foo/ .dvi .DVI .dvi.bz2 .DVI.bz2 .dvi.gz " + ".DVI.gz .dvi.Z .DVI.Z".split() + ) diff --git a/test/t/test_kill.py b/test/t/test_kill.py new file mode 100644 index 00000000..59d5fa2b --- /dev/null +++ b/test/t/test_kill.py @@ -0,0 +1,15 @@ +import pytest + + +class TestKill: + @pytest.mark.complete("kill 1", skipif="! type ps &>/dev/null") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("kill -s ") + def test_2(self, completion): + assert all(x in completion for x in "HUP QUIT".split()) + + @pytest.mark.complete("kill -") + def test_3(self, completion): + assert all("-%s" % x in completion for x in "l s ABRT USR1".split()) diff --git a/test/t/test_killall.py b/test/t/test_killall.py new file mode 100644 index 00000000..725a16e4 --- /dev/null +++ b/test/t/test_killall.py @@ -0,0 +1,13 @@ +import pytest + + +class TestKillall: + + # "p": Assume our process name completion runs ps and at least it is shown + @pytest.mark.complete("killall p") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("killall --signal ") + def test_2(self, completion): + assert all(x in completion for x in "INT KILL TERM".split()) diff --git a/test/t/test_kldload.py b/test/t/test_kldload.py new file mode 100644 index 00000000..2965e446 --- /dev/null +++ b/test/t/test_kldload.py @@ -0,0 +1,7 @@ +import pytest + + +class TestKldload: + @pytest.mark.complete("kldload ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_kldunload.py b/test/t/test_kldunload.py new file mode 100644 index 00000000..a52c99eb --- /dev/null +++ b/test/t/test_kldunload.py @@ -0,0 +1,16 @@ +import subprocess + +import pytest + + +class TestKldunload: + @pytest.mark.complete("kldunload ") + def test_1(self, completion): + try: + subprocess.check_call( + r"kldstat 2>/dev/null | command grep -q '\.ko$'", shell=True + ) + except BaseException: + assert not completion + else: + assert completion diff --git a/test/t/test_koji.py b/test/t/test_koji.py new file mode 100644 index 00000000..68a8477b --- /dev/null +++ b/test/t/test_koji.py @@ -0,0 +1,11 @@ +import pytest + + +class TestKoji: + @pytest.mark.complete("koji ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("koji -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_kpdf.py b/test/t/test_kpdf.py new file mode 100644 index 00000000..ceee34d3 --- /dev/null +++ b/test/t/test_kpdf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestKpdf: + @pytest.mark.complete("kpdf ", cwd="kpdf") + def test_1(self, completion): + assert completion == "foo/ .eps .ps .EPS .PS .pdf .PDF".split() diff --git a/test/t/test_kplayer.py b/test/t/test_kplayer.py new file mode 100644 index 00000000..ef8a08e6 --- /dev/null +++ b/test/t/test_kplayer.py @@ -0,0 +1,7 @@ +import pytest + + +class TestKplayer: + @pytest.mark.complete("kplayer ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ktutil.py b/test/t/test_ktutil.py new file mode 100644 index 00000000..7c90b802 --- /dev/null +++ b/test/t/test_ktutil.py @@ -0,0 +1,11 @@ +import pytest + + +class TestKtutil: + @pytest.mark.complete("ktutil ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ktutil -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_l2ping.py b/test/t/test_l2ping.py new file mode 100644 index 00000000..7979d734 --- /dev/null +++ b/test/t/test_l2ping.py @@ -0,0 +1,7 @@ +import pytest + + +class TestL2ping: + @pytest.mark.complete("l2ping -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_larch.py b/test/t/test_larch.py new file mode 100644 index 00000000..e68183c1 --- /dev/null +++ b/test/t/test_larch.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLarch: + @pytest.mark.complete("larch library-") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lastlog.py b/test/t/test_lastlog.py new file mode 100644 index 00000000..043af962 --- /dev/null +++ b/test/t/test_lastlog.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLastlog: + @pytest.mark.complete("lastlog -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ld.py b/test/t/test_ld.py new file mode 100644 index 00000000..a82f091b --- /dev/null +++ b/test/t/test_ld.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLd: + @pytest.mark.complete("ld ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldapadd.py b/test/t/test_ldapadd.py new file mode 100644 index 00000000..24aa5e39 --- /dev/null +++ b/test/t/test_ldapadd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdapadd: + @pytest.mark.complete("ldapadd -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldapcompare.py b/test/t/test_ldapcompare.py new file mode 100644 index 00000000..6a3afe9a --- /dev/null +++ b/test/t/test_ldapcompare.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdapcompare: + @pytest.mark.complete("ldapcompare -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldapdelete.py b/test/t/test_ldapdelete.py new file mode 100644 index 00000000..2065d9bc --- /dev/null +++ b/test/t/test_ldapdelete.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdapdelete: + @pytest.mark.complete("ldapdelete -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldapmodrdn.py b/test/t/test_ldapmodrdn.py new file mode 100644 index 00000000..da8bdbdc --- /dev/null +++ b/test/t/test_ldapmodrdn.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdapmodrdn: + @pytest.mark.complete("ldapmodrdn -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldappasswd.py b/test/t/test_ldappasswd.py new file mode 100644 index 00000000..e559f23b --- /dev/null +++ b/test/t/test_ldappasswd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdappasswd: + @pytest.mark.complete("ldappasswd -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldapsearch.py b/test/t/test_ldapsearch.py new file mode 100644 index 00000000..43797f41 --- /dev/null +++ b/test/t/test_ldapsearch.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdapsearch: + @pytest.mark.complete("ldapsearch -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldapvi.py b/test/t/test_ldapvi.py new file mode 100644 index 00000000..a81ae180 --- /dev/null +++ b/test/t/test_ldapvi.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdapvi: + @pytest.mark.complete("ldapvi -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldapwhoami.py b/test/t/test_ldapwhoami.py new file mode 100644 index 00000000..9dcfb5f8 --- /dev/null +++ b/test/t/test_ldapwhoami.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdapwhoami: + @pytest.mark.complete("ldapwhoami -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ldd.py b/test/t/test_ldd.py new file mode 100644 index 00000000..8c463b60 --- /dev/null +++ b/test/t/test_ldd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLdd: + @pytest.mark.complete("ldd ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_less.py b/test/t/test_less.py new file mode 100644 index 00000000..79cdf183 --- /dev/null +++ b/test/t/test_less.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLess: + @pytest.mark.complete("less --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lftp.py b/test/t/test_lftp.py new file mode 100644 index 00000000..18506f61 --- /dev/null +++ b/test/t/test_lftp.py @@ -0,0 +1,14 @@ +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD/lftp",)) +class TestLftp: + @pytest.mark.complete("lftp ") + def test_1(self, bash, completion): + hosts = assert_bash_exec( + bash, "compgen -A hostname", want_output=True + ).split() + assert all(x in completion for x in hosts) + assert "lftptest" in completion # defined in lftp/.lftp/bookmarks diff --git a/test/t/test_lftpget.py b/test/t/test_lftpget.py new file mode 100644 index 00000000..c1f453e9 --- /dev/null +++ b/test/t/test_lftpget.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLftpget: + @pytest.mark.complete("lftpget -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lilo.py b/test/t/test_lilo.py new file mode 100644 index 00000000..9783f506 --- /dev/null +++ b/test/t/test_lilo.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLilo: + @pytest.mark.complete("lilo -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_links.py b/test/t/test_links.py new file mode 100644 index 00000000..f21b8728 --- /dev/null +++ b/test/t/test_links.py @@ -0,0 +1,11 @@ +import pytest + + +class TestLinks: + @pytest.mark.complete("links ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("links -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_lintian.py b/test/t/test_lintian.py new file mode 100644 index 00000000..c6526426 --- /dev/null +++ b/test/t/test_lintian.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLintian: + @pytest.mark.complete("lintian --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lintian_info.py b/test/t/test_lintian_info.py new file mode 100644 index 00000000..6bcc9e52 --- /dev/null +++ b/test/t/test_lintian_info.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="lintian-info") +class TestLintianInfo: + @pytest.mark.complete("lintian-info ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("lintian-info --") + def test_2(self, completion): + assert completion diff --git a/test/t/test_lisp.py b/test/t/test_lisp.py new file mode 100644 index 00000000..84770610 --- /dev/null +++ b/test/t/test_lisp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLisp: + @pytest.mark.complete("lisp ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_list_admins.py b/test/t/test_list_admins.py new file mode 100644 index 00000000..b65387e5 --- /dev/null +++ b/test/t/test_list_admins.py @@ -0,0 +1,7 @@ +import pytest + + +class TestListAdmins: + @pytest.mark.complete("list_admins -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_list_lists.py b/test/t/test_list_lists.py new file mode 100644 index 00000000..966ca251 --- /dev/null +++ b/test/t/test_list_lists.py @@ -0,0 +1,7 @@ +import pytest + + +class TestListLists: + @pytest.mark.complete("list_lists -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_list_members.py b/test/t/test_list_members.py new file mode 100644 index 00000000..96ea2ef3 --- /dev/null +++ b/test/t/test_list_members.py @@ -0,0 +1,7 @@ +import pytest + + +class TestListMembers: + @pytest.mark.complete("list_members -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_list_owners.py b/test/t/test_list_owners.py new file mode 100644 index 00000000..2a6bcab8 --- /dev/null +++ b/test/t/test_list_owners.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestListOwners: + @pytest.mark.complete("list_owners -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ln.py b/test/t/test_ln.py new file mode 100644 index 00000000..de053345 --- /dev/null +++ b/test/t/test_ln.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLn: + @pytest.mark.complete("ln ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_locale_gen.py b/test/t/test_locale_gen.py new file mode 100644 index 00000000..41ac376f --- /dev/null +++ b/test/t/test_locale_gen.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="locale-gen") +class TestLocaleGen: + @pytest.mark.complete("locale-gen ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("locale-gen --") + def test_2(self, completion): + assert completion diff --git a/test/t/test_look.py b/test/t/test_look.py new file mode 100644 index 00000000..fd6800e5 --- /dev/null +++ b/test/t/test_look.py @@ -0,0 +1,16 @@ +import subprocess + +import pytest + + +class TestLook: + @pytest.mark.complete("look foo") + def test_1(self, completion): + try: + subprocess.check_call( + "look foo 2>/dev/null | command grep -q ^foo", shell=True + ) + except BaseException: + assert not completion + else: + assert completion diff --git a/test/t/test_lpq.py b/test/t/test_lpq.py new file mode 100644 index 00000000..0d69270d --- /dev/null +++ b/test/t/test_lpq.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLpq: + @pytest.mark.complete("lpq ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lpr.py b/test/t/test_lpr.py new file mode 100644 index 00000000..30c710bb --- /dev/null +++ b/test/t/test_lpr.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLpr: + @pytest.mark.complete("lpr ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lrzip.py b/test/t/test_lrzip.py new file mode 100644 index 00000000..266d8a30 --- /dev/null +++ b/test/t/test_lrzip.py @@ -0,0 +1,11 @@ +import pytest + + +class TestLrzip: + @pytest.mark.complete("lrzip ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("lrzip ~") + def test_2(self, completion): + assert completion diff --git a/test/t/test_ls.py b/test/t/test_ls.py new file mode 100644 index 00000000..ed5ad9c4 --- /dev/null +++ b/test/t/test_ls.py @@ -0,0 +1,38 @@ +import pytest + +from conftest import ( + assert_bash_exec, + assert_complete, + find_unique_completion_pair, +) + + +class TestLs: + @pytest.mark.complete("ls --", skipif="! ls --help &>/dev/null") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ls ~") + def test_2(self, completion): + assert completion + + def test_3(self, bash): + """~part should complete to ~full<SPACE> if home dir does not exist.""" + res = ( + assert_bash_exec( + bash, + "for u in $(compgen -u); do " + "eval test -d ~$u || echo $u; unset u; done", + want_output=True, + ) + .strip() + .split() + ) + part_full = find_unique_completion_pair(res) + if not part_full: + pytest.skip("No suitable test user found") + return + part, full = part_full + completion = assert_complete(bash, "ls ~%s" % part) + assert completion == "~%s" % full + assert completion.endswith(" ") diff --git a/test/t/test_lsof.py b/test/t/test_lsof.py new file mode 100644 index 00000000..170d2690 --- /dev/null +++ b/test/t/test_lsof.py @@ -0,0 +1,11 @@ +import pytest + + +class TestLsof: + @pytest.mark.complete("lsof ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("lsof -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_lspci.py b/test/t/test_lspci.py new file mode 100644 index 00000000..44663426 --- /dev/null +++ b/test/t/test_lspci.py @@ -0,0 +1,11 @@ +import pytest + + +class TestLspci: + @pytest.mark.complete("lspci -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("lspci -A ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_lsscsi.py b/test/t/test_lsscsi.py new file mode 100644 index 00000000..a297b375 --- /dev/null +++ b/test/t/test_lsscsi.py @@ -0,0 +1,11 @@ +import pytest + + +class TestLsscsi: + @pytest.mark.complete("lsscsi ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("lsscsi -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_lsusb.py b/test/t/test_lsusb.py new file mode 100644 index 00000000..9c546d32 --- /dev/null +++ b/test/t/test_lsusb.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLsusb: + @pytest.mark.complete("lsusb -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lua.py b/test/t/test_lua.py new file mode 100644 index 00000000..edcae883 --- /dev/null +++ b/test/t/test_lua.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLua: + @pytest.mark.complete("lua ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_luac.py b/test/t/test_luac.py new file mode 100644 index 00000000..f14d400a --- /dev/null +++ b/test/t/test_luac.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLuac: + @pytest.mark.complete("luac ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_luseradd.py b/test/t/test_luseradd.py new file mode 100644 index 00000000..35c89e54 --- /dev/null +++ b/test/t/test_luseradd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLuseradd: + @pytest.mark.complete("luseradd -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_luserdel.py b/test/t/test_luserdel.py new file mode 100644 index 00000000..cdca2a57 --- /dev/null +++ b/test/t/test_luserdel.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLuserdel: + @pytest.mark.complete("luserdel ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lusermod.py b/test/t/test_lusermod.py new file mode 100644 index 00000000..69ef07c2 --- /dev/null +++ b/test/t/test_lusermod.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLusermod: + @pytest.mark.complete("lusermod ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvchange.py b/test/t/test_lvchange.py new file mode 100644 index 00000000..5722a581 --- /dev/null +++ b/test/t/test_lvchange.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvchange: + @pytest.mark.complete( + "lvchange --", skipif="! lvchange --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvcreate.py b/test/t/test_lvcreate.py new file mode 100644 index 00000000..e60432f6 --- /dev/null +++ b/test/t/test_lvcreate.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvcreate: + @pytest.mark.complete( + "lvcreate --", skipif="! lvcreate --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvdisplay.py b/test/t/test_lvdisplay.py new file mode 100644 index 00000000..e9a955ed --- /dev/null +++ b/test/t/test_lvdisplay.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvdisplay: + @pytest.mark.complete( + "lvdisplay --", skipif="! lvdisplay --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvextend.py b/test/t/test_lvextend.py new file mode 100644 index 00000000..68e17848 --- /dev/null +++ b/test/t/test_lvextend.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvextend: + @pytest.mark.complete( + "lvextend --", skipif="! lvextend --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvm.py b/test/t/test_lvm.py new file mode 100644 index 00000000..ea25b977 --- /dev/null +++ b/test/t/test_lvm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLvm: + @pytest.mark.complete("lvm pv") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvmdiskscan.py b/test/t/test_lvmdiskscan.py new file mode 100644 index 00000000..0716d5c4 --- /dev/null +++ b/test/t/test_lvmdiskscan.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvmdiskscan: + @pytest.mark.complete( + "lvmdiskscan --", skipif="! lvmdiskscan --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvreduce.py b/test/t/test_lvreduce.py new file mode 100644 index 00000000..50b038fd --- /dev/null +++ b/test/t/test_lvreduce.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvreduce: + @pytest.mark.complete( + "lvreduce --", skipif="! lvreduce --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvremove.py b/test/t/test_lvremove.py new file mode 100644 index 00000000..53950aec --- /dev/null +++ b/test/t/test_lvremove.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvremove: + @pytest.mark.complete( + "lvremove --", skipif="! lvremove --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvrename.py b/test/t/test_lvrename.py new file mode 100644 index 00000000..c60469f5 --- /dev/null +++ b/test/t/test_lvrename.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvrename: + @pytest.mark.complete( + "lvrename --", skipif="! lvrename --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvresize.py b/test/t/test_lvresize.py new file mode 100644 index 00000000..aecc8bf4 --- /dev/null +++ b/test/t/test_lvresize.py @@ -0,0 +1,9 @@ +import pytest + + +class TestLvresize: + @pytest.mark.complete( + "lvresize --", skipif="! lvresize --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvs.py b/test/t/test_lvs.py new file mode 100644 index 00000000..456368b9 --- /dev/null +++ b/test/t/test_lvs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLvs: + @pytest.mark.complete("lvs --", skipif="! lvs --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lvscan.py b/test/t/test_lvscan.py new file mode 100644 index 00000000..4848fe4c --- /dev/null +++ b/test/t/test_lvscan.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLvscan: + @pytest.mark.complete("lvscan --", skipif="! lvscan --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lz4.py b/test/t/test_lz4.py new file mode 100644 index 00000000..0d873b66 --- /dev/null +++ b/test/t/test_lz4.py @@ -0,0 +1,11 @@ +import pytest + + +class TestLz4: + @pytest.mark.complete("lz4 ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("lz4 ~") + def test_2(self, completion): + assert completion diff --git a/test/t/test_lzip.py b/test/t/test_lzip.py new file mode 100644 index 00000000..6f1dc023 --- /dev/null +++ b/test/t/test_lzip.py @@ -0,0 +1,7 @@ +import pytest + + +class TestLzip: + @pytest.mark.complete("lzip ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_lzma.py b/test/t/test_lzma.py new file mode 100644 index 00000000..f9d89926 --- /dev/null +++ b/test/t/test_lzma.py @@ -0,0 +1,19 @@ +import pytest + + +class TestLzma: + @pytest.mark.complete("lzma ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("lzma -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("lzma -d xz/") + def test_3(self, completion): + assert completion == "a/ bashcomp.lzma bashcomp.tlz".split() + + @pytest.mark.complete("lzma ~") + def test_4(self, completion): + assert completion diff --git a/test/t/test_lzop.py b/test/t/test_lzop.py new file mode 100644 index 00000000..bd010fde --- /dev/null +++ b/test/t/test_lzop.py @@ -0,0 +1,11 @@ +import pytest + + +class TestLzop: + @pytest.mark.complete("lzop ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("lzop ~") + def test_2(self, completion): + assert completion diff --git a/test/t/test_m4.py b/test/t/test_m4.py new file mode 100644 index 00000000..d80a7538 --- /dev/null +++ b/test/t/test_m4.py @@ -0,0 +1,7 @@ +import pytest + + +class TestM4: + @pytest.mark.complete("m4 --", skipif="! m4 --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_macof.py b/test/t/test_macof.py new file mode 100644 index 00000000..8030c379 --- /dev/null +++ b/test/t/test_macof.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMacof: + @pytest.mark.complete("macof -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mailmanctl.py b/test/t/test_mailmanctl.py new file mode 100644 index 00000000..2baa0500 --- /dev/null +++ b/test/t/test_mailmanctl.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=/usr/lib/mailman/bin:$PATH",)) +class TestMailmanctl: + @pytest.mark.complete("mailmanctl ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mailsnarf.py b/test/t/test_mailsnarf.py new file mode 100644 index 00000000..4e264a6e --- /dev/null +++ b/test/t/test_mailsnarf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMailsnarf: + @pytest.mark.complete("mailsnarf -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_make.py b/test/t/test_make.py new file mode 100644 index 00000000..9c76f83c --- /dev/null +++ b/test/t/test_make.py @@ -0,0 +1,50 @@ +import os + +import pytest + +from conftest import in_docker + + +class TestMake: + @pytest.mark.complete("make -f Ma", cwd="make") + def test_1(self, completion): + assert completion == "Makefile" + + @pytest.mark.complete("make .", cwd="make") + def test_2(self, bash, completion): + """Hidden targets.""" + assert completion == ".cache/ .test_passes".split() + os.remove("%s/make/%s" % (bash.cwd, "extra_makefile")) + + @pytest.mark.complete("make .cache/", cwd="make") + def test_3(self, bash, completion): + assert completion == "1 2".split() + os.remove("%s/make/%s" % (bash.cwd, "extra_makefile")) + + @pytest.mark.complete("make ", cwd="shared/empty_dir") + def test_4(self, completion): + assert not completion + + @pytest.mark.complete("make -j ") + def test_5(self, completion): + assert completion + + @pytest.mark.complete("make ", cwd="make") + def test_6(self, bash, completion): + assert completion == "all clean extra_makefile install sample".split() + os.remove("%s/make/%s" % (bash.cwd, "extra_makefile")) + + @pytest.mark.xfail( + in_docker() and os.environ.get("DIST") == "centos6", + reason="Fails for some unknown reason on CentOS 6, " + "even though the behavior appears to be correct", + ) + @pytest.mark.complete("make .cache/.", cwd="make") + def test_7(self, bash, completion): + assert completion == ".1 .2".split() + os.remove("%s/make/%s" % (bash.cwd, "extra_makefile")) + + @pytest.mark.complete("make -C make ") + def test_8(self, bash, completion): + assert completion == "all clean extra_makefile install sample".split() + os.remove("%s/make/%s" % (bash.cwd, "extra_makefile")) diff --git a/test/t/test_makepkg.py b/test/t/test_makepkg.py new file mode 100644 index 00000000..65f49ea8 --- /dev/null +++ b/test/t/test_makepkg.py @@ -0,0 +1,14 @@ +import pytest + + +@pytest.mark.bashcomp(skipif="! makepkg --help 2>&1 | grep -qiF slackware") +class TestMakepkg: + @pytest.mark.complete("makepkg ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("makepkg --") + def test_2(self, completion): + assert all( + x in completion for x in "--chown --linkadd --prepend".split() + ) diff --git a/test/t/test_man.py b/test/t/test_man.py new file mode 100644 index 00000000..60021d99 --- /dev/null +++ b/test/t/test_man.py @@ -0,0 +1,108 @@ +import os + +import pytest + +from conftest import assert_bash_exec, in_docker + + +@pytest.mark.bashcomp(ignore_env=r"^[+-]MANPATH=") +class TestMan: + + manpath = "$PWD/man" + assumed_present = "man" + + @pytest.fixture + def colonpath(self, request, bash): + try: + assert_bash_exec(bash, "uname -s 2>&1 | grep -qiF cygwin") + except AssertionError: + pass + else: + pytest.skip("Cygwin doesn't like paths with colons") + return + assert_bash_exec(bash, "mkdir -p $TESTDIR/../tmp/man/man3") + assert_bash_exec( + bash, "touch $TESTDIR/../tmp/man/man3/Bash::Completion.3pm.gz" + ) + request.addfinalizer( + lambda: assert_bash_exec(bash, "rm -r $TESTDIR/../tmp/man") + ) + + @pytest.mark.complete( + "man bash-completion-testcas", env=dict(MANPATH=manpath) + ) + def test_1(self, completion): + assert completion == "bash-completion-testcase" + + @pytest.mark.complete("man man1/f", cwd="man", env=dict(MANPATH=manpath)) + def test_2(self, completion): + assert completion == "man1/foo.1" + + @pytest.mark.complete("man man/", cwd="man", env=dict(MANPATH=manpath)) + def test_3(self, completion): + assert completion == "man/quux.8" + + @pytest.mark.xfail( + in_docker() and os.environ.get("DIST") == "centos6", + reason="TODO: Fails in CentOS for some reason, unknown " + "how to trigger same behavior as tests show (is " + "different and correct when tried manually, but here " + "at least in CI completes things it should not with " + "this MANPATH setting)", + ) + @pytest.mark.complete( + "man %s" % assumed_present, + cwd="shared/empty_dir", + env=dict(MANPATH=manpath), + ) + def test_4(self, completion): + """ + Assumed present should not be completed complete when there's no + leading/trailing colon in $MANPATH. + """ + assert not completion + + @pytest.mark.complete( + "man %s" % assumed_present, + cwd="shared/empty_dir", + env=dict(MANPATH="%s:" % manpath), + ) + def test_5(self, completion): + """Trailing colon appends system man path.""" + assert completion + + @pytest.mark.complete( + "man bash-completion-testcas", env=dict(MANPATH="%s:" % manpath) + ) + def test_6(self, completion): + assert completion == "bash-completion-testcase" + + @pytest.mark.complete( + "man %s" % assumed_present, + cwd="shared/empty_dir", + env=dict(MANPATH=":%s" % manpath), + ) + def test_7(self, completion): + """Leading colon prepends system man path.""" + assert completion + + @pytest.mark.complete( + "man bash-completion-testcas", env=dict(MANPATH=":%s" % manpath) + ) + def test_8(self, completion): + assert completion == "bash-completion-testcase" + + @pytest.mark.complete( + "man %s" % assumed_present, + cwd="shared/empty_dir", + pre_cmds=("shopt -s failglob",), + ) + def test_9(self, bash, completion): + assert self.assumed_present in completion + assert_bash_exec(bash, "shopt -u failglob") + + @pytest.mark.complete( + "man Bash::C", env=dict(MANPATH="%s:../tmp/man" % manpath) + ) + def test_10(self, bash, colonpath, completion): + assert completion == "Bash::Completion" diff --git a/test/t/test_mc.py b/test/t/test_mc.py new file mode 100644 index 00000000..9632d6a9 --- /dev/null +++ b/test/t/test_mc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMc: + @pytest.mark.complete("mc -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mcrypt.py b/test/t/test_mcrypt.py new file mode 100644 index 00000000..da80ef5d --- /dev/null +++ b/test/t/test_mcrypt.py @@ -0,0 +1,15 @@ +import pytest + + +class TestMcrypt: + @pytest.mark.complete("mcrypt ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mcrypt -a ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("mcrypt -m ") + def test_3(self, completion): + assert completion diff --git a/test/t/test_md5sum.py b/test/t/test_md5sum.py new file mode 100644 index 00000000..fa364ea1 --- /dev/null +++ b/test/t/test_md5sum.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMd5sum: + @pytest.mark.complete("md5sum ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mdadm.py b/test/t/test_mdadm.py new file mode 100644 index 00000000..143007b3 --- /dev/null +++ b/test/t/test_mdadm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMdadm: + @pytest.mark.complete("mdadm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mdecrypt.py b/test/t/test_mdecrypt.py new file mode 100644 index 00000000..f6f4c8ed --- /dev/null +++ b/test/t/test_mdecrypt.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMdecrypt: + @pytest.mark.complete("mdecrypt ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mdtool.py b/test/t/test_mdtool.py new file mode 100644 index 00000000..356e907d --- /dev/null +++ b/test/t/test_mdtool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMdtool: + @pytest.mark.complete("mdtool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_medusa.py b/test/t/test_medusa.py new file mode 100644 index 00000000..bffa1c46 --- /dev/null +++ b/test/t/test_medusa.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMedusa: + @pytest.mark.complete("medusa -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mencoder.py b/test/t/test_mencoder.py new file mode 100644 index 00000000..ba946c7e --- /dev/null +++ b/test/t/test_mencoder.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD/mplayer",)) +class TestMencoder: + @pytest.mark.complete("mencoder ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mencoder -v") + def test_2(self, completion): + assert completion diff --git a/test/t/test_mii_diag.py b/test/t/test_mii_diag.py new file mode 100644 index 00000000..fa527e94 --- /dev/null +++ b/test/t/test_mii_diag.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="mii-diag") +class TestMiiDiag: + @pytest.mark.complete("mii-diag ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mii_tool.py b/test/t/test_mii_tool.py new file mode 100644 index 00000000..32568f82 --- /dev/null +++ b/test/t/test_mii_tool.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="mii-tool") +class TestMiiTool: + @pytest.mark.complete("mii-tool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_minicom.py b/test/t/test_minicom.py new file mode 100644 index 00000000..c004fadd --- /dev/null +++ b/test/t/test_minicom.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMinicom: + @pytest.mark.complete("minicom -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mkdir.py b/test/t/test_mkdir.py new file mode 100644 index 00000000..a5eb1a54 --- /dev/null +++ b/test/t/test_mkdir.py @@ -0,0 +1,18 @@ +import pytest + + +class TestMkdir: + @pytest.mark.complete("mkdir ") + def test_1(self, completion): + assert completion + + @pytest.mark.xfail # TODO: whitespace split issue + @pytest.mark.complete("mkdir ", cwd="shared/default") + def test_2(self, completion): + assert completion == ["bar bar.d/", "foo", "foo.d/"] + + @pytest.mark.xfail # TODO: why path in completion, basename in .output? + @pytest.mark.complete("mkdir shared/default/foo.d/") + def test_3(self, completion): + assert completion.output == "foo" + assert completion == [completion.output] diff --git a/test/t/test_mkfifo.py b/test/t/test_mkfifo.py new file mode 100644 index 00000000..b9e0013c --- /dev/null +++ b/test/t/test_mkfifo.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMkfifo: + @pytest.mark.complete("mkfifo ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mkinitrd.py b/test/t/test_mkinitrd.py new file mode 100644 index 00000000..7305925d --- /dev/null +++ b/test/t/test_mkinitrd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMkinitrd: + @pytest.mark.complete("mkinitrd ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mkisofs.py b/test/t/test_mkisofs.py new file mode 100644 index 00000000..541c6e7e --- /dev/null +++ b/test/t/test_mkisofs.py @@ -0,0 +1,15 @@ +import pytest + + +class TestMkisofs: + @pytest.mark.complete("mkisofs ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mkisofs -uid ") + def test_2(self, completion): + assert not [x for x in completion if not x.isdigit()] + + @pytest.mark.complete("mkisofs -gid ") + def test_3(self, completion): + assert not [x for x in completion if not x.isdigit()] diff --git a/test/t/test_mknod.py b/test/t/test_mknod.py new file mode 100644 index 00000000..46cb2284 --- /dev/null +++ b/test/t/test_mknod.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMknod: + @pytest.mark.complete("mknod ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mktemp.py b/test/t/test_mktemp.py new file mode 100644 index 00000000..9f61be1c --- /dev/null +++ b/test/t/test_mktemp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMktemp: + @pytest.mark.complete("mktemp -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mmsitepass.py b/test/t/test_mmsitepass.py new file mode 100644 index 00000000..4dcd9fb0 --- /dev/null +++ b/test/t/test_mmsitepass.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMmsitepass: + @pytest.mark.complete("mmsitepass -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mock.py b/test/t/test_mock.py new file mode 100644 index 00000000..7dc5de2a --- /dev/null +++ b/test/t/test_mock.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMock: + @pytest.mark.complete("mock ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_modinfo.py b/test/t/test_modinfo.py new file mode 100644 index 00000000..4c96eef0 --- /dev/null +++ b/test/t/test_modinfo.py @@ -0,0 +1,32 @@ +import subprocess + +import pytest + + +class TestModinfo: + @pytest.mark.complete("modinfo -") + def test_1(self, completion): + assert completion + + # "in": intel*, ... + @pytest.mark.complete( + "modinfo in", + skipif="! ls /lib/modules/%s &>/dev/null" + % subprocess.check_output( + "uname -r 2>/dev/null || " "echo non-existent-kernel", shell=True + ) + .decode() + .strip(), + ) + def test_2(self, completion): + assert completion + + # "in": intel*, ... + @pytest.mark.complete("modinfo -k non-existent-kernel in") + def test_3(self, completion): + assert not completion + + @pytest.mark.complete("modinfo /tm") + def test_4(self, completion): + assert completion + assert not completion.endswith(" ") diff --git a/test/t/test_modprobe.py b/test/t/test_modprobe.py new file mode 100644 index 00000000..339240f6 --- /dev/null +++ b/test/t/test_modprobe.py @@ -0,0 +1,36 @@ +import subprocess + +import pytest + + +class TestModprobe: + @pytest.mark.complete("modprobe --al") + def test_1(self, completion): + assert completion == "--all" + + # "in": intel*, ... + @pytest.mark.complete( + "modprobe in", + skipif="! ls /lib/modules/%s &>/dev/null" + % subprocess.check_output( + "uname -r 2>/dev/null || " "echo non-existent-kernel", shell=True + ) + .decode() + .strip(), + ) + def test_2(self, completion): + assert completion + + # "in": intel*, ... + @pytest.mark.complete("modprobe -S non-existent-kernel in") + def test_3(self, completion): + assert not completion + + @pytest.mark.complete("modprobe non-existent-module ") + def test_4(self, completion): + assert not completion + + @pytest.mark.complete("modprobe /tm") + def test_5(self, completion): + assert completion + assert not completion.endswith(" ") diff --git a/test/t/test_module.py b/test/t/test_module.py new file mode 100644 index 00000000..a66dea74 --- /dev/null +++ b/test/t/test_module.py @@ -0,0 +1,7 @@ +import pytest + + +class TestModule: + @pytest.mark.complete("module ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mogrify.py b/test/t/test_mogrify.py new file mode 100644 index 00000000..22d84a89 --- /dev/null +++ b/test/t/test_mogrify.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMogrify: + @pytest.mark.complete("mogrify ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_monodevelop.py b/test/t/test_monodevelop.py new file mode 100644 index 00000000..472b1aba --- /dev/null +++ b/test/t/test_monodevelop.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMonodevelop: + @pytest.mark.complete("monodevelop ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_montage.py b/test/t/test_montage.py new file mode 100644 index 00000000..1237c7df --- /dev/null +++ b/test/t/test_montage.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMontage: + @pytest.mark.complete("montage ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mount.py b/test/t/test_mount.py new file mode 100644 index 00000000..fbd6dcae --- /dev/null +++ b/test/t/test_mount.py @@ -0,0 +1,22 @@ +import pytest + + +class TestMount: + @pytest.mark.complete("mount ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mount -t ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("mount /dev/sda1 def", cwd="shared") + def test_3(self, completion): + assert completion == "default/" + assert not completion.endswith(" ") + + @pytest.mark.complete( + "mount mocksrv:/", env=dict(PATH="$PWD/mount/bin:$PATH") + ) + def test_4(self, completion): + assert completion == "/second/path /test/path /test/path2".split() diff --git a/test/t/test_mplayer.py b/test/t/test_mplayer.py new file mode 100644 index 00000000..88d7b9f1 --- /dev/null +++ b/test/t/test_mplayer.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD/mplayer",)) +class TestMplayer: + @pytest.mark.complete("mplayer ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mplayer -h") + def test_2(self, completion): + assert completion diff --git a/test/t/test_mr.py b/test/t/test_mr.py new file mode 100644 index 00000000..ab45350b --- /dev/null +++ b/test/t/test_mr.py @@ -0,0 +1,43 @@ +import pytest + + +class TestMr: + @pytest.mark.complete("mr ") + def test_1(self, completion): + assert completion + + # man -h tests below: Some mr versions require man to be around in order + # to provide useful output. + + @pytest.mark.complete("mr --", skipif="! man -h &>/dev/null") + def test_2(self, completion): + assert completion + + @pytest.mark.complete( + "mr -c shared/default/foo.d/", skipif="! man -h &>/dev/null" + ) + def test_3(self, completion): + assert completion == "shared/default/foo.d/foo" + + @pytest.mark.complete( + "mr bootstrap shared/default/", skipif="! man -h &>/dev/null" + ) + def test_4(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] + + @pytest.mark.xfail # "clean" doesn't exist before mr 1.20141023 + @pytest.mark.complete("mr clean -", skipif="! man -h &>/dev/null") + def test_5(self, completion): + assert completion == "-f" + + @pytest.mark.complete("mr commit -", skipif="! man -h &>/dev/null") + def test_6(self, completion): + assert completion == "-m" + + @pytest.mark.complete("mr status ", skipif="! man -h &>/dev/null") + def test_7(self, completion): + assert not completion + + @pytest.mark.complete("mr run ", skipif="! man -h &>/dev/null") + def test_8(self, completion): + assert completion diff --git a/test/t/test_msgsnarf.py b/test/t/test_msgsnarf.py new file mode 100644 index 00000000..5ef0fcb7 --- /dev/null +++ b/test/t/test_msgsnarf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMsgsnarf: + @pytest.mark.complete("msgsnarf -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_msynctool.py b/test/t/test_msynctool.py new file mode 100644 index 00000000..530d751b --- /dev/null +++ b/test/t/test_msynctool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMsynctool: + @pytest.mark.complete("msynctool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mtx.py b/test/t/test_mtx.py new file mode 100644 index 00000000..6b6f59b5 --- /dev/null +++ b/test/t/test_mtx.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMtx: + @pytest.mark.complete("mtx ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_munin_node_configure.py b/test/t/test_munin_node_configure.py new file mode 100644 index 00000000..f3f23e7d --- /dev/null +++ b/test/t/test_munin_node_configure.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="munin-node-configure") +class TestMuninNodeConfigure: + @pytest.mark.complete("munin-node-configure --libdir ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_munin_run.py b/test/t/test_munin_run.py new file mode 100644 index 00000000..1bcb4d85 --- /dev/null +++ b/test/t/test_munin_run.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="munin-run") +class TestMuninRun: + @pytest.mark.complete("munin-run -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_munindoc.py b/test/t/test_munindoc.py new file mode 100644 index 00000000..6b226e43 --- /dev/null +++ b/test/t/test_munindoc.py @@ -0,0 +1,9 @@ +import pytest + + +class TestMunindoc: + + # Assume at least munin* available + @pytest.mark.complete("munindoc m") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mussh.py b/test/t/test_mussh.py new file mode 100644 index 00000000..87dd52a1 --- /dev/null +++ b/test/t/test_mussh.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMussh: + @pytest.mark.complete("mussh -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mutt.py b/test/t/test_mutt.py new file mode 100644 index 00000000..b490c88b --- /dev/null +++ b/test/t/test_mutt.py @@ -0,0 +1,33 @@ +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD/mutt",)) +class TestMutt: + @pytest.mark.complete("mutt -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mutt -F muttrc -f =", cwd="mutt") + def test_2(self, completion): + assert completion == "bar/ foo/ muttrc".split() + + @pytest.mark.complete("mutt -F muttrc -A ", cwd="mutt") + def test_3(self, completion): + assert completion == "a1 a2".split() + + def test_4(self, bash): + got = ( + assert_bash_exec( + bash, + '_muttconffiles "$HOME/muttrc" "$HOME/muttrc"', + want_output=True, + ) + .strip() + .split() + ) + assert got == [ + "%s/mutt/%s" % (bash.cwd, x) + for x in ("muttrc", "bar/muttrc_b", "foo/muttrc_f") + ] diff --git a/test/t/test_muttng.py b/test/t/test_muttng.py new file mode 100644 index 00000000..3ce19ac9 --- /dev/null +++ b/test/t/test_muttng.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMuttng: + @pytest.mark.complete("muttng -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mv.py b/test/t/test_mv.py new file mode 100644 index 00000000..a9fc969d --- /dev/null +++ b/test/t/test_mv.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMv: + @pytest.mark.complete("mv ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_mypy.py b/test/t/test_mypy.py new file mode 100644 index 00000000..cecea92d --- /dev/null +++ b/test/t/test_mypy.py @@ -0,0 +1,15 @@ +import pytest + + +class TestMypy: + @pytest.mark.complete("mypy ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mypy --") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("mypy --non-existent-option=--") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_mysql.py b/test/t/test_mysql.py new file mode 100644 index 00000000..6a44b7e5 --- /dev/null +++ b/test/t/test_mysql.py @@ -0,0 +1,15 @@ +import pytest + + +class TestMysql: + @pytest.mark.complete("mysql --") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("mysql --default-character-set=") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("mysql --non-existent-option=--") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_mysqladmin.py b/test/t/test_mysqladmin.py new file mode 100644 index 00000000..74db63b0 --- /dev/null +++ b/test/t/test_mysqladmin.py @@ -0,0 +1,7 @@ +import pytest + + +class TestMysqladmin: + @pytest.mark.complete("mysqladmin -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_nc.py b/test/t/test_nc.py new file mode 100644 index 00000000..6a50106e --- /dev/null +++ b/test/t/test_nc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNc: + @pytest.mark.complete("nc -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ncftp.py b/test/t/test_ncftp.py new file mode 100644 index 00000000..470f6a76 --- /dev/null +++ b/test/t/test_ncftp.py @@ -0,0 +1,11 @@ +import pytest + + +class TestNcftp: + @pytest.mark.complete("ncftp ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ncftp -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_nethogs.py b/test/t/test_nethogs.py new file mode 100644 index 00000000..a36c587f --- /dev/null +++ b/test/t/test_nethogs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNethogs: + @pytest.mark.complete("nethogs ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_netstat.py b/test/t/test_netstat.py new file mode 100644 index 00000000..6bcbd4d2 --- /dev/null +++ b/test/t/test_netstat.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNetstat: + @pytest.mark.complete("netstat ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_newgrp.py b/test/t/test_newgrp.py new file mode 100644 index 00000000..7d65a167 --- /dev/null +++ b/test/t/test_newgrp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNewgrp: + @pytest.mark.complete("newgrp ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_newlist.py b/test/t/test_newlist.py new file mode 100644 index 00000000..d51dab26 --- /dev/null +++ b/test/t/test_newlist.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNewlist: + @pytest.mark.complete("newlist -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_newusers.py b/test/t/test_newusers.py new file mode 100644 index 00000000..acd93ad2 --- /dev/null +++ b/test/t/test_newusers.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNewusers: + @pytest.mark.complete("newusers ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ngrep.py b/test/t/test_ngrep.py new file mode 100644 index 00000000..0d29abd7 --- /dev/null +++ b/test/t/test_ngrep.py @@ -0,0 +1,11 @@ +import pytest + + +class TestNgrep: + @pytest.mark.complete("ngrep -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ngrep -d ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_nl.py b/test/t/test_nl.py new file mode 100644 index 00000000..c3e35b42 --- /dev/null +++ b/test/t/test_nl.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNl: + @pytest.mark.complete("nl ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_nm.py b/test/t/test_nm.py new file mode 100644 index 00000000..49ff167e --- /dev/null +++ b/test/t/test_nm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNm: + @pytest.mark.complete("nm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_nmap.py b/test/t/test_nmap.py new file mode 100644 index 00000000..a4d8a899 --- /dev/null +++ b/test/t/test_nmap.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNmap: + @pytest.mark.complete("nmap --v") + def test_1(self, completion): + assert completion diff --git a/test/t/test_nmcli.py b/test/t/test_nmcli.py new file mode 100644 index 00000000..f2b79504 --- /dev/null +++ b/test/t/test_nmcli.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNmcli: + @pytest.mark.complete("nmcli ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_nproc.py b/test/t/test_nproc.py new file mode 100644 index 00000000..6ab8017c --- /dev/null +++ b/test/t/test_nproc.py @@ -0,0 +1,11 @@ +import pytest + + +class TestNproc: + @pytest.mark.complete("nproc ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("nproc -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_nslookup.py b/test/t/test_nslookup.py new file mode 100644 index 00000000..0286509e --- /dev/null +++ b/test/t/test_nslookup.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNslookup: + @pytest.mark.complete("nslookup -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_nsupdate.py b/test/t/test_nsupdate.py new file mode 100644 index 00000000..5bae9707 --- /dev/null +++ b/test/t/test_nsupdate.py @@ -0,0 +1,11 @@ +import pytest + + +class TestNsupdate: + @pytest.mark.complete("nsupdate ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("nsupdate -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_ntpdate.py b/test/t/test_ntpdate.py new file mode 100644 index 00000000..dc1d5b48 --- /dev/null +++ b/test/t/test_ntpdate.py @@ -0,0 +1,7 @@ +import pytest + + +class TestNtpdate: + @pytest.mark.complete("ntpdate -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_objcopy.py b/test/t/test_objcopy.py new file mode 100644 index 00000000..13a93df5 --- /dev/null +++ b/test/t/test_objcopy.py @@ -0,0 +1,7 @@ +import pytest + + +class TestObjcopy: + @pytest.mark.complete("objcopy ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_objdump.py b/test/t/test_objdump.py new file mode 100644 index 00000000..6b8bc744 --- /dev/null +++ b/test/t/test_objdump.py @@ -0,0 +1,7 @@ +import pytest + + +class TestObjdump: + @pytest.mark.complete("objdump ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_od.py b/test/t/test_od.py new file mode 100644 index 00000000..a1e648a8 --- /dev/null +++ b/test/t/test_od.py @@ -0,0 +1,7 @@ +import pytest + + +class TestOd: + @pytest.mark.complete("od ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_oggdec.py b/test/t/test_oggdec.py new file mode 100644 index 00000000..8cabe5cd --- /dev/null +++ b/test/t/test_oggdec.py @@ -0,0 +1,11 @@ +import pytest + + +class TestOggdec: + @pytest.mark.complete("oggdec ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("oggdec --") + def test_2(self, completion): + assert completion diff --git a/test/t/test_op.py b/test/t/test_op.py new file mode 100644 index 00000000..e09c98c8 --- /dev/null +++ b/test/t/test_op.py @@ -0,0 +1,11 @@ +import pytest + + +class TestOp: + @pytest.mark.complete("op ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("op --") + def test_2(self, completion): + assert completion diff --git a/test/t/test_openssl.py b/test/t/test_openssl.py new file mode 100644 index 00000000..e3af3530 --- /dev/null +++ b/test/t/test_openssl.py @@ -0,0 +1,15 @@ +import pytest + + +class TestOpenssl: + @pytest.mark.complete("openssl ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("openssl pkey -cipher ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("openssl dgst -s") + def test_3(self, completion): + assert completion diff --git a/test/t/test_opera.py b/test/t/test_opera.py new file mode 100644 index 00000000..5ab056f4 --- /dev/null +++ b/test/t/test_opera.py @@ -0,0 +1,7 @@ +import pytest + + +class TestOpera: + @pytest.mark.complete("opera ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_optipng.py b/test/t/test_optipng.py new file mode 100644 index 00000000..393b0645 --- /dev/null +++ b/test/t/test_optipng.py @@ -0,0 +1,7 @@ +import pytest + + +class TestOptipng: + @pytest.mark.complete("optipng ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_p4.py b/test/t/test_p4.py new file mode 100644 index 00000000..876d261e --- /dev/null +++ b/test/t/test_p4.py @@ -0,0 +1,7 @@ +import pytest + + +class TestP4: + @pytest.mark.complete("p4 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pack200.py b/test/t/test_pack200.py new file mode 100644 index 00000000..0960133a --- /dev/null +++ b/test/t/test_pack200.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPack200: + @pytest.mark.complete("pack200 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_passwd.py b/test/t/test_passwd.py new file mode 100644 index 00000000..60441de9 --- /dev/null +++ b/test/t/test_passwd.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPasswd: + @pytest.mark.complete("passwd ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("passwd -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_paste.py b/test/t/test_paste.py new file mode 100644 index 00000000..2d551322 --- /dev/null +++ b/test/t/test_paste.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPaste: + @pytest.mark.complete("paste ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_patch.py b/test/t/test_patch.py new file mode 100644 index 00000000..455ebd9a --- /dev/null +++ b/test/t/test_patch.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPatch: + @pytest.mark.complete("patch ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pdftotext.py b/test/t/test_pdftotext.py new file mode 100644 index 00000000..9e332f06 --- /dev/null +++ b/test/t/test_pdftotext.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPdftotext: + @pytest.mark.complete("pdftotext ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_perl.py b/test/t/test_perl.py new file mode 100644 index 00000000..7c0c6094 --- /dev/null +++ b/test/t/test_perl.py @@ -0,0 +1,79 @@ +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^\+PERL5LIB=") +class TestPerl: + @pytest.mark.complete("perl ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("perl -e ") + def test_2(self, completion): + assert not completion + + @pytest.mark.complete("perl -V:install") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("perl -V::install") + def test_4(self, completion): + assert completion + + # Assume File::Spec and friends are always installed + + @pytest.mark.complete("perl -MFile") + def test_5(self, completion): + assert completion + + @pytest.mark.complete("perl -MFile::Sp") + def test_6(self, completion): + assert completion + + @pytest.mark.complete("perl -MFile::Spec::Func") + def test_7(self, completion): + assert completion + + @pytest.mark.complete("perl -M-File") + def test_8(self, completion): + assert completion + + @pytest.mark.complete("perl -m-File::") + def test_9(self, completion): + assert completion + + @pytest.mark.complete("perl -") + def test_10(self, completion): + assert completion + + @pytest.mark.complete("perl foo shared/default/f") + def test_11(self, completion): + """Second arg should complete files+dirs.""" + assert completion == "foo foo.d/".split() + + @pytest.mark.complete("perl -Ishared/default/") + def test_12(self, completion): + """-I without space should complete dirs.""" + assert completion == ["bar bar.d/", "foo.d/"] + + @pytest.mark.complete("perl -I shared/default/") + def test_13(self, completion): + """-I with space should complete dirs.""" + assert completion == ["bar bar.d/", "foo.d/"] + + @pytest.mark.complete("perl -xshared/default/b") + def test_14(self, completion): + """-x without space should complete dirs.""" + assert completion == ["-xshared/default/bar bar.d/"] + + @pytest.mark.complete("perl -x shared/default/b") + def test_15(self, completion): + """-x with space should complete dirs.""" + assert completion == ["shared/default/bar bar.d/"] + + @pytest.mark.complete("perl -d:", env=dict(PERL5LIB="$PWD/perl")) + def test_16(self, completion): + assert "BashCompletion" in completion + + @pytest.mark.complete("perl -dt:", env=dict(PERL5LIB="$PWD/perl")) + def test_17(self, completion): + assert "BashCompletion" in completion diff --git a/test/t/test_perlcritic.py b/test/t/test_perlcritic.py new file mode 100644 index 00000000..cc4ef25f --- /dev/null +++ b/test/t/test_perlcritic.py @@ -0,0 +1,15 @@ +import pytest + + +class TestPerlcritic: + @pytest.mark.complete("perlcritic ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("perlcritic --") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("perlcritic --theme ") + def test_3(self, completion): + assert completion diff --git a/test/t/test_perldoc.py b/test/t/test_perldoc.py new file mode 100644 index 00000000..9f772944 --- /dev/null +++ b/test/t/test_perldoc.py @@ -0,0 +1,18 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("export PERL5LIB=$PWD/perldoc",)) +class TestPerldoc: + @pytest.mark.complete("perldoc File::") + def test_1(self, completion): + assert "Path" in completion # Assume File::Path always installed + assert "fixtures/" not in completion # Our fixtures/ dir + assert not [x for x in completion if "File::File::" in x] + + @pytest.mark.complete("perldoc -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("perldoc BashCompletion") + def test_3(self, completion): + assert completion == "BashCompletionDoc BashCompletionModule".split() diff --git a/test/t/test_perltidy.py b/test/t/test_perltidy.py new file mode 100644 index 00000000..3bafd6e4 --- /dev/null +++ b/test/t/test_perltidy.py @@ -0,0 +1,19 @@ +import pytest + + +class TestPerltidy: + @pytest.mark.complete("perltidy ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("perltidy -h") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("perltidy -ole=") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("perltidy -doesntexist=") + def test_4(self, completion): + assert not completion diff --git a/test/t/test_pgrep.py b/test/t/test_pgrep.py new file mode 100644 index 00000000..1155e582 --- /dev/null +++ b/test/t/test_pgrep.py @@ -0,0 +1,9 @@ +import pytest + + +class TestPgrep: + + # "p": Assume that our process name completion runs ps + @pytest.mark.complete("pgrep p") + def test_1(self, completion): + assert completion diff --git a/test/t/test_phing.py b/test/t/test_phing.py new file mode 100644 index 00000000..2e8c1069 --- /dev/null +++ b/test/t/test_phing.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPhing: + @pytest.mark.complete("phing -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("phing -l ") + def test_2(self, completion): + assert not completion diff --git a/test/t/test_pidof.py b/test/t/test_pidof.py new file mode 100644 index 00000000..fb553e55 --- /dev/null +++ b/test/t/test_pidof.py @@ -0,0 +1,9 @@ +import pytest + + +class TestPidof: + + # "p": Assume that our process name completion runs ps + @pytest.mark.complete("pidof p") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pine.py b/test/t/test_pine.py new file mode 100644 index 00000000..2c5549e0 --- /dev/null +++ b/test/t/test_pine.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPine: + @pytest.mark.complete("pine -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pinfo.py b/test/t/test_pinfo.py new file mode 100644 index 00000000..b502273f --- /dev/null +++ b/test/t/test_pinfo.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("INFOPATH+=:$PWD/info:",)) +class TestPinfo: + @pytest.mark.complete("pinfo -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pinfo bash") + def test_2(self, completion): + assert completion diff --git a/test/t/test_ping.py b/test/t/test_ping.py new file mode 100644 index 00000000..e7c77365 --- /dev/null +++ b/test/t/test_ping.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPing: + @pytest.mark.complete("ping ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ping -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_pkg_config.py b/test/t/test_pkg_config.py new file mode 100644 index 00000000..a0703e09 --- /dev/null +++ b/test/t/test_pkg_config.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="pkg-config") +class TestPkgConfig: + @pytest.mark.complete("pkg-config ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pkg-config -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_pkg_deinstall.py b/test/t/test_pkg_deinstall.py new file mode 100644 index 00000000..5ce6d13e --- /dev/null +++ b/test/t/test_pkg_deinstall.py @@ -0,0 +1,15 @@ +import os + +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PKG_DBDIR=$PWD/pkgtools/db",)) +class TestPkgDeinstall: + @pytest.mark.complete("pkg_deinstall ") + def test_1(self, completion): + dirs = sorted( + x + for x in os.listdir("pkgtools/db") + if os.path.isdir("pkgtools/db/%s" % x) + ) + assert completion == dirs diff --git a/test/t/test_pkg_delete.py b/test/t/test_pkg_delete.py new file mode 100644 index 00000000..a4b0d855 --- /dev/null +++ b/test/t/test_pkg_delete.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPkgDelete: + @pytest.mark.complete("pkg_delete ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pkg_get.py b/test/t/test_pkg_get.py new file mode 100644 index 00000000..cb2d2834 --- /dev/null +++ b/test/t/test_pkg_get.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="pkg-get") +class TestPkgGet: + @pytest.mark.complete("pkg-get ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pkg_info.py b/test/t/test_pkg_info.py new file mode 100644 index 00000000..6011f814 --- /dev/null +++ b/test/t/test_pkg_info.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPkgInfo: + @pytest.mark.complete("pkg_info ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pkgadd.py b/test/t/test_pkgadd.py new file mode 100644 index 00000000..ca6baf27 --- /dev/null +++ b/test/t/test_pkgadd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPkgadd: + @pytest.mark.complete("pkgadd ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pkgrm.py b/test/t/test_pkgrm.py new file mode 100644 index 00000000..9cb73571 --- /dev/null +++ b/test/t/test_pkgrm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPkgrm: + @pytest.mark.complete("pkgrm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pkgtool.py b/test/t/test_pkgtool.py new file mode 100644 index 00000000..7d356377 --- /dev/null +++ b/test/t/test_pkgtool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPkgtool: + @pytest.mark.complete("pkgtool -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pkgutil.py b/test/t/test_pkgutil.py new file mode 100644 index 00000000..96647285 --- /dev/null +++ b/test/t/test_pkgutil.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPkgutil: + @pytest.mark.complete("pkgutil ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pkill.py b/test/t/test_pkill.py new file mode 100644 index 00000000..b0af6c3d --- /dev/null +++ b/test/t/test_pkill.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPkill: + @pytest.mark.complete("pkill ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_plague_client.py b/test/t/test_plague_client.py new file mode 100644 index 00000000..39eac93d --- /dev/null +++ b/test/t/test_plague_client.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="plague-client") +class TestPlagueClient: + @pytest.mark.complete("plague-client ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pm_hibernate.py b/test/t/test_pm_hibernate.py new file mode 100644 index 00000000..31b4625e --- /dev/null +++ b/test/t/test_pm_hibernate.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="pm-hibernate") +class TestPmHibernate: + @pytest.mark.complete("pm-hibernate -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pm_is_supported.py b/test/t/test_pm_is_supported.py new file mode 100644 index 00000000..47f064a4 --- /dev/null +++ b/test/t/test_pm_is_supported.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="pm-is-supported") +class TestPmIsSupported: + @pytest.mark.complete("pm-is-supported -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pm_powersave.py b/test/t/test_pm_powersave.py new file mode 100644 index 00000000..7630a412 --- /dev/null +++ b/test/t/test_pm_powersave.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="pm-powersave") +class TestPmPowersave: + @pytest.mark.complete("pm-powersave ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pngfix.py b/test/t/test_pngfix.py new file mode 100644 index 00000000..e27f3293 --- /dev/null +++ b/test/t/test_pngfix.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPngfix: + @pytest.mark.complete("pngfix ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pngfix -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_portinstall.py b/test/t/test_portinstall.py new file mode 100644 index 00000000..62fddbfb --- /dev/null +++ b/test/t/test_portinstall.py @@ -0,0 +1,26 @@ +import pytest + +from conftest import assert_bash_exec + + +class TestPortinstall: + @pytest.fixture(scope="class") + def portsdir(self, request, bash): + assert_bash_exec(bash, "PORTSDIR=$TESTDIR/tmp") + assert_bash_exec( + bash, + "command sed -e s,PORTSDIR,$PORTSDIR,g " + "pkgtools/ports/INDEX.dist >$PORTSDIR/INDEX", + ) + assert_bash_exec(bash, "cp $PORTSDIR/INDEX $PORTSDIR/INDEX-5") + request.addfinalizer( + lambda: assert_bash_exec(bash, "rm $PORTSDIR/INDEX{,-5}") + ) + + @pytest.mark.complete("portinstall ", env=dict(PORTSDIR="$TESTDIR/tmp")) + def test_1(self, completion, portsdir): + assert ( + completion + == "bash-2.05b.007_6 bash-3.1.17 bash-completion-20060301_2 " + "shells/bash shells/bash-completion shells/bash2".split() + ) diff --git a/test/t/test_portsnap.py b/test/t/test_portsnap.py new file mode 100644 index 00000000..4f5878e9 --- /dev/null +++ b/test/t/test_portsnap.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPortsnap: + @pytest.mark.complete("portsnap ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_portupgrade.py b/test/t/test_portupgrade.py new file mode 100644 index 00000000..aaff5c10 --- /dev/null +++ b/test/t/test_portupgrade.py @@ -0,0 +1,9 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PKG_DBDIR=$PWD/dbtools/db",)) +class TestPortupgrade: + @pytest.mark.complete("portupgrade ") + def test_1(self, completion): + assert completion == "a b-c-d".split() + assert completion.endswith(" ") diff --git a/test/t/test_postcat.py b/test/t/test_postcat.py new file mode 100644 index 00000000..653cca25 --- /dev/null +++ b/test/t/test_postcat.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPostcat: + @pytest.mark.complete("postcat ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_postconf.py b/test/t/test_postconf.py new file mode 100644 index 00000000..641b2734 --- /dev/null +++ b/test/t/test_postconf.py @@ -0,0 +1,18 @@ +import pytest + + +class TestPostconf: + @pytest.mark.complete("postconf -") + def test_1(self, completion): + assert len(completion) > 1 + + # Broken configs may abort output of postconf halfway through, so use + # something from early output to not trigger false positives because of + # this. For example, inet_protocols=all but no IPv6 configured: + # postconf: fatal: parameter inet_interfaces: no local interface found + # for ::1 + # ...and output can be cut off somewhere near lmtp_tls_secur*. + # ...or be completely missing, so all we can do is to skip. + @pytest.mark.complete("postconf al", skipif="! postconf &>/dev/null") + def test_2(self, completion): + assert completion diff --git a/test/t/test_postfix.py b/test/t/test_postfix.py new file mode 100644 index 00000000..f7af7b4c --- /dev/null +++ b/test/t/test_postfix.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPostfix: + @pytest.mark.complete("postfix ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_postmap.py b/test/t/test_postmap.py new file mode 100644 index 00000000..f3430fbd --- /dev/null +++ b/test/t/test_postmap.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPostmap: + @pytest.mark.complete("postmap ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_postsuper.py b/test/t/test_postsuper.py new file mode 100644 index 00000000..b74de8ec --- /dev/null +++ b/test/t/test_postsuper.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPostsuper: + @pytest.mark.complete("postsuper ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_povray.py b/test/t/test_povray.py new file mode 100644 index 00000000..99d08ea0 --- /dev/null +++ b/test/t/test_povray.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPovray: + @pytest.mark.complete("povray ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pr.py b/test/t/test_pr.py new file mode 100644 index 00000000..cb023ea0 --- /dev/null +++ b/test/t/test_pr.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPr: + @pytest.mark.complete("pr ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_prelink.py b/test/t/test_prelink.py new file mode 100644 index 00000000..ef8baece --- /dev/null +++ b/test/t/test_prelink.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPrelink: + @pytest.mark.complete("prelink ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("prelink -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_protoc.py b/test/t/test_protoc.py new file mode 100644 index 00000000..65549d35 --- /dev/null +++ b/test/t/test_protoc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestProtoc: + @pytest.mark.complete("protoc ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_psql.py b/test/t/test_psql.py new file mode 100644 index 00000000..60ed097c --- /dev/null +++ b/test/t/test_psql.py @@ -0,0 +1,9 @@ +import pytest + + +class TestPsql: + + # --help can fail due to missing package dependencies, e.g. on Ubuntu 14 + @pytest.mark.complete("psql -", skipif="! psql --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ptx.py b/test/t/test_ptx.py new file mode 100644 index 00000000..2eea63bc --- /dev/null +++ b/test/t/test_ptx.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPtx: + @pytest.mark.complete("ptx ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_puppet.py b/test/t/test_puppet.py new file mode 100644 index 00000000..470f33a2 --- /dev/null +++ b/test/t/test_puppet.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPuppet: + @pytest.mark.complete("puppet ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("puppet agent --") + def test_2(self, completion): + assert completion diff --git a/test/t/test_pushd.py b/test/t/test_pushd.py new file mode 100644 index 00000000..290e1d1d --- /dev/null +++ b/test/t/test_pushd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPushd: + @pytest.mark.complete("pushd ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pv.py b/test/t/test_pv.py new file mode 100644 index 00000000..ffca68df --- /dev/null +++ b/test/t/test_pv.py @@ -0,0 +1,15 @@ +import pytest + + +class TestPv: + @pytest.mark.complete("pv ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pv -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("pv --pidfile ") + def test_3(self, completion): + assert completion diff --git a/test/t/test_pvchange.py b/test/t/test_pvchange.py new file mode 100644 index 00000000..78e534ac --- /dev/null +++ b/test/t/test_pvchange.py @@ -0,0 +1,9 @@ +import pytest + + +class TestPvchange: + @pytest.mark.complete( + "pvchange --", skipif="! pvchange --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_pvcreate.py b/test/t/test_pvcreate.py new file mode 100644 index 00000000..372b9e39 --- /dev/null +++ b/test/t/test_pvcreate.py @@ -0,0 +1,9 @@ +import pytest + + +class TestPvcreate: + @pytest.mark.complete( + "pvcreate --", skipif="! pvcreate --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_pvdisplay.py b/test/t/test_pvdisplay.py new file mode 100644 index 00000000..e5fa07f6 --- /dev/null +++ b/test/t/test_pvdisplay.py @@ -0,0 +1,9 @@ +import pytest + + +class TestPvdisplay: + @pytest.mark.complete( + "pvdisplay --", skipif="! pvdisplay --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_pvmove.py b/test/t/test_pvmove.py new file mode 100644 index 00000000..e1b06dd6 --- /dev/null +++ b/test/t/test_pvmove.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPvmove: + @pytest.mark.complete("pvmove --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pvremove.py b/test/t/test_pvremove.py new file mode 100644 index 00000000..08bf63b0 --- /dev/null +++ b/test/t/test_pvremove.py @@ -0,0 +1,9 @@ +import pytest + + +class TestPvremove: + @pytest.mark.complete( + "pvremove --", skipif="! pvremove --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_pvs.py b/test/t/test_pvs.py new file mode 100644 index 00000000..6063888e --- /dev/null +++ b/test/t/test_pvs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPvs: + @pytest.mark.complete("pvs --", skipif="! pvs --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pvscan.py b/test/t/test_pvscan.py new file mode 100644 index 00000000..1ae237fc --- /dev/null +++ b/test/t/test_pvscan.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPvscan: + @pytest.mark.complete("pvscan --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pwck.py b/test/t/test_pwck.py new file mode 100644 index 00000000..143c76f1 --- /dev/null +++ b/test/t/test_pwck.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPwck: + @pytest.mark.complete("pwck ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pwd.py b/test/t/test_pwd.py new file mode 100644 index 00000000..b1ec3378 --- /dev/null +++ b/test/t/test_pwd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPwd: + @pytest.mark.complete("pwd -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pwdx.py b/test/t/test_pwdx.py new file mode 100644 index 00000000..411d7a59 --- /dev/null +++ b/test/t/test_pwdx.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPwdx: + @pytest.mark.complete("pwdx ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pwgen.py b/test/t/test_pwgen.py new file mode 100644 index 00000000..54c194cf --- /dev/null +++ b/test/t/test_pwgen.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPwgen: + @pytest.mark.complete("pwgen -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pycodestyle.py b/test/t/test_pycodestyle.py new file mode 100644 index 00000000..03c58eec --- /dev/null +++ b/test/t/test_pycodestyle.py @@ -0,0 +1,15 @@ +import pytest + + +class TestPycodestyle: + @pytest.mark.complete("pycodestyle ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pycodestyle -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("pycodestyle --doesnt-exist=") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_pydoc.py b/test/t/test_pydoc.py new file mode 100644 index 00000000..e6173676 --- /dev/null +++ b/test/t/test_pydoc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPydoc: + @pytest.mark.complete("pydoc r") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pydocstyle.py b/test/t/test_pydocstyle.py new file mode 100644 index 00000000..4deb45fe --- /dev/null +++ b/test/t/test_pydocstyle.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPydocstyle: + @pytest.mark.complete("pydocstyle ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pydocstyle -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_pyflakes.py b/test/t/test_pyflakes.py new file mode 100644 index 00000000..ae3853a7 --- /dev/null +++ b/test/t/test_pyflakes.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPyflakes: + @pytest.mark.complete("pyflakes ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_pylint.py b/test/t/test_pylint.py new file mode 100644 index 00000000..e08507aa --- /dev/null +++ b/test/t/test_pylint.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPylint: + @pytest.mark.complete("pylint --v") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pylint --confidence=HIGH,") + def test_2(self, completion): + assert completion diff --git a/test/t/test_pylint_3.py b/test/t/test_pylint_3.py new file mode 100644 index 00000000..305db7d3 --- /dev/null +++ b/test/t/test_pylint_3.py @@ -0,0 +1,12 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="pylint-3") +class TestPylint3: + @pytest.mark.complete("pylint-3 --v") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pylint-3 http.clien") + def test_2(self, completion): + assert completion diff --git a/test/t/test_pytest.py b/test/t/test_pytest.py new file mode 100644 index 00000000..69d01820 --- /dev/null +++ b/test/t/test_pytest.py @@ -0,0 +1,11 @@ +import pytest + + +class TestPytest: + @pytest.mark.complete("pytest ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("pytest -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_python.py b/test/t/test_python.py new file mode 100644 index 00000000..4990f957 --- /dev/null +++ b/test/t/test_python.py @@ -0,0 +1,35 @@ +import pytest + + +class TestPython: + @pytest.mark.complete("python ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("python -") + def test_2(self, completion): + assert len(completion) > 1 + + @pytest.mark.complete("python -c ") + def test_3(self, completion): + assert not completion + + @pytest.mark.complete("python shared/default/") + def test_4(self, completion): + assert completion == ["bar bar.d/", "foo.d/"] + + @pytest.mark.complete("python -c foo shared/default/") + def test_5(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] + + @pytest.mark.complete("python -c foo -") + def test_6(self, completion): + assert not completion + + @pytest.mark.complete("python -m foo -") + def test_7(self, completion): + assert not completion + + @pytest.mark.complete("python -m sy") + def test_8(self, completion): + assert completion diff --git a/test/t/test_python3.py b/test/t/test_python3.py new file mode 100644 index 00000000..3f2b5f9e --- /dev/null +++ b/test/t/test_python3.py @@ -0,0 +1,35 @@ +import pytest + + +class TestPython3: + @pytest.mark.complete("python3 ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("python3 -") + def test_2(self, completion): + assert len(completion) > 1 + + @pytest.mark.complete("python3 -c ") + def test_3(self, completion): + assert not completion + + @pytest.mark.complete("python3 shared/default/") + def test_4(self, completion): + assert completion == ["bar bar.d/", "foo.d/"] + + @pytest.mark.complete("python3 -c foo shared/default/") + def test_5(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] + + @pytest.mark.complete("python3 -c foo -") + def test_6(self, completion): + assert not completion + + @pytest.mark.complete("python3 -m foo -") + def test_7(self, completion): + assert not completion + + @pytest.mark.complete("python3 -m sy") + def test_8(self, completion): + assert completion diff --git a/test/t/test_pyvenv.py b/test/t/test_pyvenv.py new file mode 100644 index 00000000..5e9152a5 --- /dev/null +++ b/test/t/test_pyvenv.py @@ -0,0 +1,7 @@ +import pytest + + +class TestPyvenv: + @pytest.mark.complete("pyvenv ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_qemu.py b/test/t/test_qemu.py new file mode 100644 index 00000000..3be6f64b --- /dev/null +++ b/test/t/test_qemu.py @@ -0,0 +1,7 @@ +import pytest + + +class TestQemu: + @pytest.mark.complete("qemu ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_qrunner.py b/test/t/test_qrunner.py new file mode 100644 index 00000000..4e4cdd8d --- /dev/null +++ b/test/t/test_qrunner.py @@ -0,0 +1,7 @@ +import pytest + + +class TestQrunner: + @pytest.mark.complete("qrunner -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_querybts.py b/test/t/test_querybts.py new file mode 100644 index 00000000..dd3af4f9 --- /dev/null +++ b/test/t/test_querybts.py @@ -0,0 +1,7 @@ +import pytest + + +class TestQuerybts: + @pytest.mark.complete("querybts --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_quota.py b/test/t/test_quota.py new file mode 100644 index 00000000..75098875 --- /dev/null +++ b/test/t/test_quota.py @@ -0,0 +1,7 @@ +import pytest + + +class TestQuota: + @pytest.mark.complete("quota ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_quotacheck.py b/test/t/test_quotacheck.py new file mode 100644 index 00000000..0311befb --- /dev/null +++ b/test/t/test_quotacheck.py @@ -0,0 +1,7 @@ +import pytest + + +class TestQuotacheck: + @pytest.mark.complete("quotacheck -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_quotaon.py b/test/t/test_quotaon.py new file mode 100644 index 00000000..46bf5546 --- /dev/null +++ b/test/t/test_quotaon.py @@ -0,0 +1,7 @@ +import pytest + + +class TestQuotaon: + @pytest.mark.complete("quotaon -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_radvdump.py b/test/t/test_radvdump.py new file mode 100644 index 00000000..e3d9242d --- /dev/null +++ b/test/t/test_radvdump.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRadvdump: + @pytest.mark.complete("radvdump ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rcs.py b/test/t/test_rcs.py new file mode 100644 index 00000000..985bb44f --- /dev/null +++ b/test/t/test_rcs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRcs: + @pytest.mark.complete("rcs ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rcsdiff.py b/test/t/test_rcsdiff.py new file mode 100644 index 00000000..d54934c7 --- /dev/null +++ b/test/t/test_rcsdiff.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRcsdiff: + @pytest.mark.complete("rcsdiff ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rdesktop.py b/test/t/test_rdesktop.py new file mode 100644 index 00000000..b82b471e --- /dev/null +++ b/test/t/test_rdesktop.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRdesktop: + @pytest.mark.complete("rdesktop -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rdict.py b/test/t/test_rdict.py new file mode 100644 index 00000000..86d7c087 --- /dev/null +++ b/test/t/test_rdict.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRdict: + @pytest.mark.complete("rdict --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_readelf.py b/test/t/test_readelf.py new file mode 100644 index 00000000..5c5dff37 --- /dev/null +++ b/test/t/test_readelf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestReadelf: + @pytest.mark.complete("readelf --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_readonly.py b/test/t/test_readonly.py new file mode 100644 index 00000000..0ac310c2 --- /dev/null +++ b/test/t/test_readonly.py @@ -0,0 +1,7 @@ +import pytest + + +class TestReadonly: + @pytest.mark.complete("readonly BASH_ARG") + def test_1(self, completion): + assert completion diff --git a/test/t/test_remove_members.py b/test/t/test_remove_members.py new file mode 100644 index 00000000..a3b0afd6 --- /dev/null +++ b/test/t/test_remove_members.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRemoveMembers: + @pytest.mark.complete("remove_members --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_removepkg.py b/test/t/test_removepkg.py new file mode 100644 index 00000000..9fd7a9d8 --- /dev/null +++ b/test/t/test_removepkg.py @@ -0,0 +1,15 @@ +import os + +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^\+ROOT=") +class TestRemovepkg: + @pytest.mark.complete("removepkg -") + def test_1(self, completion): + assert completion == "-copy -keep -preserve -warn".split() + + @pytest.mark.complete("removepkg ", env=dict(ROOT="./slackware")) + def test_2(self, completion): + files = sorted(x for x in os.listdir("slackware/var/log/packages")) + assert completion == files diff --git a/test/t/test_renice.py b/test/t/test_renice.py new file mode 100644 index 00000000..20d59a33 --- /dev/null +++ b/test/t/test_renice.py @@ -0,0 +1,11 @@ +import pytest + + +class TestRenice: + @pytest.mark.complete("renice 1") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("renice -g ") + def test_2(self, completion): + assert completion diff --git a/test/t/test_repomanage.py b/test/t/test_repomanage.py new file mode 100644 index 00000000..6def4a8c --- /dev/null +++ b/test/t/test_repomanage.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRepomanage: + @pytest.mark.complete("repomanage ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_reportbug.py b/test/t/test_reportbug.py new file mode 100644 index 00000000..612a96b8 --- /dev/null +++ b/test/t/test_reportbug.py @@ -0,0 +1,7 @@ +import pytest + + +class TestReportbug: + @pytest.mark.complete("reportbug --m") + def test_1(self, completion): + assert completion diff --git a/test/t/test_reptyr.py b/test/t/test_reptyr.py new file mode 100644 index 00000000..62a9b1c5 --- /dev/null +++ b/test/t/test_reptyr.py @@ -0,0 +1,11 @@ +import pytest + + +class TestReptyr: + @pytest.mark.complete("reptyr ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("reptyr -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_resolvconf.py b/test/t/test_resolvconf.py new file mode 100644 index 00000000..fdcf584f --- /dev/null +++ b/test/t/test_resolvconf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestResolvconf: + @pytest.mark.complete("resolvconf -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rfcomm.py b/test/t/test_rfcomm.py new file mode 100644 index 00000000..c30d23b1 --- /dev/null +++ b/test/t/test_rfcomm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRfcomm: + @pytest.mark.complete("rfcomm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rfkill.py b/test/t/test_rfkill.py new file mode 100644 index 00000000..f8248ff9 --- /dev/null +++ b/test/t/test_rfkill.py @@ -0,0 +1,11 @@ +import pytest + + +class TestRfkill: + @pytest.mark.complete("rfkill ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("rfkill -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_ri.py b/test/t/test_ri.py new file mode 100644 index 00000000..e54f18bb --- /dev/null +++ b/test/t/test_ri.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("export RI='-d ri'",)) +class TestRi: + @pytest.mark.complete("ri -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ri --dump=ri/") + def test_2(self, completion): + assert completion == "BashCompletion/ cache.ri".split() + + @pytest.mark.complete("ri BashCompletio") + def test_3(self, completion): + assert completion == "BashCompletion" diff --git a/test/t/test_rlog.py b/test/t/test_rlog.py new file mode 100644 index 00000000..87a4da10 --- /dev/null +++ b/test/t/test_rlog.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRlog: + @pytest.mark.complete("rlog ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rm.py b/test/t/test_rm.py new file mode 100644 index 00000000..622ef13c --- /dev/null +++ b/test/t/test_rm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRm: + @pytest.mark.complete("rm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rmdir.py b/test/t/test_rmdir.py new file mode 100644 index 00000000..d416819a --- /dev/null +++ b/test/t/test_rmdir.py @@ -0,0 +1,12 @@ +import pytest + + +class TestRmdir: + @pytest.mark.complete("rmdir ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("/bin/rmdir shared/default/") + def test_2(self, completion): + """Should complete dirs only, also when invoked using full path.""" + assert completion == ["bar bar.d/", "foo.d/"] diff --git a/test/t/test_rmlist.py b/test/t/test_rmlist.py new file mode 100644 index 00000000..3a6c6ece --- /dev/null +++ b/test/t/test_rmlist.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRmlist: + @pytest.mark.complete("rmlist -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rmmod.py b/test/t/test_rmmod.py new file mode 100644 index 00000000..dfeb0090 --- /dev/null +++ b/test/t/test_rmmod.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRmmod: + @pytest.mark.complete("rmmod -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_route.py b/test/t/test_route.py new file mode 100644 index 00000000..741ef585 --- /dev/null +++ b/test/t/test_route.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRoute: + @pytest.mark.complete("route ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rpcdebug.py b/test/t/test_rpcdebug.py new file mode 100644 index 00000000..e92bdee1 --- /dev/null +++ b/test/t/test_rpcdebug.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRpcdebug: + @pytest.mark.complete("rpcdebug -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rpm.py b/test/t/test_rpm.py new file mode 100644 index 00000000..939090dd --- /dev/null +++ b/test/t/test_rpm.py @@ -0,0 +1,11 @@ +import pytest + + +class TestRpm: + @pytest.mark.complete("rpm ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("rpm -q ", skipif='test -z "$(rpm -qa 2>/dev/null)"') + def test_2(self, completion): + assert completion diff --git a/test/t/test_rpm2tgz.py b/test/t/test_rpm2tgz.py new file mode 100644 index 00000000..366faedc --- /dev/null +++ b/test/t/test_rpm2tgz.py @@ -0,0 +1,26 @@ +import os + +import pytest + + +class TestRpm2tgz: + @pytest.mark.complete("rpm2tgz -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("rpm2tgz ", cwd="slackware/home") + def test_2(self, completion): + expected = sorted( + [ + "%s/" + for x in os.listdir("slackware/home") + if os.path.isdir("shared/bin/%s" % x) + ] + + [ + x + for x in os.listdir("slackware/home") + if os.path.isfile("slackware/home/%s" % x) + and x.endswith(".rpm") + ] + ) + assert completion == expected diff --git a/test/t/test_rpmbuild.py b/test/t/test_rpmbuild.py new file mode 100644 index 00000000..13f164ba --- /dev/null +++ b/test/t/test_rpmbuild.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRpmbuild: + @pytest.mark.complete("rpmbuild -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rrdtool.py b/test/t/test_rrdtool.py new file mode 100644 index 00000000..9da83100 --- /dev/null +++ b/test/t/test_rrdtool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRrdtool: + @pytest.mark.complete("rrdtool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_rsync.py b/test/t/test_rsync.py new file mode 100644 index 00000000..d54ce6fc --- /dev/null +++ b/test/t/test_rsync.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^[+-]_scp_path_esc=") +class TestRsync: + @pytest.mark.complete("rsync ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("rsync --rsh ") + def test_2(self, completion): + assert completion == "rsh ssh".split() + + @pytest.mark.complete("rsync --rsh=") + def test_3(self, completion): + assert completion == "rsh ssh".split() diff --git a/test/t/test_rtcwake.py b/test/t/test_rtcwake.py new file mode 100644 index 00000000..e9c12d07 --- /dev/null +++ b/test/t/test_rtcwake.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRtcwake: + @pytest.mark.complete("rtcwake ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_runuser.py b/test/t/test_runuser.py new file mode 100644 index 00000000..01a6d884 --- /dev/null +++ b/test/t/test_runuser.py @@ -0,0 +1,7 @@ +import pytest + + +class TestRunuser: + @pytest.mark.complete("runuser ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sbcl.py b/test/t/test_sbcl.py new file mode 100644 index 00000000..cce4cba3 --- /dev/null +++ b/test/t/test_sbcl.py @@ -0,0 +1,8 @@ +import pytest + + +class TestSbcl: + @pytest.mark.xfail # TODO: whitespace split issue + @pytest.mark.complete("sbcl shared/default/") + def test_1(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo foo.d/"] diff --git a/test/t/test_sbcl_mt.py b/test/t/test_sbcl_mt.py new file mode 100644 index 00000000..860acc2f --- /dev/null +++ b/test/t/test_sbcl_mt.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="sbcl-mt") +class TestSbclMt: + @pytest.mark.complete("sbcl-mt shared/default/") + def test_1(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo foo.d/"] diff --git a/test/t/test_sbopkg.py b/test/t/test_sbopkg.py new file mode 100644 index 00000000..cb1f7360 --- /dev/null +++ b/test/t/test_sbopkg.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSbopkg: + @pytest.mark.complete("sbopkg -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_screen.py b/test/t/test_screen.py new file mode 100644 index 00000000..c05e0ce0 --- /dev/null +++ b/test/t/test_screen.py @@ -0,0 +1,24 @@ +import pytest + + +class TestScreen: + @pytest.mark.complete("screen -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("screen -c shared/default/") + def test_2(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] + + @pytest.mark.complete("screen cat ") + def test_3(self, completion): + assert completion + + # Assume at least vt100 and friends are there + @pytest.mark.complete("screen -T vt") + def test_4(self, completion): + assert completion + + @pytest.mark.complete("screen -T foo cat") + def test_5(self, completion): + assert completion diff --git a/test/t/test_scrub.py b/test/t/test_scrub.py new file mode 100644 index 00000000..0a521faf --- /dev/null +++ b/test/t/test_scrub.py @@ -0,0 +1,19 @@ +import pytest + + +class TestScrub: + @pytest.mark.complete("scrub ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("scrub -") + def test_2(self, completion): + assert completion + + # Not all scrub versions list available patterns in --help output + @pytest.mark.complete( + "scrub -p ", + skipif="! (scrub --help 2>&1 || :) | " "command grep -q ^Available", + ) + def test_3(self, completion): + assert completion diff --git a/test/t/test_sdptool.py b/test/t/test_sdptool.py new file mode 100644 index 00000000..095d90e6 --- /dev/null +++ b/test/t/test_sdptool.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSdptool: + @pytest.mark.complete("sdptool ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sed.py b/test/t/test_sed.py new file mode 100644 index 00000000..3fc0559f --- /dev/null +++ b/test/t/test_sed.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSed: + @pytest.mark.complete("sed --", skipif="! sed --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_seq.py b/test/t/test_seq.py new file mode 100644 index 00000000..96580450 --- /dev/null +++ b/test/t/test_seq.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSeq: + @pytest.mark.complete("seq --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_service.py b/test/t/test_service.py new file mode 100644 index 00000000..7ce43125 --- /dev/null +++ b/test/t/test_service.py @@ -0,0 +1,7 @@ +import pytest + + +class TestService: + @pytest.mark.complete("service ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_set.py b/test/t/test_set.py new file mode 100644 index 00000000..08c1671e --- /dev/null +++ b/test/t/test_set.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSet: + @pytest.mark.complete("set no") + def test_1(self, completion): + assert completion diff --git a/test/t/test_setquota.py b/test/t/test_setquota.py new file mode 100644 index 00000000..a2822bca --- /dev/null +++ b/test/t/test_setquota.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSetquota: + @pytest.mark.complete("setquota ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sftp.py b/test/t/test_sftp.py new file mode 100644 index 00000000..e76a6f59 --- /dev/null +++ b/test/t/test_sftp.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSftp: + @pytest.mark.complete("sftp -Fsp", cwd="sftp") + def test_1(self, completion): + assert completion == "-Fspaced conf" diff --git a/test/t/test_sh.py b/test/t/test_sh.py new file mode 100644 index 00000000..f49a1685 --- /dev/null +++ b/test/t/test_sh.py @@ -0,0 +1,19 @@ +import pytest + + +class TestSh: + @pytest.mark.complete("sh -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("sh +") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("sh -o ") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("sh -c ") + def test_4(self, completion): + assert not completion diff --git a/test/t/test_sha1sum.py b/test/t/test_sha1sum.py new file mode 100644 index 00000000..efe8dfec --- /dev/null +++ b/test/t/test_sha1sum.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSha1sum: + @pytest.mark.complete("sha1sum --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_shar.py b/test/t/test_shar.py new file mode 100644 index 00000000..f73c4b87 --- /dev/null +++ b/test/t/test_shar.py @@ -0,0 +1,7 @@ +import pytest + + +class TestShar: + @pytest.mark.complete("shar --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_shellcheck.py b/test/t/test_shellcheck.py new file mode 100644 index 00000000..54bc4636 --- /dev/null +++ b/test/t/test_shellcheck.py @@ -0,0 +1,19 @@ +import pytest + + +class TestShellcheck: + @pytest.mark.complete("shellcheck ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("shellcheck -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("shellcheck --format=") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("shellcheck -s ") + def test_4(self, completion): + assert "bash" in completion diff --git a/test/t/test_sitecopy.py b/test/t/test_sitecopy.py new file mode 100644 index 00000000..de66a5dc --- /dev/null +++ b/test/t/test_sitecopy.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSitecopy: + @pytest.mark.complete("sitecopy --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_slackpkg.py b/test/t/test_slackpkg.py new file mode 100644 index 00000000..3997bb02 --- /dev/null +++ b/test/t/test_slackpkg.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSlackpkg: + @pytest.mark.complete("slackpkg -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_slapt_get.py b/test/t/test_slapt_get.py new file mode 100644 index 00000000..1254d5b4 --- /dev/null +++ b/test/t/test_slapt_get.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="slapt-get") +class TestSlaptGet: + @pytest.mark.complete("slapt-get -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("slapt-get --up") + def test_2(self, completion): + assert completion == "--update --upgrade".split() + + @pytest.mark.complete("slapt-get -c non-existent-file --install ") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_slapt_src.py b/test/t/test_slapt_src.py new file mode 100644 index 00000000..df5f4da0 --- /dev/null +++ b/test/t/test_slapt_src.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="slapt-src") +class TestSlaptSrc: + @pytest.mark.complete("slapt-src -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("slapt-src --bu") + def test_2(self, completion): + assert completion == "--build" + + @pytest.mark.complete("slapt-src --ins") + def test_3(self, completion): + assert completion == "--install" diff --git a/test/t/test_smartctl.py b/test/t/test_smartctl.py new file mode 100644 index 00000000..ac6dc68d --- /dev/null +++ b/test/t/test_smartctl.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmartctl: + @pytest.mark.complete("smartctl --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_smbcacls.py b/test/t/test_smbcacls.py new file mode 100644 index 00000000..1ff16e2b --- /dev/null +++ b/test/t/test_smbcacls.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmbcacls: + @pytest.mark.complete("smbcacls -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_smbclient.py b/test/t/test_smbclient.py new file mode 100644 index 00000000..ed2da4b0 --- /dev/null +++ b/test/t/test_smbclient.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmbclient: + @pytest.mark.complete("smbclient -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_smbcquotas.py b/test/t/test_smbcquotas.py new file mode 100644 index 00000000..b7e01d29 --- /dev/null +++ b/test/t/test_smbcquotas.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmbcquotas: + @pytest.mark.complete("smbcquotas -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_smbget.py b/test/t/test_smbget.py new file mode 100644 index 00000000..a360bd3c --- /dev/null +++ b/test/t/test_smbget.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmbget: + @pytest.mark.complete("smbget -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_smbpasswd.py b/test/t/test_smbpasswd.py new file mode 100644 index 00000000..4d0e76ba --- /dev/null +++ b/test/t/test_smbpasswd.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmbpasswd: + @pytest.mark.complete("smbpasswd -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_smbtar.py b/test/t/test_smbtar.py new file mode 100644 index 00000000..44b424bc --- /dev/null +++ b/test/t/test_smbtar.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmbtar: + @pytest.mark.complete("smbtar -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_smbtree.py b/test/t/test_smbtree.py new file mode 100644 index 00000000..0eba4b54 --- /dev/null +++ b/test/t/test_smbtree.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSmbtree: + @pytest.mark.complete("smbtree -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_snownews.py b/test/t/test_snownews.py new file mode 100644 index 00000000..24ed2dfe --- /dev/null +++ b/test/t/test_snownews.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSnownews: + @pytest.mark.complete("snownews --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sort.py b/test/t/test_sort.py new file mode 100644 index 00000000..7dbb5b9d --- /dev/null +++ b/test/t/test_sort.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSort: + @pytest.mark.complete("sort --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_split.py b/test/t/test_split.py new file mode 100644 index 00000000..79013663 --- /dev/null +++ b/test/t/test_split.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSplit: + @pytest.mark.complete("split --", skipif="! split --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_spovray.py b/test/t/test_spovray.py new file mode 100644 index 00000000..9033f835 --- /dev/null +++ b/test/t/test_spovray.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSpovray: + @pytest.mark.complete("spovray ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sqlite3.py b/test/t/test_sqlite3.py new file mode 100644 index 00000000..466281a9 --- /dev/null +++ b/test/t/test_sqlite3.py @@ -0,0 +1,15 @@ +import pytest + + +class TestSqlite3: + @pytest.mark.complete("sqlite3 ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("sqlite3 -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("sqlite3 -scratch foo ") + def test_3(self, completion): + assert not completion diff --git a/test/t/test_ss.py b/test/t/test_ss.py new file mode 100644 index 00000000..3e515dde --- /dev/null +++ b/test/t/test_ss.py @@ -0,0 +1,15 @@ +import pytest + + +class TestSs: + @pytest.mark.complete("ss -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ss -A ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("ss -A foo,") + def test_3(self, completion): + assert completion diff --git a/test/t/test_ssh.py b/test/t/test_ssh.py new file mode 100644 index 00000000..97a4a733 --- /dev/null +++ b/test/t/test_ssh.py @@ -0,0 +1,30 @@ +import pytest + + +class TestSsh: + @pytest.mark.complete("ssh -Fsp", cwd="ssh") + def test_1(self, completion): + assert completion == "-Fspaced conf" + + @pytest.mark.complete("ssh -F config ls", cwd="ssh") + def test_2(self, completion): + """Should complete both commands and hostname.""" + assert all(x in completion for x in "ls ls_known_host".split()) + + @pytest.mark.complete("ssh bash", cwd="ssh") + def test_3(self, completion): + """ + First arg should not complete with commands. + + Assumes there's no "bash" known host. + """ + assert "bash" not in completion + + @pytest.mark.complete("ssh -vo AddressFamily=") + def test_4(self, completion): + assert completion + + @pytest.mark.xfail # TODO our test facilities don't support case change? + @pytest.mark.complete("ssh -vo userknownhostsf") + def test_5(self, completion): + assert "UserKnownHostsFile=" in completion diff --git a/test/t/test_ssh_add.py b/test/t/test_ssh_add.py new file mode 100644 index 00000000..33e679c7 --- /dev/null +++ b/test/t/test_ssh_add.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="ssh-add") +class TestSshAdd: + @pytest.mark.complete("ssh-add ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ssh_copy_id.py b/test/t/test_ssh_copy_id.py new file mode 100644 index 00000000..cb607715 --- /dev/null +++ b/test/t/test_ssh_copy_id.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp( + cmd="ssh-copy-id", + pre_cmds=( + # 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. + "HOME=$PWD/ssh-copy-id", + ), + ignore_env=r"^[+-]_scp_path_esc=", +) +class TestSshCopyId: + @pytest.mark.complete("ssh-copy-id -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ssh_keygen.py b/test/t/test_ssh_keygen.py new file mode 100644 index 00000000..628672d4 --- /dev/null +++ b/test/t/test_ssh_keygen.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="ssh-keygen") +class TestSshKeygen: + @pytest.mark.complete("ssh-keygen -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sshfs.py b/test/t/test_sshfs.py new file mode 100644 index 00000000..44daed3e --- /dev/null +++ b/test/t/test_sshfs.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^[+-]_scp_path_esc=") +class TestSshfs: + @pytest.mark.complete("sshfs ./") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sshmitm.py b/test/t/test_sshmitm.py new file mode 100644 index 00000000..9964c5b5 --- /dev/null +++ b/test/t/test_sshmitm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSshmitm: + @pytest.mark.complete("sshmitm -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sshow.py b/test/t/test_sshow.py new file mode 100644 index 00000000..b6811e0c --- /dev/null +++ b/test/t/test_sshow.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSshow: + @pytest.mark.complete("sshow -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_strace.py b/test/t/test_strace.py new file mode 100644 index 00000000..b9dbfaca --- /dev/null +++ b/test/t/test_strace.py @@ -0,0 +1,7 @@ +import pytest + + +class TestStrace: + @pytest.mark.complete("strace -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_stream.py b/test/t/test_stream.py new file mode 100644 index 00000000..a46e9015 --- /dev/null +++ b/test/t/test_stream.py @@ -0,0 +1,7 @@ +import pytest + + +class TestStream: + @pytest.mark.complete("stream ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_strings.py b/test/t/test_strings.py new file mode 100644 index 00000000..3922ecef --- /dev/null +++ b/test/t/test_strings.py @@ -0,0 +1,7 @@ +import pytest + + +class TestStrings: + @pytest.mark.complete("strings ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_strip.py b/test/t/test_strip.py new file mode 100644 index 00000000..c756fe03 --- /dev/null +++ b/test/t/test_strip.py @@ -0,0 +1,7 @@ +import pytest + + +class TestStrip: + @pytest.mark.complete("strip --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_su.py b/test/t/test_su.py new file mode 100644 index 00000000..e6c5ef4b --- /dev/null +++ b/test/t/test_su.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSu: + @pytest.mark.complete("su ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sudo.py b/test/t/test_sudo.py new file mode 100644 index 00000000..761c5604 --- /dev/null +++ b/test/t/test_sudo.py @@ -0,0 +1,83 @@ +import pytest + +from conftest import assert_complete + + +class TestSudo: + @pytest.mark.complete("sudo -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("sudo cd fo", cwd="shared/default") + def test_2(self, completion): + assert completion == "foo.d/" + assert not completion.endswith(" ") + + @pytest.mark.complete("sudo sh share") + def test_3(self, completion): + assert completion == "shared/" + assert not completion.endswith(" ") + + @pytest.mark.complete("sudo mount /dev/sda1 def", cwd="shared") + def test_4(self, completion): + assert completion == "default/" + assert not completion.endswith(" ") + + @pytest.mark.complete("sudo -e -u root bar foo", cwd="shared/default") + def test_5(self, completion): + assert completion == ["foo", "foo.d/"] + + def test_6(self, bash, part_full_user): + part, full = part_full_user + completion = assert_complete(bash, "sudo chown %s" % part) + assert completion == full + assert completion.endswith(" ") + + def test_7(self, bash, part_full_user, part_full_group): + _, user = part_full_user + partgroup, fullgroup = part_full_group + completion = assert_complete( + bash, "sudo chown %s:%s" % (user, partgroup) + ) + assert completion == "%s:%s" % (user, fullgroup) + assert completion.endswith(" ") + + def test_8(self, bash, part_full_group): + part, full = part_full_group + completion = assert_complete(bash, "sudo chown dot.user:%s" % part) + assert completion == "dot.user:%s" % full + assert completion.endswith(" ") + + @pytest.mark.xfail # TODO check escaping, whitespace + def test_9(self, bash, part_full_group): + """Test preserving special chars in $prefix$partgroup<TAB>.""" + part, full = part_full_group + for prefix in ( + r"funky\ user:", + "funky.user:", + r"funky\.user:", + r"fu\ nky.user:", + r"f\ o\ o\.\bar:", + r"foo\_b\ a\.r\ :", + ): + completion = assert_complete( + bash, "sudo chown %s%s" % (prefix, part) + ) + assert completion == "%s%s" % (prefix, full) + assert completion.endswith(" ") + + def test_10(self, bash, part_full_user, part_full_group): + """Test giving up on degenerate cases instead of spewing junk.""" + _, user = part_full_user + partgroup, _ = part_full_group + for x in range(2, 5): + completion = assert_complete( + bash, "sudo chown %s%s:%s" % (user, x * "\\", partgroup) + ) + assert not completion + + def test_11(self, bash, part_full_group): + """Test graceful fail on colon in user/group name.""" + part, _ = part_full_group + completion = assert_complete(bash, "sudo chown foo:bar:%s" % part) + assert not completion diff --git a/test/t/test_svcadm.py b/test/t/test_svcadm.py new file mode 100644 index 00000000..76d86a47 --- /dev/null +++ b/test/t/test_svcadm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSvcadm: + @pytest.mark.complete("svcadm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_svk.py b/test/t/test_svk.py new file mode 100644 index 00000000..8014bb01 --- /dev/null +++ b/test/t/test_svk.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSvk: + @pytest.mark.complete("svk ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_svn.py b/test/t/test_svn.py new file mode 100644 index 00000000..d8bbee7b --- /dev/null +++ b/test/t/test_svn.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSvn: + @pytest.mark.complete("svn ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_svnadmin.py b/test/t/test_svnadmin.py new file mode 100644 index 00000000..2dc7c6c7 --- /dev/null +++ b/test/t/test_svnadmin.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSvnadmin: + @pytest.mark.complete("svnadmin ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_svnlook.py b/test/t/test_svnlook.py new file mode 100644 index 00000000..26761b08 --- /dev/null +++ b/test/t/test_svnlook.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSvnlook: + @pytest.mark.complete("svnlook ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sync_members.py b/test/t/test_sync_members.py new file mode 100644 index 00000000..f0d2dcf0 --- /dev/null +++ b/test/t/test_sync_members.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSyncMembers: + @pytest.mark.complete("sync_members --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_synclient.py b/test/t/test_synclient.py new file mode 100644 index 00000000..23138294 --- /dev/null +++ b/test/t/test_synclient.py @@ -0,0 +1,14 @@ +import pytest + + +class TestSynclient: + + # synclient -l may error out with e.g. + # "Couldn't find synaptics properties. No synaptics driver loaded?" + @pytest.mark.complete("synclient ", skipif="! synclient -l &>/dev/null") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("synclient -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_sysbench.py b/test/t/test_sysbench.py new file mode 100644 index 00000000..afe21eca --- /dev/null +++ b/test/t/test_sysbench.py @@ -0,0 +1,7 @@ +import pytest + + +class TestSysbench: + @pytest.mark.complete("sysbench ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_sysctl.py b/test/t/test_sysctl.py new file mode 100644 index 00000000..773b5910 --- /dev/null +++ b/test/t/test_sysctl.py @@ -0,0 +1,14 @@ +import pytest + + +class TestSysctl: + @pytest.mark.complete("sysctl -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete( + "sysctl kern", + skipif="! sysctl -N -a 2>/dev/null | " "command grep -q ^kern", + ) + def test_2(self, completion): + assert completion diff --git a/test/t/test_tac.py b/test/t/test_tac.py new file mode 100644 index 00000000..f612cc90 --- /dev/null +++ b/test/t/test_tac.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTac: + @pytest.mark.complete("tac --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tail.py b/test/t/test_tail.py new file mode 100644 index 00000000..1b818f7d --- /dev/null +++ b/test/t/test_tail.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTail: + @pytest.mark.complete("tail --", skipif="! tail --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tar.py b/test/t/test_tar.py new file mode 100644 index 00000000..309bcc76 --- /dev/null +++ b/test/t/test_tar.py @@ -0,0 +1,126 @@ +import re + +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(ignore_env=r"^-declare -f _tar$") +class TestTar: + @pytest.fixture(scope="class") + def gnu_tar(self, bash): + got = assert_bash_exec(bash, "tar --version || :", want_output=True) + if not re.search(r"\bGNU ", got): + pytest.skip("Not GNU tar") + + @pytest.mark.complete("tar ") + def test_1(self, completion): + assert completion + + # Test "f" when mode is not as first option + @pytest.mark.complete("tar zfc ", cwd="tar") + def test_2(self, completion): + assert completion == "dir/ dir2/".split() + + @pytest.mark.complete("tar cf ", cwd="tar") + def test_3(self, completion): + assert completion == "dir/ dir2/".split() + + @pytest.mark.complete("tar tf archive.tar.xz dir/file", cwd="tar") + def test_4(self, completion): + assert completion == "dir/fileA dir/fileB dir/fileC".split() + + @pytest.mark.complete("tar cTfvv NOT_EXISTS DONT_CREATE.tar ", cwd="tar") + def test_5(self, completion): + assert completion == "archive.tar.xz dir/ dir2/ escape.tar".split() + + @pytest.mark.complete("tar xvf ", cwd="tar") + def test_6(self, completion): + assert completion == "archive.tar.xz dir/ dir2/ escape.tar".split() + + @pytest.mark.complete("tar -c") + def test_7(self, completion, gnu_tar): + """Test short options.""" + assert completion + + @pytest.mark.complete("tar -zcf ", cwd="tar") + def test_8(self, completion, gnu_tar): + """Test mode not as first option.""" + assert completion == "dir/ dir2/".split() + + @pytest.mark.complete("tar -cf ", cwd="tar") + def test_9(self, completion, gnu_tar): + """Test that we don't suggest rewriting existing archive.""" + assert completion == "dir/ dir2/".split() + + @pytest.mark.complete("tar -c --file ", cwd="tar") + def test_10(self, completion, gnu_tar): + assert completion == "dir/ dir2/".split() + + @pytest.mark.complete("tar -cvv --file ", cwd="tar") + def test_11(self, completion, gnu_tar): + assert completion == "dir/ dir2/".split() + + @pytest.mark.complete("tar -tf archive.tar.xz dir/file", cwd="tar") + def test_12(self, completion, gnu_tar): + """Test archive listing.""" + assert completion == "dir/fileA dir/fileB dir/fileC".split() + + @pytest.mark.complete("tar -t --file archive.tar.xz dir/file", cwd="tar") + def test_13(self, completion, gnu_tar): + """Test archive listing with --file.""" + assert completion == "dir/fileA dir/fileB dir/fileC".split() + + @pytest.mark.complete("tar --block") + def test_14(self, completion, gnu_tar): + assert completion == "--block-number --blocking-factor=".split() + + @pytest.mark.complete("tar --add-fil") + def test_15(self, completion, gnu_tar): + assert completion == "--add-file=" + assert not completion.endswith(" ") + + @pytest.mark.complete("tar -cf /dev/null --posi") + def test_16(self, completion, gnu_tar): + assert completion == "--posix" + assert completion.endswith(" ") + + @pytest.mark.complete("tar --owner=") + def test_17(self, bash, completion, gnu_tar): + users = sorted( + assert_bash_exec(bash, "compgen -A user", want_output=True).split() + ) + assert completion == users + + @pytest.mark.complete("tar --group=") + def test_18(self, bash, completion, gnu_tar): + groups = sorted( + assert_bash_exec( + bash, "compgen -A group", want_output=True + ).split() + ) + assert completion == groups + + # Use -b for this as -b is still not handled by tar's completion + @pytest.mark.complete("tar -cvvfb ") + def test_19(self, bash, completion, gnu_tar): + """Test short option -XXXb <TAB> (arg required).""" + assert not completion + + # Use bsdtar here as it completes to only 'zc zt zx' + # -- 'tar' can be GNU tar and have more options + @pytest.mark.complete("bsdtar z") + def test_20(self, bash, completion): + assert completion == "zc zt zx".split() + + @pytest.mark.complete("bsdtar cbfvv NON_EXISTENT ", cwd="tar") + def test_21(self, bash, completion): + """Test _second_ option in "old" argument.""" + assert completion == "dir/ dir2/".split() + + @pytest.mark.complete(r"tar tf escape.tar a/b\'", cwd="tar") + def test_22(self, bash, completion): + """Test listing escaped chars in old option.""" + assert completion == "a/b'c/" + + # TODO: "tar tf escape.tar a/b" diff --git a/test/t/test_tcpdump.py b/test/t/test_tcpdump.py new file mode 100644 index 00000000..ec26187f --- /dev/null +++ b/test/t/test_tcpdump.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTcpdump: + @pytest.mark.complete("tcpdump -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tcpkill.py b/test/t/test_tcpkill.py new file mode 100644 index 00000000..4581a346 --- /dev/null +++ b/test/t/test_tcpkill.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTcpkill: + @pytest.mark.complete("tcpkill -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tcpnice.py b/test/t/test_tcpnice.py new file mode 100644 index 00000000..c7d208d1 --- /dev/null +++ b/test/t/test_tcpnice.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTcpnice: + @pytest.mark.complete("tcpnice -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tee.py b/test/t/test_tee.py new file mode 100644 index 00000000..b0914624 --- /dev/null +++ b/test/t/test_tee.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTee: + @pytest.mark.complete("tee ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_texindex.py b/test/t/test_texindex.py new file mode 100644 index 00000000..4a2387ff --- /dev/null +++ b/test/t/test_texindex.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTexindex: + @pytest.mark.complete("texindex --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tightvncviewer.py b/test/t/test_tightvncviewer.py new file mode 100644 index 00000000..04ebece5 --- /dev/null +++ b/test/t/test_tightvncviewer.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTightvncviewer: + @pytest.mark.complete("tightvncviewer ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_time.py b/test/t/test_time.py new file mode 100644 index 00000000..231f14eb --- /dev/null +++ b/test/t/test_time.py @@ -0,0 +1,23 @@ +import os + +import pytest + + +class TestTime: + @pytest.mark.complete("time set") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("time -p find -typ") + def test_2(self, completion): + assert completion # find's options + + @pytest.mark.complete("time shared/bin/") + def test_3(self, completion): + execs = sorted( + x + for x in os.listdir("shared/bin") + if os.path.isfile("shared/bin/%s" % x) + and os.access("shared/bin/%s" % x, os.X_OK) + ) + assert completion == execs diff --git a/test/t/test_timeout.py b/test/t/test_timeout.py new file mode 100644 index 00000000..6b5ac5f0 --- /dev/null +++ b/test/t/test_timeout.py @@ -0,0 +1,11 @@ +import pytest + + +class TestTimeout: + @pytest.mark.complete("timeout ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("timeout -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_tipc.py b/test/t/test_tipc.py new file mode 100644 index 00000000..17b2bfda --- /dev/null +++ b/test/t/test_tipc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTipc: + @pytest.mark.complete("tipc ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_touch.py b/test/t/test_touch.py new file mode 100644 index 00000000..cc398d81 --- /dev/null +++ b/test/t/test_touch.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTouch: + @pytest.mark.complete("touch --", skipif="! touch --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tox.py b/test/t/test_tox.py new file mode 100644 index 00000000..b6149362 --- /dev/null +++ b/test/t/test_tox.py @@ -0,0 +1,15 @@ +import pytest + + +class TestTox: + @pytest.mark.complete("tox -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("tox -e ") + def test_2(self, completion): + assert completion == "ALL" + + @pytest.mark.complete("tox -e foo,") + def test_3(self, completion): + assert completion == "foo,ALL" diff --git a/test/t/test_tr.py b/test/t/test_tr.py new file mode 100644 index 00000000..84597012 --- /dev/null +++ b/test/t/test_tr.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTr: + @pytest.mark.complete("tr --", skipif="! tr --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_tracepath.py b/test/t/test_tracepath.py new file mode 100644 index 00000000..a6ef7a41 --- /dev/null +++ b/test/t/test_tracepath.py @@ -0,0 +1,11 @@ +import pytest + + +class TestTracepath: + @pytest.mark.complete("tracepath ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("tracepath -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_tshark.py b/test/t/test_tshark.py new file mode 100644 index 00000000..6505e6a8 --- /dev/null +++ b/test/t/test_tshark.py @@ -0,0 +1,31 @@ +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^\+_tshark_pr(ef|otocol)s=") +class TestTshark: + @pytest.mark.complete("tshark -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("tshark -G ") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("tshark -O foo,htt") + def test_3(self, completion): + # When there's only one completion, it's be the one with "foo," prefix; + # when multiple (e.g. http and http2), it's the completion alone. + assert completion == "foo,http" or "http" in completion + + @pytest.mark.complete("tshark -o tcp") + def test_4(self, completion): + assert "tcp.desegment_tcp_streams:" in completion + + @pytest.mark.complete("tshark -otcp") + def test_5(self, completion): + assert "-otcp.desegment_tcp_streams:" in completion + + @pytest.mark.complete("tshark -O http") + def test_6(self, completion): + """Test there are no URLs in completions.""" + assert not any("://" in x for x in completion) diff --git a/test/t/test_tune2fs.py b/test/t/test_tune2fs.py new file mode 100644 index 00000000..c8f4e873 --- /dev/null +++ b/test/t/test_tune2fs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestTune2fs: + @pytest.mark.complete("tune2fs ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_udevadm.py b/test/t/test_udevadm.py new file mode 100644 index 00000000..d5dcddbb --- /dev/null +++ b/test/t/test_udevadm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUdevadm: + @pytest.mark.complete("udevadm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ulimit.py b/test/t/test_ulimit.py new file mode 100644 index 00000000..24785beb --- /dev/null +++ b/test/t/test_ulimit.py @@ -0,0 +1,35 @@ +import pytest + + +class TestUlimit: + @pytest.mark.complete("ulimit ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("ulimit -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("ulimit -S -") + def test_3(self, completion): + """Test modes are completed after -S (-S not treated as mode).""" + assert completion + + @pytest.mark.complete("ulimit -u -") + def test_4(self, completion): + """Test modes are NOT completed if one is specified.""" + assert not completion + + @pytest.mark.complete("ulimit -c ") + def test_5(self, completion): + assert completion + assert not any(x.startswith("-") for x in completion) + + @pytest.mark.complete("ulimit -a ") + def test_6(self, completion): + assert completion == sorted("-S -H".split()) + + @pytest.mark.complete("ulimit -a -H -") + def test_7(self, completion): + """Test modes are NOT completed with -a given somewhere.""" + assert not completion diff --git a/test/t/test_umount.py b/test/t/test_umount.py new file mode 100644 index 00000000..dd4ae0b5 --- /dev/null +++ b/test/t/test_umount.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUmount: + @pytest.mark.complete("umount ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_unace.py b/test/t/test_unace.py new file mode 100644 index 00000000..e4d5acb7 --- /dev/null +++ b/test/t/test_unace.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUnace: + @pytest.mark.complete("unace -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_uname.py b/test/t/test_uname.py new file mode 100644 index 00000000..743f317c --- /dev/null +++ b/test/t/test_uname.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUname: + @pytest.mark.complete("uname --", skipif="! uname --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_unexpand.py b/test/t/test_unexpand.py new file mode 100644 index 00000000..6b77b3bb --- /dev/null +++ b/test/t/test_unexpand.py @@ -0,0 +1,9 @@ +import pytest + + +class TestUnexpand: + @pytest.mark.complete( + "unexpand --", skipif="! unexpand --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_uniq.py b/test/t/test_uniq.py new file mode 100644 index 00000000..8647c615 --- /dev/null +++ b/test/t/test_uniq.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUniq: + @pytest.mark.complete("uniq --", skipif="! uniq --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_units.py b/test/t/test_units.py new file mode 100644 index 00000000..aa1f89c8 --- /dev/null +++ b/test/t/test_units.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUnits: + @pytest.mark.complete("units --", skipif="! units --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_unpack200.py b/test/t/test_unpack200.py new file mode 100644 index 00000000..16c04025 --- /dev/null +++ b/test/t/test_unpack200.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUnpack200: + @pytest.mark.complete("unpack200 ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_unrar.py b/test/t/test_unrar.py new file mode 100644 index 00000000..45e336ef --- /dev/null +++ b/test/t/test_unrar.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUnrar: + @pytest.mark.complete("unrar -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_unset.py b/test/t/test_unset.py new file mode 100644 index 00000000..9f3eaded --- /dev/null +++ b/test/t/test_unset.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUnset: + @pytest.mark.complete("unset BASH_ARG") + def test_1(self, completion): + assert completion diff --git a/test/t/test_unshunt.py b/test/t/test_unshunt.py new file mode 100644 index 00000000..966312ed --- /dev/null +++ b/test/t/test_unshunt.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUnshunt: + @pytest.mark.complete("unshunt --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_update_alternatives.py b/test/t/test_update_alternatives.py new file mode 100644 index 00000000..1209bebf --- /dev/null +++ b/test/t/test_update_alternatives.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="update-alternatives") +class TestUpdateAlternatives: + @pytest.mark.complete("update-alternatives --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_update_rc_d.py b/test/t/test_update_rc_d.py new file mode 100644 index 00000000..6f574168 --- /dev/null +++ b/test/t/test_update_rc_d.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="update-rc.d") +class TestUpdateRcD: + @pytest.mark.complete("update-rc.d -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_upgradepkg.py b/test/t/test_upgradepkg.py new file mode 100644 index 00000000..ada84f1c --- /dev/null +++ b/test/t/test_upgradepkg.py @@ -0,0 +1,34 @@ +import fnmatch +import os + +import pytest + + +class TestUpgradepkg: + @pytest.mark.complete("upgradepkg -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("upgradepkg --") + def test_2(self, completion): + assert ( + completion == "--dry-run --install-new --reinstall " + "--verbose".split() + ) + + @pytest.mark.complete("upgradepkg ", cwd="slackware/home") + def test_4(self, completion): + expected = sorted( + [ + "%s/" % x + for x in os.listdir("slackware/home") + if os.path.isdir("./%s" % x) + ] + + [ + x + for x in os.listdir("slackware/home") + if os.path.isfile("./%s" % x) + and fnmatch.fnmatch(x, "*.t[bglx]z") + ] + ) + assert completion == expected diff --git a/test/t/test_urlsnarf.py b/test/t/test_urlsnarf.py new file mode 100644 index 00000000..a9482113 --- /dev/null +++ b/test/t/test_urlsnarf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUrlsnarf: + @pytest.mark.complete("urlsnarf -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_uscan.py b/test/t/test_uscan.py new file mode 100644 index 00000000..5f4c684a --- /dev/null +++ b/test/t/test_uscan.py @@ -0,0 +1,7 @@ +import pytest + + +class TestUscan: + @pytest.mark.complete("uscan -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_useradd.py b/test/t/test_useradd.py new file mode 100644 index 00000000..557d4a91 --- /dev/null +++ b/test/t/test_useradd.py @@ -0,0 +1,11 @@ +import pytest + + +class TestUseradd: + @pytest.mark.complete("useradd ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("useradd -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_userdel.py b/test/t/test_userdel.py new file mode 100644 index 00000000..74003eb1 --- /dev/null +++ b/test/t/test_userdel.py @@ -0,0 +1,11 @@ +import pytest + + +class TestUserdel: + @pytest.mark.complete("userdel -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("userdel root") + def test_2(self, completion): + assert "root" in completion diff --git a/test/t/test_usermod.py b/test/t/test_usermod.py new file mode 100644 index 00000000..1eb169c7 --- /dev/null +++ b/test/t/test_usermod.py @@ -0,0 +1,11 @@ +import pytest + + +class TestUsermod: + @pytest.mark.complete("usermod ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("usermod -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_valgrind.py b/test/t/test_valgrind.py new file mode 100644 index 00000000..2b03d6f9 --- /dev/null +++ b/test/t/test_valgrind.py @@ -0,0 +1,40 @@ +import os + +import pytest + + +class TestValgrind: + + # b: Assume we have at least bash that starts with b in PATH + @pytest.mark.complete("valgrind b") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("valgrind -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("valgrind --tool=memche") + def test_3(self, completion): + assert "--tool=memcheck" in completion + + @pytest.mark.complete("valgrind --tool=helgrind --history-l") + def test_4(self, completion): + assert "--history-level=" in completion + assert not completion.endswith(" ") + + @pytest.mark.complete(r"valgrind --log-file=v\ 0.log ./bin/", cwd="shared") + def test_5(self, completion): + expected = sorted( + [ + "%s/" + for x in os.listdir("shared/bin") + if os.path.isdir("shared/bin/%s" % x) + ] + + [ + x + for x in os.listdir("shared/bin") + if os.path.isfile("shared/bin/%s" % x) + ] + ) + assert completion == expected diff --git a/test/t/test_vdir.py b/test/t/test_vdir.py new file mode 100644 index 00000000..2f6a744e --- /dev/null +++ b/test/t/test_vdir.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVdir: + @pytest.mark.complete("vdir ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgcfgbackup.py b/test/t/test_vgcfgbackup.py new file mode 100644 index 00000000..20ef09cc --- /dev/null +++ b/test/t/test_vgcfgbackup.py @@ -0,0 +1,9 @@ +import pytest + + +class TestVgcfgbackup: + @pytest.mark.complete( + "vgcfgbackup -", skipif="! vgcfgbackup --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgcfgrestore.py b/test/t/test_vgcfgrestore.py new file mode 100644 index 00000000..26096555 --- /dev/null +++ b/test/t/test_vgcfgrestore.py @@ -0,0 +1,9 @@ +import pytest + + +class TestVgcfgrestore: + @pytest.mark.complete( + "vgcfgrestore -", skipif="! vgcfgrestore --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgchange.py b/test/t/test_vgchange.py new file mode 100644 index 00000000..0e268bad --- /dev/null +++ b/test/t/test_vgchange.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgchange: + @pytest.mark.complete("vgchange -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgck.py b/test/t/test_vgck.py new file mode 100644 index 00000000..347f8f9b --- /dev/null +++ b/test/t/test_vgck.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgck: + @pytest.mark.complete("vgck -", skipif="! vgck --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgconvert.py b/test/t/test_vgconvert.py new file mode 100644 index 00000000..9810bc2f --- /dev/null +++ b/test/t/test_vgconvert.py @@ -0,0 +1,9 @@ +import pytest + + +class TestVgconvert: + @pytest.mark.complete( + "vgconvert -", skipif="! vgconvert --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgcreate.py b/test/t/test_vgcreate.py new file mode 100644 index 00000000..07518e58 --- /dev/null +++ b/test/t/test_vgcreate.py @@ -0,0 +1,11 @@ +import pytest + + +class TestVgcreate: + @pytest.mark.complete("vgcreate -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("vgcreate __does_not_exist__") + def test_2(self, completion): + assert not completion diff --git a/test/t/test_vgdisplay.py b/test/t/test_vgdisplay.py new file mode 100644 index 00000000..a6919a6c --- /dev/null +++ b/test/t/test_vgdisplay.py @@ -0,0 +1,9 @@ +import pytest + + +class TestVgdisplay: + @pytest.mark.complete( + "vgdisplay -", skipif="! vgdisplay --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgexport.py b/test/t/test_vgexport.py new file mode 100644 index 00000000..ce9a93bf --- /dev/null +++ b/test/t/test_vgexport.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgexport: + @pytest.mark.complete("vgexport -", skipif="! vgexport --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgextend.py b/test/t/test_vgextend.py new file mode 100644 index 00000000..3d3347f1 --- /dev/null +++ b/test/t/test_vgextend.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgextend: + @pytest.mark.complete("vgextend -", skipif="! vgextend --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgimport.py b/test/t/test_vgimport.py new file mode 100644 index 00000000..1a3efab0 --- /dev/null +++ b/test/t/test_vgimport.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgimport: + @pytest.mark.complete("vgimport -", skipif="! vgimport --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgmerge.py b/test/t/test_vgmerge.py new file mode 100644 index 00000000..971eb69a --- /dev/null +++ b/test/t/test_vgmerge.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgmerge: + @pytest.mark.complete("vgmerge -", skipif="! vgmerge --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgmknodes.py b/test/t/test_vgmknodes.py new file mode 100644 index 00000000..3209de9f --- /dev/null +++ b/test/t/test_vgmknodes.py @@ -0,0 +1,9 @@ +import pytest + + +class TestVgmknodes: + @pytest.mark.complete( + "vgmknodes -", skipif="! vgmknodes --help &>/dev/null" + ) + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgreduce.py b/test/t/test_vgreduce.py new file mode 100644 index 00000000..97641b42 --- /dev/null +++ b/test/t/test_vgreduce.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgreduce: + @pytest.mark.complete("vgreduce -", skipif="! vgreduce --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgremove.py b/test/t/test_vgremove.py new file mode 100644 index 00000000..9c47752c --- /dev/null +++ b/test/t/test_vgremove.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgremove: + @pytest.mark.complete("vgremove -", skipif="! vgremove --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgrename.py b/test/t/test_vgrename.py new file mode 100644 index 00000000..ea5bc050 --- /dev/null +++ b/test/t/test_vgrename.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgrename: + @pytest.mark.complete("vgrename -", skipif="! vgrename --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgs.py b/test/t/test_vgs.py new file mode 100644 index 00000000..d492fe8d --- /dev/null +++ b/test/t/test_vgs.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgs: + @pytest.mark.complete("vgs -", skipif="! vgs --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgscan.py b/test/t/test_vgscan.py new file mode 100644 index 00000000..061ff4e2 --- /dev/null +++ b/test/t/test_vgscan.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgscan: + @pytest.mark.complete("vgscan -", skipif="! vgscan --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vgsplit.py b/test/t/test_vgsplit.py new file mode 100644 index 00000000..7b5a6869 --- /dev/null +++ b/test/t/test_vgsplit.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVgsplit: + @pytest.mark.complete("vgsplit -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vi.py b/test/t/test_vi.py new file mode 100644 index 00000000..4f7f4c2b --- /dev/null +++ b/test/t/test_vi.py @@ -0,0 +1,11 @@ +import pytest + + +class TestVi: + @pytest.mark.complete("vi ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("vi shared/ld.so.conf.d/") + def test_2(self, completion): + assert completion == "foo.txt libfoo.conf".split() diff --git a/test/t/test_vipw.py b/test/t/test_vipw.py new file mode 100644 index 00000000..160cb11b --- /dev/null +++ b/test/t/test_vipw.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVipw: + @pytest.mark.complete("vipw -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vmstat.py b/test/t/test_vmstat.py new file mode 100644 index 00000000..47b55f6f --- /dev/null +++ b/test/t/test_vmstat.py @@ -0,0 +1,7 @@ +import pytest + + +class TestVmstat: + @pytest.mark.complete("vmstat -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vncviewer.py b/test/t/test_vncviewer.py new file mode 100644 index 00000000..9e2f1486 --- /dev/null +++ b/test/t/test_vncviewer.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(ignore_env=r"^-declare -f _vncviewer_bootstrap$") +class TestVncviewer: + @pytest.mark.complete("vncviewer ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_vpnc.py b/test/t/test_vpnc.py new file mode 100644 index 00000000..29a120a4 --- /dev/null +++ b/test/t/test_vpnc.py @@ -0,0 +1,13 @@ +import pytest + + +@pytest.mark.bashcomp( + # On CentOS and Fedora, there's something fishy with consolehelper and + # /usr/bin/vpnc going on at least when invoked as root; try to invoke the + # one in /usr/sbin instead. + pre_cmds=("PATH=/usr/sbin:$PATH",) +) +class TestVpnc: + @pytest.mark.complete("vpnc -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_watch.py b/test/t/test_watch.py new file mode 100644 index 00000000..8387ae0a --- /dev/null +++ b/test/t/test_watch.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWatch: + @pytest.mark.complete("watch -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_wc.py b/test/t/test_wc.py new file mode 100644 index 00000000..eb7b5a85 --- /dev/null +++ b/test/t/test_wc.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWc: + @pytest.mark.complete("wc --", skipif="! wc --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_webmitm.py b/test/t/test_webmitm.py new file mode 100644 index 00000000..e9f85940 --- /dev/null +++ b/test/t/test_webmitm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWebmitm: + @pytest.mark.complete("webmitm -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_wget.py b/test/t/test_wget.py new file mode 100644 index 00000000..f8af4fb3 --- /dev/null +++ b/test/t/test_wget.py @@ -0,0 +1,11 @@ +import pytest + + +class TestWget: + @pytest.mark.complete("wget ") + def test_1(self, completion): + assert not completion + + @pytest.mark.complete("wget --h") + def test_2(self, completion): + assert completion diff --git a/test/t/test_who.py b/test/t/test_who.py new file mode 100644 index 00000000..d1f29ea7 --- /dev/null +++ b/test/t/test_who.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWho: + @pytest.mark.complete("who --", skipif="! who --help &>/dev/null") + def test_1(self, completion): + assert completion diff --git a/test/t/test_wine.py b/test/t/test_wine.py new file mode 100644 index 00000000..d0e5698b --- /dev/null +++ b/test/t/test_wine.py @@ -0,0 +1,11 @@ +import pytest + + +class TestWine: + @pytest.mark.complete("wine ", cwd="shared/default") + def test_1(self, completion): + assert completion == ["bar bar.d/", "foo.d/"] + + @pytest.mark.complete("wine notepad ", cwd="shared/default") + def test_2(self, completion): + assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"] diff --git a/test/t/test_withlist.py b/test/t/test_withlist.py new file mode 100644 index 00000000..752c3943 --- /dev/null +++ b/test/t/test_withlist.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWithlist: + @pytest.mark.complete("withlist --") + def test_1(self, completion): + assert completion diff --git a/test/t/test_wodim.py b/test/t/test_wodim.py new file mode 100644 index 00000000..4b785b6d --- /dev/null +++ b/test/t/test_wodim.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWodim: + @pytest.mark.complete("wodim ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_wol.py b/test/t/test_wol.py new file mode 100644 index 00000000..8a6bea21 --- /dev/null +++ b/test/t/test_wol.py @@ -0,0 +1,15 @@ +import pytest + + +@pytest.mark.bashcomp(pre_cmds=("PATH=$PWD/shared/bin:$PATH",)) +class TestWol: + @pytest.mark.complete("wol ") + def test_1(self, completion): + assert ( + completion == "00:00:00:00:00:00 11:11:11:11:11:11 " + "22:22:22:22:22:22 33:33:33:33:33:33".split() + ) + + @pytest.mark.complete("wol 00:") + def test_2(self, completion): + assert completion == "00:00:00:00:00:00" diff --git a/test/t/test_write.py b/test/t/test_write.py new file mode 100644 index 00000000..8f0886e4 --- /dev/null +++ b/test/t/test_write.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWrite: + @pytest.mark.complete("write root") + def test_1(self, completion): + assert "root" in completion diff --git a/test/t/test_wsimport.py b/test/t/test_wsimport.py new file mode 100644 index 00000000..b75bf0f7 --- /dev/null +++ b/test/t/test_wsimport.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWsimport: + @pytest.mark.complete("wsimport ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_wtf.py b/test/t/test_wtf.py new file mode 100644 index 00000000..6b2c9745 --- /dev/null +++ b/test/t/test_wtf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWtf: + @pytest.mark.complete("wtf A") + def test_1(self, completion): + assert completion diff --git a/test/t/test_wvdial.py b/test/t/test_wvdial.py new file mode 100644 index 00000000..19043f61 --- /dev/null +++ b/test/t/test_wvdial.py @@ -0,0 +1,7 @@ +import pytest + + +class TestWvdial: + @pytest.mark.complete("wvdial -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_xdg_mime.py b/test/t/test_xdg_mime.py new file mode 100644 index 00000000..432be067 --- /dev/null +++ b/test/t/test_xdg_mime.py @@ -0,0 +1,28 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="xdg-mime") +class TestXdgMime: + @pytest.mark.complete("xdg-mime ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xdg-mime -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("xdg-mime query ") + def test_3(self, completion): + assert completion + + @pytest.mark.complete("xdg-mime query filetype ") + def test_4(self, completion): + assert completion + + @pytest.mark.complete("xdg-mime default foo.desktop ") + def test_5(self, completion): + assert completion + + @pytest.mark.complete("xdg-mime install --mode ") + def test_6(self, completion): + assert completion diff --git a/test/t/test_xdg_settings.py b/test/t/test_xdg_settings.py new file mode 100644 index 00000000..a50df579 --- /dev/null +++ b/test/t/test_xdg_settings.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="xdg-settings") +class TestXdgSettings: + @pytest.mark.complete("xdg-settings ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xdg-settings --") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("xdg-settings get ") + def test_3(self, completion): + assert completion diff --git a/test/t/test_xfreerdp.py b/test/t/test_xfreerdp.py new file mode 100644 index 00000000..fdad1926 --- /dev/null +++ b/test/t/test_xfreerdp.py @@ -0,0 +1,46 @@ +import pytest + +from conftest import assert_bash_exec + + +class TestXfreerdp: + def _help(self, bash): + return assert_bash_exec(bash, "xfreerdp --help || :", want_output=True) + + @pytest.fixture(scope="class") + def slash_syntax(self, bash): + if "/help" not in self._help(bash): + pytest.skip("Not slash syntax") + + @pytest.fixture(scope="class") + def dash_syntax(self, bash): + if "/help" in self._help(bash): + pytest.skip("Not dash syntax") + + @pytest.mark.complete("xfreerdp /") + def test_1(self, bash, completion, slash_syntax): + assert completion + + @pytest.mark.complete("xfreerdp -") + def test_2(self, completion): + assert completion + + @pytest.mark.complete("xfreerdp +") + def test_3(self, bash, completion, slash_syntax): + assert completion + + @pytest.mark.complete("xfreerdp /kbd:") + def test_4(self, bash, completion, slash_syntax): + assert completion + + @pytest.mark.complete("xfreerdp /help ") + def test_5(self, completion): + assert not completion + + @pytest.mark.complete("xfreerdp -k ") + def test_6(self, bash, completion, dash_syntax): + assert completion + + @pytest.mark.complete("xfreerdp --help ") + def test_7(self, completion): + assert not completion diff --git a/test/t/test_xgamma.py b/test/t/test_xgamma.py new file mode 100644 index 00000000..56c9440d --- /dev/null +++ b/test/t/test_xgamma.py @@ -0,0 +1,12 @@ +import pytest + + +class TestXgamma: + @pytest.mark.complete("xgamma -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xgamma -gam") + def test_2(self, completion): + assert completion == "-gamma" + assert completion.endswith(" ") diff --git a/test/t/test_xm.py b/test/t/test_xm.py new file mode 100644 index 00000000..42c4c53d --- /dev/null +++ b/test/t/test_xm.py @@ -0,0 +1,7 @@ +import pytest + + +class TestXm: + @pytest.mark.complete("xm ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_xmllint.py b/test/t/test_xmllint.py new file mode 100644 index 00000000..0c0ebbcd --- /dev/null +++ b/test/t/test_xmllint.py @@ -0,0 +1,11 @@ +import pytest + + +class TestXmllint: + @pytest.mark.complete("xmllint ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xmllint -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_xmlwf.py b/test/t/test_xmlwf.py new file mode 100644 index 00000000..8751f865 --- /dev/null +++ b/test/t/test_xmlwf.py @@ -0,0 +1,7 @@ +import pytest + + +class TestXmlwf: + @pytest.mark.complete("xmlwf ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_xmms.py b/test/t/test_xmms.py new file mode 100644 index 00000000..1c96e2b5 --- /dev/null +++ b/test/t/test_xmms.py @@ -0,0 +1,11 @@ +import pytest + + +class TestXmms: + @pytest.mark.complete("xmms --") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xmms --non-existent-option=--") + def test_2(self, completion): + assert not completion diff --git a/test/t/test_xmodmap.py b/test/t/test_xmodmap.py new file mode 100644 index 00000000..d6d0ceae --- /dev/null +++ b/test/t/test_xmodmap.py @@ -0,0 +1,11 @@ +import pytest + + +class TestXmodmap: + @pytest.mark.complete("xmodmap ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xmodmap -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_xpovray.py b/test/t/test_xpovray.py new file mode 100644 index 00000000..4f603a7c --- /dev/null +++ b/test/t/test_xpovray.py @@ -0,0 +1,7 @@ +import pytest + + +class TestXpovray: + @pytest.mark.complete("xpovray ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_xrandr.py b/test/t/test_xrandr.py new file mode 100644 index 00000000..e4e0d6b7 --- /dev/null +++ b/test/t/test_xrandr.py @@ -0,0 +1,11 @@ +import pytest + + +class TestXrandr: + @pytest.mark.complete("xrandr ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xrandr --mode ") + def test_2(self, completion): + assert not completion diff --git a/test/t/test_xrdb.py b/test/t/test_xrdb.py new file mode 100644 index 00000000..8f675e68 --- /dev/null +++ b/test/t/test_xrdb.py @@ -0,0 +1,7 @@ +import pytest + + +class TestXrdb: + @pytest.mark.complete("xrdb ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_xsltproc.py b/test/t/test_xsltproc.py new file mode 100644 index 00000000..26898777 --- /dev/null +++ b/test/t/test_xsltproc.py @@ -0,0 +1,11 @@ +import pytest + + +class TestXsltproc: + @pytest.mark.complete("xsltproc ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xsltproc -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_xvnc4viewer.py b/test/t/test_xvnc4viewer.py new file mode 100644 index 00000000..72fe3f98 --- /dev/null +++ b/test/t/test_xvnc4viewer.py @@ -0,0 +1,15 @@ +import pytest + + +class TestXvnc4viewer: + @pytest.mark.complete("xvnc4viewer -") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xvnc4viewer -PreferredEncoding ") + def test_2(self, completion): + assert completion == "hextile raw zrle".split() + + @pytest.mark.complete("xvnc4viewer --preferredencoding ") + def test_3(self, completion): + assert completion == "hextile raw zrle".split() diff --git a/test/t/test_xxd.py b/test/t/test_xxd.py new file mode 100644 index 00000000..bd461eb7 --- /dev/null +++ b/test/t/test_xxd.py @@ -0,0 +1,11 @@ +import pytest + + +class TestXxd: + @pytest.mark.complete("xxd ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xxd -") + def test_2(self, completion): + assert completion diff --git a/test/t/test_xz.py b/test/t/test_xz.py new file mode 100644 index 00000000..6b92f480 --- /dev/null +++ b/test/t/test_xz.py @@ -0,0 +1,22 @@ +import pytest + + +class TestXz: + @pytest.mark.complete("xz ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("xz -d xz/") + def test_2(self, completion): + assert ( + completion == "a/ bashcomp.lzma bashcomp.tar.xz " + "bashcomp.tlz bashcomp.xz".split() + ) + + @pytest.mark.complete("xz xz/") + def test_3(self, completion): + assert completion == "a/ bashcomp.tar".split() + + @pytest.mark.complete("xz ~") + def test_4(self, completion): + assert completion diff --git a/test/t/test_xzdec.py b/test/t/test_xzdec.py new file mode 100644 index 00000000..e57c1b65 --- /dev/null +++ b/test/t/test_xzdec.py @@ -0,0 +1,7 @@ +import pytest + + +class TestXzdec: + @pytest.mark.complete("xzdec ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ypcat.py b/test/t/test_ypcat.py new file mode 100644 index 00000000..f743c5ad --- /dev/null +++ b/test/t/test_ypcat.py @@ -0,0 +1,7 @@ +import pytest + + +class TestYpcat: + @pytest.mark.complete("ypcat ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_ypmatch.py b/test/t/test_ypmatch.py new file mode 100644 index 00000000..db56320a --- /dev/null +++ b/test/t/test_ypmatch.py @@ -0,0 +1,7 @@ +import pytest + + +class TestYpmatch: + @pytest.mark.complete("ypmatch foo ") + def test_1(self, completion): + assert completion diff --git a/test/t/test_yum.py b/test/t/test_yum.py new file mode 100644 index 00000000..5d4a052b --- /dev/null +++ b/test/t/test_yum.py @@ -0,0 +1,7 @@ +import pytest + + +class TestYum: + @pytest.mark.complete("yum -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_yum_arch.py b/test/t/test_yum_arch.py new file mode 100644 index 00000000..9bbc38ff --- /dev/null +++ b/test/t/test_yum_arch.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.bashcomp(cmd="yum-arch") +class TestYumArch: + @pytest.mark.complete("yum-arch -") + def test_1(self, completion): + assert completion diff --git a/test/t/test_zopfli.py b/test/t/test_zopfli.py new file mode 100644 index 00000000..127eda28 --- /dev/null +++ b/test/t/test_zopfli.py @@ -0,0 +1,11 @@ +import pytest + + +class TestZopfli: + @pytest.mark.complete("zopfli ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("zopfli ~") + def test_2(self, completion): + assert completion diff --git a/test/t/test_zopflipng.py b/test/t/test_zopflipng.py new file mode 100644 index 00000000..a01e7bd7 --- /dev/null +++ b/test/t/test_zopflipng.py @@ -0,0 +1,7 @@ +import pytest + + +class TestZopflipng: + @pytest.mark.complete("zopflipng ") + def test_1(self, completion): + assert completion diff --git a/test/t/unit/Makefile.am b/test/t/unit/Makefile.am new file mode 100644 index 00000000..a0ab7502 --- /dev/null +++ b/test/t/unit/Makefile.am @@ -0,0 +1,19 @@ +EXTRA_DIST = \ + test_unit_count_args.py \ + test_unit_expand.py \ + test_unit_expand_tilde_by_ref.py \ + test_unit_filedir.py \ + test_unit_find_unique_completion_pair.py \ + test_unit_get_comp_words_by_ref.py \ + test_unit_get_cword.py \ + test_unit_init_completion.py \ + test_unit_ip_addresses.py \ + test_unit_longopt.py \ + test_unit_parse_help.py \ + test_unit_parse_usage.py \ + test_unit_tilde.py + +all: + +clean-local: + $(RM) -R __pycache__ diff --git a/test/t/unit/test_unit_count_args.py b/test/t/unit/test_unit_count_args.py new file mode 100644 index 00000000..c0afe736 --- /dev/null +++ b/test/t/unit/test_unit_count_args.py @@ -0,0 +1,66 @@ +import pytest + +from conftest import assert_bash_exec, TestUnitBase + + +@pytest.mark.bashcomp( + cmd=None, ignore_env=r"^[+-](args|COMP_(WORDS|CWORD|LINE|POINT))=" +) +class TestUnitCountArgs(TestUnitBase): + def _test(self, *args, **kwargs): + return self._test_unit("_count_args %s; echo $args", *args, **kwargs) + + def test_1(self, bash): + assert_bash_exec(bash, "_count_args >/dev/null") + + def test_2(self, bash): + """a b| should set args to 1""" + output = self._test(bash, "(a b)", 1, "a b", 3) + assert output == "1" + + def test_3(self, bash): + """a b|c should set args to 1""" + output = self._test(bash, "(a bc)", 1, "a bc", 3) + assert output == "1" + + def test_4(self, bash): + """a b c| should set args to 2""" + output = self._test(bash, "(a b c)", 2, "a b c", 4) + assert output == "2" + + def test_5(self, bash): + """a b| c should set args to 1""" + output = self._test(bash, "(a b c)", 1, "a b c", 3) + assert output == "1" + + def test_6(self, bash): + """a b -c| d should set args to 2""" + output = self._test(bash, "(a b -c d)", 2, "a b -c d", 6) + assert output == "2" + + def test_7(self, bash): + """a b -c d e| with -c arg excluded should set args to 2""" + output = self._test( + bash, "(a b -c d e)", 4, "a b -c d e", 10, arg='"" "@(-c|--foo)"' + ) + assert output == "2" + + def test_8(self, bash): + """a -b -c d e| with -c arg excluded + and -b included should set args to 1""" + output = self._test( + bash, + "(a -b -c d e)", + 4, + "a -b -c d e", + 11, + arg='"" "@(-c|--foo)" "-[b]"', + ) + assert output == "2" + + def test_9(self, bash): + """a -b -c d e| with -b included should set args to 3""" + output = self._test( + bash, "(a -b -c d e)", 4, "a -b -c d e", 11, arg='"" "" "-b"' + ) + assert output == "3" diff --git a/test/t/unit/test_unit_expand.py b/test/t/unit/test_unit_expand.py new file mode 100644 index 00000000..7c0a9836 --- /dev/null +++ b/test/t/unit/test_unit_expand.py @@ -0,0 +1,13 @@ +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(cmd=None) +class TestUnitExpand: + def test_1(self, bash): + assert_bash_exec(bash, "_expand >/dev/null") + + def test_2(self, bash): + """Test environment non-pollution, detected at teardown.""" + assert_bash_exec(bash, "foo() { _expand; }; foo; unset foo") diff --git a/test/t/unit/test_unit_expand_tilde_by_ref.py b/test/t/unit/test_unit_expand_tilde_by_ref.py new file mode 100644 index 00000000..fbc172df --- /dev/null +++ b/test/t/unit/test_unit_expand_tilde_by_ref.py @@ -0,0 +1,16 @@ +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(cmd=None) +class TestUnitExpandTildeByRef: + def test_1(self, bash): + assert_bash_exec(bash, "__expand_tilde_by_ref >/dev/null") + + def test_2(self, bash): + """Test environment non-pollution, detected at teardown.""" + assert_bash_exec( + bash, + '_x() { local aa="~"; __expand_tilde_by_ref aa; }; _x; unset _x', + ) diff --git a/test/t/unit/test_unit_filedir.py b/test/t/unit/test_unit_filedir.py new file mode 100644 index 00000000..dcd52403 --- /dev/null +++ b/test/t/unit/test_unit_filedir.py @@ -0,0 +1,9 @@ +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") +class TestUnitFiledir: + def test_1(self, bash): + assert_bash_exec(bash, "_filedir >/dev/null") diff --git a/test/t/unit/test_unit_find_unique_completion_pair.py b/test/t/unit/test_unit_find_unique_completion_pair.py new file mode 100644 index 00000000..25cf9d3b --- /dev/null +++ b/test/t/unit/test_unit_find_unique_completion_pair.py @@ -0,0 +1,55 @@ +import pytest + +from conftest import find_unique_completion_pair + + +@pytest.mark.bashcomp(cmd=None) +class TestUnitFindUniqueCompletionPair: + def _test(self, inp: str, exp: str) -> None: + res = find_unique_completion_pair(inp.split()) + if exp: + part, cont = exp.split() + assert res == (part, part + cont) + else: + assert not exp + + def test_1(self): + self._test("a", "") + + def test_2(self): + self._test("ab", "a b") + + def test_3(self): + self._test("ab ab ab", "a b") + + def test_4(self): + self._test("a ab abcd abc", "") + + def test_5(self): + self._test("user1 user2", "") + + def test_6(self): + self._test("root username1 username2", "ro ot") + + def test_7(self): + self._test("root username21 username2", "ro ot") + + def test_8(self): + self._test( + "long_user_name lang_user_name long_usor_name", "lang_us er_name" + ) + + def test_9(self): + self._test( + "lang_user_name1 long_user_name lang_user_name long_usor_name", + "long_use r_name", + ) + + def test_10(self): + self._test("root username", "user name") + + def test_11(self): + self._test("a aladin", "ala din") + + def test_12(self): + self._test("ala aladin", "alad in") diff --git a/test/t/unit/test_unit_get_comp_words_by_ref.py b/test/t/unit/test_unit_get_comp_words_by_ref.py new file mode 100644 index 00000000..1603bad6 --- /dev/null +++ b/test/t/unit/test_unit_get_comp_words_by_ref.py @@ -0,0 +1,167 @@ +import pytest + +from conftest import assert_bash_exec, TestUnitBase + + +@pytest.mark.bashcomp( + cmd=None, ignore_env=r"^(\+(cur|prev)|[+-]COMP_(WORDS|CWORD|LINE|POINT))=" +) +class TestUnitGetCompWordsByRef(TestUnitBase): + def _test(self, bash, *args, **kwargs): + assert_bash_exec(bash, "unset cur prev") + output = self._test_unit( + "_get_comp_words_by_ref %s cur prev; echo $cur,$prev", + bash, + *args, + **kwargs + ) + return output.strip() + + def test_1(self, bash): + assert_bash_exec(bash, "_get_comp_words_by_ref cur >/dev/null") + + def test_2(self, bash): + """a b|""" + output = self._test(bash, "(a b)", 1, "a b", 3) + assert output == "b,a" + + def test_3(self, bash): + """a |""" + output = self._test(bash, "(a)", 1, "a ", 2) + assert output == ",a" + + def test_4(self, bash): + """|a""" + output = self._test(bash, "(a)", 0, "a", 0) + assert output == "," + + def test_5(self, bash): + """|a """ + output = self._test(bash, "(a)", 0, "a ", 0) + assert output == "," + + def test_6(self, bash): + """ | a """ + output = self._test(bash, "(a)", 0, " a ", 1) + assert output.strip() == "," + + def test_7(self, bash): + """a b |""" + output = self._test(bash, "(a b '')", 2, "a b ", 4) + assert output == ",b" + + def test_8(self, bash): + """a b | with WORDBREAKS -= :""" + output = self._test(bash, "(a b '')", 2, "a b ", 4, arg="-n :") + assert output == ",b" + + def test_9(self, bash): + """a b|c""" + output = self._test(bash, "(a bc)", 1, "a bc", 3) + assert output == "b,a" + + def test_10(self, bash): + """a | b""" + output = self._test(bash, "(a b)", 1, "a b", 2) + assert output == ",a" + + def test_11(self, bash): + r"""a b\ c|""" + output = self._test(bash, r"(a 'b\ c')", 1, r"a b\ c", 6) + assert output == r"b\ c,a" + + def test_12(self, bash): + r"""a\ b a\ b|""" + output = self._test(bash, r"('a\ b' 'a\ b')", 1, r"a\ b a\ b", 9) + assert output == r"a\ b,a\ b" + + def test_13(self, bash): + r"""a b\| c""" + output = self._test(bash, r"(a 'b\ c')", 1, r"a b\ c", 4) + assert output == r"b\,a" + + def test_14(self, bash): + r"""a "b\|""" + output = self._test(bash, "(a '\"b')", 1, 'a "b\\', 5) + assert output == r'"b\,a' + + def test_15(self, bash): + """a 'b c|""" + output = self._test(bash, '(a "\'b c")', 1, "a 'b c", 6) + assert output == "'b c,a" + + def test_16(self, bash): + """a "b c|""" + output = self._test(bash, r'(a "\"b c")', 1, 'a "b c', 6) + assert output == '"b c,a' + + def test_17(self, bash): + """a b:c| with WORDBREAKS += :""" + assert_bash_exec(bash, "add_comp_wordbreak_char :") + output = self._test(bash, "(a b : c)", 3, "a b:c", 5) + assert output == "c,:" + + def test_18(self, bash): + """a b:c| with WORDBREAKS -= :""" + output = self._test(bash, "(a b : c)", 3, "a b:c", 5, arg="-n :") + assert output == "b:c,a" + + def test_19(self, bash): + """a b c:| with WORDBREAKS -= :""" + output = self._test(bash, "(a b c :)", 3, "a b c:", 6, arg="-n :") + assert output == "c:,b" + + def test_20(self, bash): + r"""a b:c | with WORDBREAKS -= :""" + output = self._test(bash, "(a b : c '')", 4, "a b:c ", 6, arg="-n :") + assert output == ",b:c" + + def test_21(self, bash): + """a :| with WORDBREAKS -= :""" + output = self._test(bash, "(a :)", 1, "a :", 3, arg="-n :") + assert output == ":,a" + + def test_22(self, bash): + """a b::| with WORDBREAKS -= :""" + output = self._test(bash, "(a b ::)", 2, "a b::", 5, arg="-n :") + assert output == "b::,a" + + def test_23(self, bash): + """a -n| + + This test makes sure `_get_cword' doesn't use `echo' to return its + value, because -n might be interpreted by `echo' and thus woud not + be returned. + """ + output = self._test(bash, "(a -n)", 1, "a -n", 4) + assert output == "-n,a" + + def test_24(self, bash): + """a b>c|""" + output = self._test(bash, r"(a b \> c)", 3, "a b>c", 5) + assert output.startswith("c,") + + def test_25(self, bash): + """a b=c|""" + output = self._test(bash, "(a b = c)", 3, "a b=c", 5) + assert output.startswith("c,") + + def test_26(self, bash): + """a *|""" + output = self._test(bash, r"(a \*)", 1, "a *", 4) + assert output == "*,a" + + def test_27(self, bash): + """a $(b c|""" + output = self._test(bash, "(a '$(b c')", 1, "a $(b c", 7) + assert output == "$(b c,a" + + def test_28(self, bash): + r"""a $(b c\ d|""" + output = self._test(bash, r"(a '$(b c\ d')", 1, r"a $(b c\ d", 10) + assert output == r"$(b c\ d,a" + + def test_29(self, bash): + """a 'b&c|""" + output = self._test(bash, '(a "\'b&c")', 1, "a 'b&c", 6) + assert output == "'b&c,a" diff --git a/test/t/unit/test_unit_get_cword.py b/test/t/unit/test_unit_get_cword.py new file mode 100644 index 00000000..3042dd29 --- /dev/null +++ b/test/t/unit/test_unit_get_cword.py @@ -0,0 +1,135 @@ +import pytest + +from conftest import assert_bash_exec, TestUnitBase + + +@pytest.mark.bashcomp( + cmd=None, ignore_env=r"^[+-]COMP_(WORDS|CWORD|LINE|POINT)=" +) +class TestUnitGetCword(TestUnitBase): + def _test(self, *args, **kwargs): + return self._test_unit("_get_cword %s; echo", *args, **kwargs) + + def test_1(self, bash): + assert_bash_exec(bash, "_get_cword >/dev/null") + + def test_2(self, bash): + """a b| should return b""" + output = self._test(bash, "(a b)", 1, "a b", 3) + assert output == "b" + + def test_3(self, bash): + """a | should return nothing""" + output = self._test(bash, "(a)", 1, "a ", 2) + assert not output + + def test_4(self, bash): + """a b | should return nothing""" + output = self._test(bash, "(a b '')", 2, "a b ", 4) + assert not output + + def test_5(self, bash): + """a b | with WORDBREAKS -= : should return nothing""" + output = self._test(bash, "(a b '')", 2, "a b ", 4, arg=":") + assert not output + + def test_6(self, bash): + """a b|c should return b""" + output = self._test(bash, "(a bc)", 1, "a bc", 3) + assert output == "b" + + def test_7(self, bash): + r"""a b\ c| should return b\ c""" + output = self._test(bash, r"(a 'b\ c')", 1, r"a b\ c", 6) + assert output == r"b\ c" + + def test_8(self, bash): + r"""a b\| c should return b\ """ + output = self._test(bash, r"(a 'b\ c')", 1, r"a b\ c", 4) + assert output == "b\\" + + def test_9(self, bash): + r"""a "b\| should return "b\ """ + output = self._test(bash, "(a '\"b\\')", 1, r"a \"b\\", 5) + assert output == '"b\\' + + def test_10(self, bash): + r"""a 'b c| should return 'b c""" + output = self._test(bash, '(a "\'b c")', 1, "a 'b c", 6) + assert output == "'b c" + + def test_11(self, bash): + r"""a "b c| should return "b c""" + output = self._test(bash, "(a '\"b c')", 1, 'a "b c', 6) + assert output == '"b c' + + def test_12(self, bash): + """a b:c| with WORDBREAKS += : should return c""" + assert_bash_exec(bash, "add_comp_wordbreak_char :") + output = self._test(bash, "(a b : c)", 3, "a b:c", 5) + assert output == "c" + + def test_13(self, bash): + """a b:c| with WORDBREAKS -= : should return b:c""" + assert_bash_exec(bash, "add_comp_wordbreak_char :") + output = self._test(bash, "(a b : c)", 3, "a b:c", 5, arg=":") + assert output == "b:c" + + def test_14(self, bash): + """a b c:| with WORDBREAKS -= : should return c:""" + assert_bash_exec(bash, "add_comp_wordbreak_char :") + output = self._test(bash, "(a b c :)", 3, "a b c:", 6, arg=":") + assert output == "c:" + + def test_15(self, bash): + """a :| with WORDBREAKS -= : should return :""" + assert_bash_exec(bash, "add_comp_wordbreak_char :") + output = self._test(bash, "(a :)", 1, "a :", 3, arg=":") + assert output == ":" + + def test_16(self, bash): + """a b::| with WORDBREAKS -= : should return b::""" + assert_bash_exec(bash, "add_comp_wordbreak_char :") + output = self._test(bash, "(a b::)", 1, "a b::", 5, arg=":") + assert output == "b::" + + def test_17(self, bash): + """ + a -n| should return -n + + This test makes sure `_get_cword' doesn't use `echo' to return its + value, because -n might be interpreted by `echo' and thus woud not + be returned. + """ + output = self._test(bash, "(a -n)", 1, "a -n", 4) + assert output == "-n" + + def test_18(self, bash): + """a b>c| should return c""" + output = self._test(bash, r"(a b \> c)", 3, "a b>c", 5) + assert output == "c" + + def test_19(self, bash): + """a b=c| should return c""" + output = self._test(bash, "(a b = c)", 3, "a b=c", 5) + assert output == "c" + + def test_20(self, bash): + """a *| should return *""" + output = self._test(bash, r"(a \*)", 1, "a *", 4) + assert output == "*" + + def test_21(self, bash): + """a $(b c| should return $(b c""" + output = self._test(bash, r"(a '$(b c')", 1, "a $(b c", 7) + assert output == "$(b c" + + def test_22(self, bash): + r"""a $(b c\ d| should return $(b c\ d""" + output = self._test(bash, r"(a '$(b c\ d')", 1, r"a $(b c\ d", 10) + assert output == r"$(b c\ d" + + def test_23(self, bash): + """a 'b&c| should return 'b&c""" + output = self._test(bash, '(a "\'b&c")', 1, "a 'b&c", 6) + assert output == "'b&c" diff --git a/test/t/unit/test_unit_init_completion.py b/test/t/unit/test_unit_init_completion.py new file mode 100644 index 00000000..64f3b511 --- /dev/null +++ b/test/t/unit/test_unit_init_completion.py @@ -0,0 +1,24 @@ +import pytest + +from conftest import assert_bash_exec, TestUnitBase + + +@pytest.mark.bashcomp( + cmd=None, + ignore_env=r"^[+-](COMP(_(WORDS|CWORD|LINE|POINT)|REPLY)|" + r"cur|cword|words)=", +) +class TestUnitInitCompletion(TestUnitBase): + def test_1(self, bash): + """Test environment non-pollution, detected at teardown.""" + assert_bash_exec( + bash, + "foo() { local cur prev words cword; _init_completion; }; " + "foo; unset foo", + ) + + def test_2(self, bash): + output = self._test_unit( + "_init_completion %s; echo $cur,$prev", bash, "(a)", 0, "a", 0 + ) + assert output == "," diff --git a/test/t/unit/test_unit_ip_addresses.py b/test/t/unit/test_unit_ip_addresses.py new file mode 100644 index 00000000..cd7a38ab --- /dev/null +++ b/test/t/unit/test_unit_ip_addresses.py @@ -0,0 +1,49 @@ +import pytest + +from conftest import assert_bash_exec, in_docker + + +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") +class TestUnitIpAddresses: + @pytest.fixture(scope="class") + def functions(self, request, bash): + assert_bash_exec( + bash, + "_ia() { local cur=$(_get_cword);unset COMPREPLY;" + "_ip_addresses; }", + ) + assert_bash_exec(bash, "complete -F _ia ia") + assert_bash_exec( + bash, + "_iaa() { local cur=$(_get_cword);unset COMPREPLY;" + "_ip_addresses -a; }", + ) + assert_bash_exec(bash, "complete -F _iaa iaa") + assert_bash_exec( + bash, + " _ia6() { local cur=$(_get_cword);unset COMPREPLY;" + "_ip_addresses -6; }", + ) + assert_bash_exec(bash, "complete -F _ia6 ia6") + + def test_1(self, bash): + assert_bash_exec(bash, "_ip_addresses") + + @pytest.mark.complete("iaa ") + def test_2(self, functions, completion): + """_ip_addresses -a should complete ip addresses.""" + assert completion + assert all("." in x or ":" in x for x in completion) + + @pytest.mark.complete("ia ") + def test_3(self, functions, completion): + """_ip_addresses should complete ipv4 addresses.""" + assert completion + assert all("." in x for x in completion) + + @pytest.mark.xfail(in_docker(), reason="Probably fails in docker") + @pytest.mark.complete("ia6 ") + def test_4(self, functions, completion): + """_ip_addresses -6 should complete ipv6 addresses.""" + assert completion + assert all(":" in x for x in completion) diff --git a/test/t/unit/test_unit_longopt.py b/test/t/unit/test_unit_longopt.py new file mode 100644 index 00000000..ac0ac836 --- /dev/null +++ b/test/t/unit/test_unit_longopt.py @@ -0,0 +1,34 @@ +# Based on work by Stephen Gildea, October 2010. + +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") +class TestUnitLongopt: + @pytest.fixture(scope="class") + def functions(self, request, bash): + assert_bash_exec(bash, "_grephelp() { cat _longopt/grep--help.txt; }") + assert_bash_exec(bash, "complete -F _longopt _grephelp") + + @pytest.mark.complete("_grephelp --") + def test_1(self, functions, completion): + """First long option should be included""" + assert completion + assert all( + x in completion for x in "--quiet --recursive --text".split() + ) + + @pytest.mark.complete("_grephelp -") + def test_2(self, functions, completion): + """Only long options should be included""" + assert completion + assert all(x.startswith("--") for x in completion) + + @pytest.mark.complete("_grephelp --") + def test_3(self, functions, completion): + """Should have both ones ending with a = and ones not""" + assert completion + assert any(x.endswith("=") for x in completion) + assert any(not x.endswith("=") for x in completion) diff --git a/test/t/unit/test_unit_parse_help.py b/test/t/unit/test_unit_parse_help.py new file mode 100644 index 00000000..4a02155b --- /dev/null +++ b/test/t/unit/test_unit_parse_help.py @@ -0,0 +1,183 @@ +# Based on work by Stephen Gildea, October 2010. + +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+declare -f fn$") +class TestUnitParseHelp: + def test_1(self, bash): + assert_bash_exec(bash, "fn() { echo; }") + output = assert_bash_exec(bash, "_parse_help fn") + assert not output + + def test_2(self, bash): + assert_bash_exec(bash, "fn() { echo 'no dashes here'; }") + output = assert_bash_exec(bash, "_parse_help fn") + assert not output + + def test_3(self, bash): + assert_bash_exec(bash, "fn() { echo 'internal-dash'; }") + output = assert_bash_exec(bash, "_parse_help fn") + assert not output + + def test_4(self, bash): + assert_bash_exec(bash, "fn() { echo 'no -leading-dashes'; }") + output = assert_bash_exec(bash, "_parse_help fn") + assert not output + + def test_5(self, bash): + assert_bash_exec(bash, "fn() { echo '-one dash'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "-one".split() + + def test_6(self, bash): + assert_bash_exec(bash, "fn() { echo ' -space dash'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "-space".split() + + def test_7(self, bash): + assert_bash_exec(bash, "fn() { echo '-one -two dashes'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "-one".split() + + def test_8(self, bash): + assert_bash_exec(bash, "fn() { echo '-one,-t dashes'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "-one".split() + + def test_9(self, bash): + assert_bash_exec(bash, "fn() { echo '-one dash-inside'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "-one".split() + + def test_10(self, bash): + """Test value not included in completion.""" + assert_bash_exec(bash, "fn() { echo '--long-arg=value'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--long-arg=".split() + + def test_11(self, bash): + """Test -value not seen as option.""" + assert_bash_exec(bash, "fn() { echo '--long-arg=-value'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--long-arg=".split() + + def test_12(self, bash): + assert_bash_exec(bash, "fn() { echo '--long-arg=-value,--opt2=val'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--long-arg=".split() + + def test_13(self, bash): + assert_bash_exec(bash, "fn() { echo '-m,--mirror'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--mirror".split() + + def test_14(self, bash): + assert_bash_exec(bash, "fn() { echo '-T/--upload-file'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--upload-file".split() + + def test_15(self, bash): + assert_bash_exec(bash, "fn() { echo '-T|--upload-file'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--upload-file".split() + + def test_16(self, bash): + assert_bash_exec(bash, "fn() { echo '-f, -F, --foo'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo".split() + + def test_17(self, bash): + assert_bash_exec(bash, "fn() { echo '--foo[=bar]'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo".split() + + def test_18(self, bash): + assert_bash_exec(bash, "fn() { echo '--foo=<bar>'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo=".split() + + def test_19(self, bash): + assert_bash_exec(bash, "fn() { echo '--foo={bar,quux}'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo=".split() + + def test_20(self, bash): + assert_bash_exec(bash, "fn() { echo '--[no]foo'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo --nofoo".split() + + def test_21(self, bash): + assert_bash_exec(bash, "fn() { echo '--[no-]bar[=quux]'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--bar --no-bar".split() + + def test_22(self, bash): + assert_bash_exec(bash, "fn() { echo '--[no-]bar=quux'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--bar= --no-bar=".split() + + def test_23(self, bash): + assert_bash_exec(bash, "fn() { echo '--[dont-]foo'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo --dont-foo".split() + + def test_24(self, bash): + assert_bash_exec(bash, "fn() { echo '-[dont]x --[dont]yy'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--yy --dontyy".split() + + def test_25(self, bash): + assert_bash_exec(bash, "fn() { echo '-f FOO, --foo=FOO'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo=".split() + + def test_26(self, bash): + assert_bash_exec(bash, "fn() { echo '-f [FOO], --foo[=FOO]'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo".split() + + def test_27(self, bash): + assert_bash_exec(bash, "fn() { echo '--foo.'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo".split() + + def test_28(self, bash): + assert_bash_exec(bash, "fn() { echo '-f or --foo'; }") + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--foo".split() + + def test_29(self, bash): + """Test parsing from stdin.""" + output = assert_bash_exec( + bash, "echo '-f or --foo' | _parse_help -", want_output=True + ) + assert output.split() == "--foo".split() + + def test_30(self, bash): + """More than two dashes should not be treated as options.""" + assert_bash_exec( + bash, r"fn() { printf '%s\n' $'----\n---foo\n----- bar'; }" + ) + output = assert_bash_exec(bash, "_parse_help fn") + assert not output + + def test_31(self, bash): + assert_bash_exec( + bash, + r"fn() { printf '%s\n' " + r"'-F ERROR_FORMAT, --error-format ERROR_FORMAT'; }", + ) + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--error-format".split() + + def test_32(self, bash): + assert_bash_exec( + bash, + r"fn() { printf '%s\n' " + r"'-e CODE1,CODE2.. --exclude=CODE1,CODE2..'; }", + ) + output = assert_bash_exec(bash, "_parse_help fn", want_output=True) + assert output.split() == "--exclude=".split() diff --git a/test/t/unit/test_unit_parse_usage.py b/test/t/unit/test_unit_parse_usage.py new file mode 100644 index 00000000..f0cb7114 --- /dev/null +++ b/test/t/unit/test_unit_parse_usage.py @@ -0,0 +1,69 @@ +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+declare -f fn$") +class TestUnitParseUsage: + def test_1(self, bash): + assert_bash_exec(bash, "fn() { echo; }") + output = assert_bash_exec(bash, "_parse_usage fn") + assert not output + + def test_2(self, bash): + assert_bash_exec(bash, "fn() { echo 'no dashes here'; }") + output = assert_bash_exec(bash, "_parse_usage fn") + assert not output + + def test_3(self, bash): + assert_bash_exec(bash, "fn() { echo 'foo [-f]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "-f".split() + + def test_4(self, bash): + assert_bash_exec(bash, "fn() { echo 'bar [-aBcD] [-e X]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "-a -B -c -D -e".split() + + def test_5(self, bash): + assert_bash_exec(bash, "fn() { echo '[-[XyZ]] [--long=arg]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "-X -y -Z --long=".split() + + def test_6(self, bash): + assert_bash_exec(bash, "fn() { echo '[-s|--long]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "--long".split() + + def test_7(self, bash): + assert_bash_exec(bash, "fn() { echo '[-s, --long=arg]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "--long=".split() + + def test_8(self, bash): + assert_bash_exec(bash, "fn() { echo '[--long/-s] [-S/--longer]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "--long --longer".split() + + def test_9(self, bash): + assert_bash_exec(bash, "fn() { echo '[ -a ] [ -b foo ]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "-a -b".split() + + def test_10(self, bash): + assert_bash_exec(bash, "fn() { echo '[ -a | --aa ]'; }") + output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) + assert output.split() == "--aa".split() + + def test_11(self, bash): + assert_bash_exec( + bash, "fn() { echo ----; echo ---foo; echo '----- bar'; }" + ) + output = assert_bash_exec(bash, "_parse_usage fn") + assert not output + + def test_12(self, bash): + output = assert_bash_exec( + bash, "echo '[-duh]' | _parse_usage -", want_output=True + ) + assert output.split() == "-d -u -h".split() diff --git a/test/t/unit/test_unit_tilde.py b/test/t/unit/test_unit_tilde.py new file mode 100644 index 00000000..35a4e4c6 --- /dev/null +++ b/test/t/unit/test_unit_tilde.py @@ -0,0 +1,42 @@ +import pytest + +from conftest import assert_bash_exec + + +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") +class TestUnitTilde: + def test_1(self, bash): + assert_bash_exec(bash, "_tilde >/dev/null") + + def test_2(self, bash): + """Test environment non-pollution, detected at teardown.""" + assert_bash_exec( + bash, 'foo() { local aa="~"; _tilde "$aa"; }; foo; unset foo' + ) + + def test_3(self, bash): + """Test for https://bugs.debian.org/766163""" + assert_bash_exec(bash, "_tilde ~-o") + + def _test_part_full(self, bash, part, full): + res = ( + assert_bash_exec( + bash, + '_tilde "~%s"; echo "${COMPREPLY[@]}"' % part, + want_output=True, + ) + .strip() + .split() + ) + assert res + assert res[0] == "~%s" % full + + def test_4(self, bash, part_full_user): + """~full should complete to ~full unmodified.""" + _, full = part_full_user + self._test_part_full(bash, full, full) + + def test_5(self, bash, part_full_user): + """~part should complete to ~full.""" + part, full = part_full_user + self._test_part_full(bash, part, full) |