Skip to content

Commit

Permalink
test(_filedir): Test files that start with ".."
Browse files Browse the repository at this point in the history
These types of files are used by the go kubernetes atomic writer [0],
and presumably other types of systems, and we want to make sure they
will be completed correctly.

[0] https://pkg.go.dev/k8s.io/kubernetes/pkg/volume/util#AtomicWriter.Write
  • Loading branch information
yedayak committed Nov 2, 2024
1 parent eaa9bca commit 0f03abd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
Empty file.
1 change: 1 addition & 0 deletions test/fixtures/_filedir/dotdot/..data
Empty file.
20 changes: 20 additions & 0 deletions test/t/unit/test_unit_compgen_filedir.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,23 @@ def test_28_dot_4(self, bash, functions, funcname):
"""Include . when the completion is attempted for '..[TAB]'"""
completion = assert_complete(bash, r"%s _filedir/.." % funcname)
assert completion == "/"

@pytest.mark.parametrize("funcname", "f f2".split())
def test_29_dotdot(self, bash, functions, funcname):
"""Complete files starting with "..".
These types of files are used by the go kubernetes atomic writer [0],
and presumably other types of systems, and we want to make sure they
will be completed correctly.
[0] https://pkg.go.dev/k8s.io/kubernetes/pkg/volume/util#AtomicWriter.Write
"""
completion = assert_complete(
bash, r"%s .." % funcname, cwd="_filedir/dotdot/"
)
assert completion == [
"../",
"..2016_02_01_15_04_05.123456",
"..data",
"..folder/",
]
5 changes: 4 additions & 1 deletion test/t/unit/test_unit_expand_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def functions(self, bash):

def test_match_all(self, bash, functions):
output = assert_bash_exec(bash, "__tester '*'", want_output=True)
assert output.strip() == "<a b><a$b><a&b><a'b><ab><aé><brackets><ext>"
assert (
output.strip()
== "<a b><a$b><a&b><a'b><ab><aé><brackets><dotdot><ext>"
)

def test_match_pattern(self, bash, functions):
output = assert_bash_exec(bash, "__tester 'a*'", want_output=True)
Expand Down

0 comments on commit 0f03abd

Please sign in to comment.