From 99500ff21a025c9381d1ea12cc0b22f08e4519e2 Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Thu, 28 Nov 2024 09:47:14 -0500 Subject: [PATCH 1/3] fix: make default search case insensitive when looking for files in the default patterns search, it's better to be flexible and not care about case sensitive matching. For example, certain frameworks output their test results with the word "test" in all upper case and we shouldn't need to specify both "test" and "TEST" to match those files. --- codecov_cli/helpers/folder_searcher.py | 10 ++++++++-- codecov_cli/services/upload/file_finder.py | 4 +++- tests/services/upload/test_coverage_file_finder.py | 8 +++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/codecov_cli/helpers/folder_searcher.py b/codecov_cli/helpers/folder_searcher.py index cc87238a..fcaac64c 100644 --- a/codecov_cli/helpers/folder_searcher.py +++ b/codecov_cli/helpers/folder_searcher.py @@ -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 @@ -100,4 +102,8 @@ 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)) + # return re.compile("|".join(regex_str)) + if case_sensitive: + return re.compile("|".join(regex_str)) + else: + return re.compile("|".join(regex_str), re.IGNORECASE) diff --git a/codecov_cli/services/upload/file_finder.py b/codecov_cli/services/upload/file_finder.py index 9c0a89cc..8af8cf28 100644 --- a/codecov_cli/services/upload/file_finder.py +++ b/codecov_cli/services/upload/file_finder.py @@ -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, diff --git a/tests/services/upload/test_coverage_file_finder.py b/tests/services/upload/test_coverage_file_finder.py index 201701c8..580da6f9 100644 --- a/tests/services/upload/test_coverage_file_finder.py +++ b/tests/services/upload/test_coverage_file_finder.py @@ -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", @@ -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() From 6c7c47bcdba36241c78134f603777b6ff860dea4 Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Thu, 28 Nov 2024 09:51:25 -0500 Subject: [PATCH 2/3] fix: typo i think this is meant to be remapIstanbul since that's the name of a JS coverage tool --- codecov_cli/services/upload/file_finder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov_cli/services/upload/file_finder.py b/codecov_cli/services/upload/file_finder.py index 8af8cf28..8e0de6d5 100644 --- a/codecov_cli/services/upload/file_finder.py +++ b/codecov_cli/services/upload/file_finder.py @@ -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", From a0fd1251e5eeb8c69f8a257f4e8d0dd592950fe8 Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Thu, 28 Nov 2024 11:06:44 -0500 Subject: [PATCH 3/3] fix: leftover commented out code --- codecov_cli/helpers/folder_searcher.py | 1 - 1 file changed, 1 deletion(-) diff --git a/codecov_cli/helpers/folder_searcher.py b/codecov_cli/helpers/folder_searcher.py index fcaac64c..e5b02b16 100644 --- a/codecov_cli/helpers/folder_searcher.py +++ b/codecov_cli/helpers/folder_searcher.py @@ -102,7 +102,6 @@ def globs_to_regex( 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: