5
5
from conftest import assert_bash_exec , assert_complete , bash_env_saved
6
6
7
7
8
- @pytest .mark .bashcomp (cmd = None , temp_cwd = True )
8
+ @pytest .mark .bashcomp (
9
+ cmd = None ,
10
+ temp_cwd = True ,
11
+ ignore_env = r"^\+declare -f _comp_test_quote_compgen$" ,
12
+ )
9
13
class TestUnitQuoteCompgen :
10
- def test_exec (self , bash ):
11
- assert_bash_exec (bash , "quote_readline '' >/dev/null" )
14
+ @pytest .fixture (scope = "class" )
15
+ def functions (self , bash ):
16
+ assert_bash_exec (
17
+ bash ,
18
+ '_comp_test_quote_compgen() { local ret; _comp_quote_compgen "$1"; printf %s "$ret"; }' ,
19
+ )
20
+
21
+ def test_exec (self , bash , functions ):
22
+ assert_bash_exec (bash , "_comp_test_quote_compgen '' >/dev/null" )
12
23
13
- def test_env_non_pollution (self , bash ):
24
+ def test_env_non_pollution (self , bash , functions ):
14
25
"""Test environment non-pollution, detected at teardown."""
15
26
assert_bash_exec (
16
- bash , "foo() { quote_readline meh >/dev/null; }; foo; unset -f foo"
27
+ bash ,
28
+ "foo() { _comp_test_quote_compgen meh >/dev/null; }; foo; unset -f foo" ,
17
29
)
18
30
19
- def test_github_issue_189_1 (self , bash ):
31
+ def test_github_issue_189_1 (self , bash , functions ):
20
32
"""Test error messages on a certain command line
21
33
22
34
Reported at https://github.com/scop/bash-completion/issues/189
@@ -28,9 +40,9 @@ def test_github_issue_189_1(self, bash):
28
40
$ rm -- '${[TAB]
29
41
30
42
"""
31
- assert_bash_exec (bash , "quote_readline $'\\ '${' >/dev/null" )
43
+ assert_bash_exec (bash , "_comp_test_quote_compgen $'\\ '${' >/dev/null" )
32
44
33
- def test_github_issue_492_1 (self , bash ):
45
+ def test_github_issue_492_1 (self , bash , functions ):
34
46
"""Test unintended code execution on a certain command line
35
47
36
48
Reported at https://github.com/scop/bash-completion/pull/492
@@ -44,11 +56,11 @@ def test_github_issue_492_1(self, bash):
44
56
45
57
"""
46
58
assert_bash_exec (
47
- bash , "quote_readline $'\\ '$(touch 1.txt)' >/dev/null"
59
+ bash , "_comp_test_quote_compgen $'\\ '$(touch 1.txt)' >/dev/null"
48
60
)
49
61
assert not os .path .exists ("./1.txt" )
50
62
51
- def test_github_issue_492_2 (self , bash ):
63
+ def test_github_issue_492_2 (self , bash , functions ):
52
64
"""Test the file clear by unintended redirection on a certain command line
53
65
54
66
Reported at https://github.com/scop/bash-completion/pull/492
@@ -59,23 +71,25 @@ def test_github_issue_492_2(self, bash):
59
71
$ awk '$1 > 1.0[TAB]
60
72
61
73
"""
62
- assert_bash_exec (bash , "quote_readline $'\\ '$1 > 1.0' >/dev/null" )
74
+ assert_bash_exec (
75
+ bash , "_comp_test_quote_compgen $'\\ '$1 > 1.0' >/dev/null"
76
+ )
63
77
assert not os .path .exists ("./1.0" )
64
78
65
- def test_github_issue_492_3 (self , bash ):
79
+ def test_github_issue_492_3 (self , bash , functions ):
66
80
"""Test code execution through unintended pathname expansions
67
81
68
82
When there is a file named "quote=$(COMMAND)" (for _filedir) or
69
- "ret=$(COMMAND)" (for quote_readline ), the completion of the word '$*
70
- results in the execution of COMMAND.
83
+ "ret=$(COMMAND)" (for _comp_quote_compgen ), the completion of the word
84
+ '$* results in the execution of COMMAND.
71
85
72
86
$ echo '$*[TAB]
73
87
74
88
"""
75
89
os .mkdir ("./ret=$(echo injected >&2)" )
76
- assert_bash_exec (bash , "quote_readline $'\\ '$*' >/dev/null" )
90
+ assert_bash_exec (bash , "_comp_test_quote_compgen $'\\ '$*' >/dev/null" )
77
91
78
- def test_github_issue_492_4 (self , bash ):
92
+ def test_github_issue_492_4 (self , bash , functions ):
79
93
"""Test error messages through unintended pathname expansions
80
94
81
95
When "shopt -s failglob" is set by the user, the completion of the word
@@ -88,7 +102,9 @@ def test_github_issue_492_4(self, bash):
88
102
"""
89
103
with bash_env_saved (bash ) as bash_env :
90
104
bash_env .shopt ("failglob" , True )
91
- assert_bash_exec (bash , "quote_readline $'a\\ \\ \\ tb*' >/dev/null" )
105
+ assert_bash_exec (
106
+ bash , "_comp_test_quote_compgen $'a\\ \\ \\ tb*' >/dev/null"
107
+ )
92
108
93
109
def test_github_issue_526_1 (self , bash ):
94
110
r"""Regression tests for unprocessed escape sequences after quotes
0 commit comments