2
2
3
3
import pytest
4
4
5
- from conftest import assert_bash_exec , assert_complete
5
+ from conftest import assert_bash_exec , assert_complete , bash_env_saved
6
6
7
7
LIVE_HOST = "bash_completion"
8
8
@@ -23,7 +23,7 @@ def test_basic(self, hosts, completion):
23
23
)
24
24
),
25
25
# Local filenames
26
- ["config" , "known_hosts" , r"spaced\ \ conf" ],
26
+ ["bin/" , " config" , "known_hosts" , r"spaced\ \ conf" ],
27
27
)
28
28
)
29
29
assert completion == expected
@@ -43,7 +43,7 @@ def test_basic_spaced_conf(self, hosts, completion):
43
43
)
44
44
),
45
45
# Local filenames
46
- ["config" , "known_hosts" , r"spaced\ \ conf" ],
46
+ ["bin/" , " config" , "known_hosts" , r"spaced\ \ conf" ],
47
47
)
48
48
)
49
49
assert completion == expected
@@ -101,3 +101,43 @@ def test_remote_path_with_spaces(self, bash):
101
101
completion = assert_complete (bash , "scp remote_host:spaces" )
102
102
assert_bash_exec (bash , "unset -f ssh" )
103
103
assert completion == r"\\\ in\\\ filename.txt"
104
+
105
+ def test_xfunc_remote_files (self , bash ):
106
+ with bash_env_saved (bash ) as bash_env :
107
+ bash_env .save_variable ("COMPREPLY" )
108
+ bash_env .write_variable (
109
+ "PATH" ,
110
+ "$PWD/scp/bin:$PATH" ,
111
+ quote = False ,
112
+ )
113
+ bash_env .write_variable ("cur" , "local:shared/default/" )
114
+ completions_regular_escape = (
115
+ assert_bash_exec (
116
+ bash ,
117
+ r'_comp_compgen -x scp remote_files; printf "%s\n" "${COMPREPLY[@]}"' ,
118
+ want_output = True ,
119
+ )
120
+ .strip ()
121
+ .splitlines ()
122
+ )
123
+ completions_less_escape = (
124
+ assert_bash_exec (
125
+ bash ,
126
+ r'_comp_compgen -x scp remote_files -l; printf "%s\n" "${COMPREPLY[@]}"' ,
127
+ want_output = True ,
128
+ )
129
+ .strip ()
130
+ .splitlines ()
131
+ )
132
+ assert completions_regular_escape == [
133
+ "shared/default/bar " ,
134
+ r"shared/default/bar\\\ bar.d/" ,
135
+ "shared/default/foo " ,
136
+ "shared/default/foo.d/" ,
137
+ ]
138
+ assert completions_less_escape == [
139
+ "shared/default/bar " ,
140
+ r"shared/default/bar\ bar.d/" ,
141
+ "shared/default/foo " ,
142
+ "shared/default/foo.d/" ,
143
+ ]
0 commit comments