Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make default search case insensitive #568

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions codecov_cli/helpers/folder_searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def search_files(
yield file_path


def globs_to_regex(patterns: List[str]) -> Optional[Pattern]:
def globs_to_regex(
patterns: List[str], case_sensitive: bool = True
) -> Optional[Pattern]:
"""
Converts a list of glob patterns to a combined ORed regex

Expand All @@ -100,4 +102,7 @@ def globs_to_regex(patterns: List[str]) -> Optional[Pattern]:
return None

regex_str = ["(" + translate(pattern) + ")" for pattern in patterns]
return re.compile("|".join(regex_str))
if case_sensitive:
return re.compile("|".join(regex_str))
else:
return re.compile("|".join(regex_str), re.IGNORECASE)
6 changes: 4 additions & 2 deletions codecov_cli/services/upload/file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"inputFiles.lst",
"phpunit-code-coverage.xml",
"phpunit-coverage.xml",
"remapInstanbul.coverage*.json",
"remapIstanbul.coverage*.json",
"scoverage.measurements.*",
"test_*_coverage.txt",
"test-result-*-codecoverage.json",
Expand Down Expand Up @@ -209,7 +209,9 @@ def find_files(self) -> List[UploadCollectionResultFile]:
if self.explicitly_listed_files:
user_files_paths = self.get_user_specified_files(regex_patterns_to_exclude)
if not self.disable_search:
regex_patterns_to_include = globs_to_regex(files_patterns)
regex_patterns_to_include = globs_to_regex(
files_patterns, case_sensitive=False
)
assert regex_patterns_to_include # this is never `None`
files_paths = search_files(
self.search_root,
Expand Down
8 changes: 7 additions & 1 deletion tests/services/upload/test_coverage_file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ def test_find_coverage_files_test_results(self, tmp_path):
(tmp_path / "sub" / "subsub").mkdir()
(tmp_path / "node_modules").mkdir()

should_find = ["junit.xml", "abc.junit.xml", "sub/junit.xml"]
should_find = [
"junit.xml",
"abc.junit.xml",
"sub/junit.xml",
"sub/TEST-something.xml",
]

should_ignore = [
"abc.codecov.exe",
Expand Down Expand Up @@ -330,6 +335,7 @@ def test_find_coverage_files_with_user_specified_files_not_found(
project_root / "coverage.xml",
project_root / "subdirectory" / "test_coverage.xml",
project_root / ".tox" / "another_file.abc",
project_root / ".tox" / "ANOTHER_FILE.abc",
]
(project_root / "subdirectory").mkdir()
(project_root / ".tox").mkdir()
Expand Down
Loading