Skip to content

Commit 701e002

Browse files
scopakinomyoga
andcommitted
feat(_filedir): add tests with _comp_compgen -C
Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
1 parent 7fba87c commit 701e002

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/t/unit/test_unit_filedir.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,22 @@ def functions(self, request, bash):
2424
"_g() { local cur;_comp_get_words cur; unset -v COMPREPLY; _comp_compgen_filedir e1; }; "
2525
"complete -F _g g",
2626
)
27+
assert_bash_exec(
28+
bash,
29+
"_fc() { local cur=$(_get_cword); unset -v COMPREPLY; _comp_compgen -C _filedir filedir; }; "
30+
"complete -F _fc fc; "
31+
"complete -F _fc -o filenames fc2",
32+
)
2733
assert_bash_exec(
2834
bash,
2935
"_fd() { local cur;_comp_get_words cur; unset -v COMPREPLY; _comp_compgen_filedir -d; };"
3036
"complete -F _fd fd",
3137
)
38+
assert_bash_exec(
39+
bash,
40+
"_fcd() { local cur=$(_get_cword); unset -v COMPREPLY; _comp_compgen -C _filedir filedir -d; };"
41+
"complete -F _fcd fcd",
42+
)
3243

3344
@pytest.fixture(scope="class")
3445
def non_windows_testdir(self, request, bash):
@@ -66,6 +77,11 @@ def test_2(self, bash, functions, funcname):
6677
completion = assert_complete(bash, "%s ab/" % funcname, cwd="_filedir")
6778
assert completion == "e"
6879

80+
@pytest.mark.parametrize("funcname", "fc fc2".split())
81+
def test_2C(self, bash, functions, funcname):
82+
completion = assert_complete(bash, "%s _filedir ab/" % funcname)
83+
assert completion == "e"
84+
6985
@pytest.mark.parametrize("funcname", "f f2".split())
7086
def test_3(self, bash, functions, funcname):
7187
completion = assert_complete(
@@ -154,6 +170,10 @@ def test_14(self, bash, functions, funcname):
154170
def test_15(self, functions, completion):
155171
assert completion == "b/"
156172

173+
@pytest.mark.complete(r"fcd a\ ")
174+
def test_15d(self, functions, completion):
175+
assert completion == "b/"
176+
157177
@pytest.mark.complete("g ", cwd="_filedir/ext")
158178
def test_16(self, functions, completion):
159179
assert completion == sorted("ee.e1 foo/ gg.e1 ii.E1".split())

0 commit comments

Comments
 (0)