summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-17 14:57:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-17 14:57:17 +0000
commit8c80e4dce14eed4e3c06b16fc307c6c7d20b9af8 (patch)
tree4477eaed15415ddadc3e88205234659628759415 /test
parentReleasing progress-linux version 1:2.13.0-1~progress7.99u1. (diff)
downloadbash-completion-8c80e4dce14eed4e3c06b16fc307c6c7d20b9af8.tar.xz
bash-completion-8c80e4dce14eed4e3c06b16fc307c6c7d20b9af8.zip
Merging upstream version 1:2.14.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test')
-rw-r--r--test/requirements-dev.txt2
-rw-r--r--test/t/conftest.py4
-rw-r--r--test/t/test_env.py37
-rw-r--r--test/t/test_fio.py2
-rw-r--r--test/t/test_ssh_keygen.py26
-rw-r--r--test/t/unit/test_unit_compgen_available_interfaces.py2
-rw-r--r--test/t/unit/test_unit_load.py3
-rw-r--r--test/t/unit/test_unit_realcommand.py8
8 files changed, 74 insertions, 10 deletions
diff --git a/test/requirements-dev.txt b/test/requirements-dev.txt
index 68655c4..ed51d1c 100644
--- a/test/requirements-dev.txt
+++ b/test/requirements-dev.txt
@@ -3,4 +3,4 @@
-r requirements.txt
mypy==1.8.0
-ruff==0.3.5
+ruff==0.4.3
diff --git a/test/t/conftest.py b/test/t/conftest.py
index cb279cc..2ca0f9a 100644
--- a/test/t/conftest.py
+++ b/test/t/conftest.py
@@ -381,8 +381,8 @@ def load_completion_for(bash: pexpect.spawn, cmd: str) -> bool:
try:
# Allow _comp_load to fail so we can test completions
# that are directly loaded in bash_completion without a separate file.
- assert_bash_exec(bash, "_comp_load %s || :" % cmd)
- assert_bash_exec(bash, "complete -p %s &>/dev/null" % cmd)
+ assert_bash_exec(bash, "_comp_load -- %s || :" % cmd)
+ assert_bash_exec(bash, "complete -p -- %s &>/dev/null" % cmd)
except AssertionError:
return False
return True
diff --git a/test/t/test_env.py b/test/t/test_env.py
index 3d1a684..7608a4b 100644
--- a/test/t/test_env.py
+++ b/test/t/test_env.py
@@ -1,7 +1,44 @@
import pytest
+from conftest import assert_complete
+
class TestEnv:
@pytest.mark.complete("env --", require_longopt=True)
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("env __unknown_variable__=")
+ def test_unknown_variable_falls_back_to_filedir(self, completion):
+ assert "shared/" in completion
+
+ @pytest.mark.complete("env LANG=", xfail="! locale -a &>/dev/null")
+ def test_lang_envvar(self, completion):
+ assert any(x == "C" or x.startswith("C.") for x in completion)
+
+ @pytest.mark.parametrize(
+ "opts",
+ [
+ "",
+ "foo=bar",
+ "--debug",
+ "--debug foo=bar",
+ "-",
+ "- foo=bar",
+ ],
+ )
+ def test_command(self, bash, opts):
+ completion = assert_complete(bash, "env %s s" % opts)
+ assert completion == "h" or "sh" in completion
+
+ @pytest.mark.parametrize(
+ "opts",
+ [
+ "foo=bar --non-existent",
+ "- --non-existent",
+ "-- --non-existent",
+ ],
+ )
+ def test_option_like_command(self, bash, opts):
+ completion = assert_complete(bash, "env %s s" % opts)
+ assert not (completion == "h" or "sh" in completion)
diff --git a/test/t/test_fio.py b/test/t/test_fio.py
index dadb5ac..75b9046 100644
--- a/test/t/test_fio.py
+++ b/test/t/test_fio.py
@@ -23,6 +23,8 @@ class TestFio:
def test_enghelp(self, completion):
"""Test --enghelp parsing."""
assert completion
+ assert all(x == x.strip() for x in completion)
+ assert all(")" not in x for x in completion)
@pytest.mark.complete("fio --unlink=", require_cmd=True)
def test_cmdhelp_boolean(self, completion):
diff --git a/test/t/test_ssh_keygen.py b/test/t/test_ssh_keygen.py
index cc6ff4e..6e9953c 100644
--- a/test/t/test_ssh_keygen.py
+++ b/test/t/test_ssh_keygen.py
@@ -55,11 +55,15 @@ class TestSshKeygen:
assert not completion
@pytest.mark.complete("ssh-keygen -O ")
- def test_O(self, completion):
+ def test_bare_O(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("ssh-keygen -s -O ")
+ def test_s_O(self, completion):
assert completion
assert any(x.endswith("=") for x in completion)
- @pytest.mark.complete("ssh-keygen -O force-command=bas")
+ @pytest.mark.complete("ssh-keygen -s -O force-command=bas")
def test_O_force_command(self, completion):
assert completion
assert not completion.startswith("force-command=")
@@ -68,18 +72,28 @@ class TestSshKeygen:
def test_O_unknown(self, completion):
assert not completion
- @pytest.mark.complete("ssh-keygen -O application=")
+ @pytest.mark.complete("ssh-keygen -t ed25519-sk -O application=")
def test_O_application(self, completion):
assert completion == "ssh:"
- @pytest.mark.complete("ssh-keygen -O application=s")
+ @pytest.mark.complete("ssh-keygen -t ed25519-sk -O application=s")
def test_O_application_s(self, completion):
assert completion == "sh:"
- @pytest.mark.complete("ssh-keygen -O application=ssh:")
+ @pytest.mark.complete("ssh-keygen -t ed25519-sk -O application=ssh:")
def test_O_application_ssh_colon(self, completion):
assert not completion
- @pytest.mark.complete("ssh-keygen -O application=nonexistent")
+ @pytest.mark.complete(
+ "ssh-keygen -t ed25519-sk -O application=nonexistent"
+ )
def test_O_application_nonexistent(self, completion):
assert not completion
+
+ @pytest.mark.complete("ssh-keygen -r -O ")
+ def test_r_O(self, completion):
+ assert completion
+
+ @pytest.mark.complete("ssh-keygen -Y -O ")
+ def test_Y_O(self, completion):
+ assert completion
diff --git a/test/t/unit/test_unit_compgen_available_interfaces.py b/test/t/unit/test_unit_compgen_available_interfaces.py
index 5e93100..f3ebac0 100644
--- a/test/t/unit/test_unit_compgen_available_interfaces.py
+++ b/test/t/unit/test_unit_compgen_available_interfaces.py
@@ -22,4 +22,4 @@ class TestUtilCompgenAvailableInterfaces:
"_comp__test_compgen available_interfaces",
want_output=True,
)
- assert ":" not in output.strip()
+ assert ":>" not in output.strip()
diff --git a/test/t/unit/test_unit_load.py b/test/t/unit/test_unit_load.py
index 3515703..5513041 100644
--- a/test/t/unit/test_unit_load.py
+++ b/test/t/unit/test_unit_load.py
@@ -128,3 +128,6 @@ class TestCompLoad:
# The in-tree `sh` completion should be loaded here,
# and cause no output, unlike our `$PWD/prefix1/bin/sh` canary.
assert_bash_exec(bash, "_comp_load sh", want_output=False)
+
+ def test_option_like_cmd_name(self, bash):
+ assert_bash_exec(bash, "! _comp_load -- --non-existent")
diff --git a/test/t/unit/test_unit_realcommand.py b/test/t/unit/test_unit_realcommand.py
index 4eb7b73..a057788 100644
--- a/test/t/unit/test_unit_realcommand.py
+++ b/test/t/unit/test_unit_realcommand.py
@@ -88,3 +88,11 @@ class TestUnitRealCommand:
want_output=False,
)
assert output.strip() == ""
+
+ def test_option_like_cmd_name(self, bash, functions):
+ output = assert_bash_exec(
+ bash,
+ "! __tester --non-existent",
+ want_output=False,
+ )
+ assert output.strip() == ""