Skip to content

Commit

Permalink
fix: allow for .. explicit file search (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov authored May 7, 2024
1 parent 3c2bac8 commit 4de8fc2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion codecov_cli/services/upload/file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ def get_user_specified_files(self, regex_patterns_to_exclude):
user_files_paths_resolved = [path.resolve() for path in user_files_paths]
for filepath in self.explicitly_listed_files:
if filepath.resolve() not in user_files_paths_resolved:
not_found_files.append(filepath)
## The file given might be linked or in a parent dir, check to see if it exists
if filepath.exists():
user_files_paths.append(filepath)
else:
not_found_files.append(filepath)

if not_found_files:
logger.warning(
Expand Down
23 changes: 23 additions & 0 deletions tests/services/upload/test_coverage_file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,29 @@ def test_find_coverage_files_with_existing_files(
expected_paths = sorted([file.get_filename() for file in expected])
assert result == expected_paths

def test_find_coverage_files_with_file_in_parent(
self, coverage_file_finder_fixture
):
# Create some sample coverage coverage_file_finder_fixture
(
project_root,
coverage_file_finder,
) = coverage_file_finder_fixture
coverage_files = [
project_root.parent / "coverage.xml",
]
for file in coverage_files:
file.touch()

coverage_file_finder.explicitly_listed_files = [project_root.parent / "coverage.xml"]

result = sorted(
[file.get_filename() for file in coverage_file_finder.find_files()]
)
expected = [UploadCollectionResultFile(Path(f"{project_root.parent}/coverage.xml"))]
expected_paths = sorted([file.get_filename() for file in expected])
assert result == expected_paths

def test_find_coverage_files_with_no_files(self, coverage_file_finder_fixture):
(
_,
Expand Down

0 comments on commit 4de8fc2

Please sign in to comment.