|
6 | 6 |
|
7 | 7 | import pytest
|
8 | 8 |
|
9 |
| -from conftest import assert_bash_exec, assert_complete |
| 9 | +from conftest import assert_bash_exec, assert_complete, bash_env_saved |
10 | 10 |
|
11 | 11 |
|
12 | 12 | @pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=")
|
@@ -59,7 +59,9 @@ def utf8_ctype(self, bash):
|
59 | 59 | return lc_ctype
|
60 | 60 |
|
61 | 61 | def test_1(self, bash):
|
62 |
| - assert_bash_exec(bash, "_comp_compgen_filedir >/dev/null") |
| 62 | + with bash_env_saved(bash) as bash_env: |
| 63 | + bash_env.write_variable("cur", "") |
| 64 | + assert_bash_exec(bash, 'cur="" _comp_compgen_filedir >/dev/null') |
63 | 65 |
|
64 | 66 | @pytest.mark.parametrize("funcname", "f f2".split())
|
65 | 67 | def test_2(self, bash, functions, funcname):
|
@@ -233,3 +235,47 @@ def test_26(self, bash, functions, funcname):
|
233 | 235 | def test_27(self, bash, functions, funcname, utf8_ctype):
|
234 | 236 | completion = assert_complete(bash, "%s aé/" % funcname, cwd="_filedir")
|
235 | 237 | assert completion == "g"
|
| 238 | + |
| 239 | + @pytest.mark.parametrize("funcname", "f f2".split()) |
| 240 | + def test_28_dot_1(self, bash, functions, funcname): |
| 241 | + """Exclude . and .. when the completion is attempted for '.[TAB]'""" |
| 242 | + completion = assert_complete(bash, r"%s ." % funcname, cwd="_filedir") |
| 243 | + assert completion == [".dotfile1", ".dotfile2"] |
| 244 | + |
| 245 | + @pytest.mark.parametrize("funcname", "f f2".split()) |
| 246 | + def test_28_dot_2(self, bash, functions, funcname): |
| 247 | + """Exclude . and .. when the completion is attempted for 'dir/.[TAB]'""" |
| 248 | + completion = assert_complete(bash, r"%s _filedir/." % funcname) |
| 249 | + assert completion == [".dotfile1", ".dotfile2"] |
| 250 | + |
| 251 | + @pytest.mark.parametrize("funcname", "f f2".split()) |
| 252 | + def test_28_dot_3(self, bash, functions, funcname): |
| 253 | + """Include . when the completion is attempted for '..[TAB]'""" |
| 254 | + completion = assert_complete(bash, r"%s .." % funcname, cwd="_filedir") |
| 255 | + assert completion == "/" |
| 256 | + |
| 257 | + @pytest.mark.parametrize("funcname", "f f2".split()) |
| 258 | + def test_28_dot_4(self, bash, functions, funcname): |
| 259 | + """Include . when the completion is attempted for '..[TAB]'""" |
| 260 | + completion = assert_complete(bash, r"%s _filedir/.." % funcname) |
| 261 | + assert completion == "/" |
| 262 | + |
| 263 | + @pytest.mark.parametrize("funcname", "f f2".split()) |
| 264 | + def test_29_dotdot(self, bash, functions, funcname): |
| 265 | + """Complete files starting with "..". |
| 266 | +
|
| 267 | + These types of files are used by the go kubernetes atomic writer [0], |
| 268 | + and presumably other types of systems, and we want to make sure they |
| 269 | + will be completed correctly. |
| 270 | +
|
| 271 | + [0] https://pkg.go.dev/k8s.io/kubernetes/pkg/volume/util#AtomicWriter.Write |
| 272 | + """ |
| 273 | + completion = assert_complete( |
| 274 | + bash, r"%s .." % funcname, cwd="_filedir/dotdot/" |
| 275 | + ) |
| 276 | + assert completion == [ |
| 277 | + "../", |
| 278 | + "..2016_02_01_15_04_05.123456", |
| 279 | + "..data", |
| 280 | + "..folder/", |
| 281 | + ] |
0 commit comments