summaryrefslogtreecommitdiffstats
path: root/test/t/test_man.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
commit6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch)
tree0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /test/t/test_man.py
parentReleasing progress-linux version 1:2.11-8~progress7.99u1. (diff)
downloadbash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz
bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/t/test_man.py')
-rw-r--r--test/t/test_man.py77
1 files changed, 60 insertions, 17 deletions
diff --git a/test/t/test_man.py b/test/t/test_man.py
index 1ff9f84..081b8fc 100644
--- a/test/t/test_man.py
+++ b/test/t/test_man.py
@@ -1,13 +1,17 @@
import pytest
-from conftest import assert_bash_exec
+from conftest import (
+ assert_bash_exec,
+ assert_complete,
+ is_bash_type,
+ prepare_fixture_dir,
+)
@pytest.mark.bashcomp(
- ignore_env=r"^[+-]((BASHOPTS|MANPATH)=|shopt -. failglob)"
+ ignore_env=r"^[+-]((BASHOPTS|MANPATH|manpath)=|shopt -. failglob)"
)
class TestMan:
-
manpath = "$PWD/man"
assumed_present = "man"
@@ -20,13 +24,12 @@ class TestMan:
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")
+ tmpdir, _, _ = prepare_fixture_dir(
+ request,
+ files=["man/man3/Bash::Completion.3pm.gz"],
+ dirs=["man", "man/man3"],
)
+ return tmpdir
@pytest.mark.complete(
"man bash-completion-testcas",
@@ -96,20 +99,60 @@ class TestMan:
"man %s" % assumed_present,
require_cmd=True,
cwd="shared/empty_dir",
- pre_cmds=("shopt -s failglob",),
+ shopt=dict(failglob=True),
)
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",
- require_cmd=True,
- env=dict(MANPATH="%s:../tmp/man" % manpath),
- )
- def test_10(self, bash, colonpath, completion):
+ def test_10(self, request, bash, colonpath):
+ if not is_bash_type(bash, "man"):
+ pytest.skip("Command not found")
+ completion = assert_complete(
+ bash,
+ "man Bash::C",
+ env=dict(MANPATH="%s:%s/man" % (TestMan.manpath, colonpath)),
+ )
assert completion == "ompletion"
@pytest.mark.complete("man -", require_cmd=True)
def test_11(self, completion):
assert completion
+
+ @pytest.mark.complete("man -S 1", require_cmd=True)
+ def test_delimited_first(self, completion):
+ # just appends space
+ assert not completion
+ assert completion.endswith(" ")
+
+ @pytest.mark.complete("man -S 1:", require_cmd=True)
+ def test_delimited_after_delimiter(self, completion):
+ assert completion
+ assert "1" not in completion
+
+ @pytest.mark.complete("man -S 1:2", require_cmd=True)
+ def test_delimited_later(self, completion):
+ # just appends space
+ assert not completion
+ assert completion.endswith(" ")
+
+ @pytest.mark.complete("man -S 1:1", require_cmd=True)
+ def test_delimited_deduplication(self, completion):
+ # no completion, no space appended
+ assert not completion
+ assert not completion.endswith(" ")
+
+ @pytest.mark.complete(
+ "man bash-completion-zstd-testcas",
+ env=dict(MANPATH=manpath),
+ require_cmd=True,
+ )
+ def test_zstd_arbitrary_sectsuffix(self, completion):
+ assert completion == "e"
+
+ @pytest.mark.complete(
+ "man bash-completion-testcas",
+ env=dict(MANPATH="'$(echo malicious code >/dev/tty)'"),
+ )
+ def test_manpath_code_injection(self, completion):
+ # no completion, no space appended
+ assert not completion