From 30384dc6ab4d266cfef5bf1557491e4bd14723b5 Mon Sep 17 00:00:00 2001 From: Tom Hu <88201630+thomasrockhu-codecov@users.noreply.github.com> Date: Fri, 2 Aug 2024 19:13:53 +0300 Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"feat:=20disable=20search=20?= =?UTF-8?q?means=20don't=20search=20for=20explicitly=20mentio=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1478514b1203d1c3921ca60b767c4224d0c417e4. --- codecov_cli/helpers/folder_searcher.py | 2 +- codecov_cli/services/upload/file_finder.py | 9 +++++++++ tests/commands/test_process_test_results.py | 9 ++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/codecov_cli/helpers/folder_searcher.py b/codecov_cli/helpers/folder_searcher.py index 19e1be46..dc28a572 100644 --- a/codecov_cli/helpers/folder_searcher.py +++ b/codecov_cli/helpers/folder_searcher.py @@ -37,7 +37,7 @@ def search_files( filename_exclude_regex: typing.Optional[typing.Pattern] = None, multipart_include_regex: typing.Optional[typing.Pattern] = None, multipart_exclude_regex: typing.Optional[typing.Pattern] = None, - search_for_directories: bool = False + search_for_directories: bool = False, ) -> typing.Generator[pathlib.Path, None, None]: """ " Searches for files or directories in a given folder diff --git a/codecov_cli/services/upload/file_finder.py b/codecov_cli/services/upload/file_finder.py index f641f039..428beb58 100644 --- a/codecov_cli/services/upload/file_finder.py +++ b/codecov_cli/services/upload/file_finder.py @@ -226,8 +226,17 @@ def find_files(self) -> typing.List[UploadCollectionResultFile]: return list(set(result_files + user_result_files)) def get_user_specified_files(self, regex_patterns_to_exclude): + if self.disable_search: + result = [] + for file in self.explicitly_listed_files: + filepath = Path(file) + if filepath.exists(): + result.append(filepath) + return result + user_filenames_to_include = [] files_excluded_but_user_includes = [] + for file in self.explicitly_listed_files: user_filenames_to_include.append(file.name) if regex_patterns_to_exclude.match(file.name): diff --git a/tests/commands/test_process_test_results.py b/tests/commands/test_process_test_results.py index d0c62eb7..df3bf0ae 100644 --- a/tests/commands/test_process_test_results.py +++ b/tests/commands/test_process_test_results.py @@ -1,4 +1,3 @@ -import logging import os from click.testing import CliRunner @@ -11,7 +10,6 @@ def test_process_test_results( mocker, tmpdir, ): - tmp_file = tmpdir.mkdir("folder").join("summary.txt") mocker.patch.dict( @@ -44,7 +42,6 @@ def test_process_test_results( assert result.exit_code == 0 - mocked_post.assert_called_with( url="https://api.github.com/repos/fake/repo/issues/pull/comments", data={ @@ -58,7 +55,6 @@ def test_process_test_results( ) - def test_process_test_results_non_existent_file(mocker, tmpdir): tmp_file = tmpdir.mkdir("folder").join("summary.txt") @@ -93,7 +89,7 @@ def test_process_test_results_non_existent_file(mocker, tmpdir): assert result.exit_code == 1 expected_logs = [ "ci service found", - 'Some files were not found', + "No JUnit XML files were found", ] for log in expected_logs: assert log in result.output @@ -182,7 +178,6 @@ def test_process_test_results_missing_ref(mocker, tmpdir): assert log in result.output - def test_process_test_results_missing_step_summary(mocker, tmpdir): tmp_file = tmpdir.mkdir("folder").join("summary.txt") @@ -221,4 +216,4 @@ def test_process_test_results_missing_step_summary(mocker, tmpdir): "Error: Error getting step summary file path from environment. Can't find GITHUB_STEP_SUMMARY environment variable.", ] for log in expected_logs: - assert log in result.output \ No newline at end of file + assert log in result.output