Skip to content

Commit

Permalink
add a regression test for git ls-files parsing
Browse files Browse the repository at this point in the history
This commit adds a regression test to ensure
that file-names starting with a tab-character
are properly parsed from the output of
`git ls-files`.

The test instantiates PurePosixPath-instances
to check against names in the output of
`iter_gitworktree`, because `iter_gitworktree`
explicitly creates PurePosixPath-instances in
the function `_lsfiles_line2props`.
  • Loading branch information
christian-monch committed Jun 15, 2023
1 parent da874de commit a6822fd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion datalad_next/iter_collections/tests/test_itergitworktree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from pathlib import PurePath
from pathlib import (
PurePath,
PurePosixPath,
)
from ..gitworktree import (
GitWorktreeItem,
GitWorktreeFileSystemItem,
Expand Down Expand Up @@ -72,3 +75,14 @@ def test_iter_gitworktree(existing_dataset):
checked_untracked = True
assert checked_tracked
assert checked_untracked


def test_name_starting_with_tab(existing_dataset):
ds = existing_dataset
tabbed_file_name = "\ttab.txt"
tabbed_name = ds.pathobj / tabbed_file_name
tabbed_name.write_text('name of this file starts with a tab')
ds.save()

iter_names = [item.name for item in iter_gitworktree(ds.pathobj)]
assert PurePosixPath(tabbed_file_name) in iter_names

0 comments on commit a6822fd

Please sign in to comment.