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

Add a test for ambiguous paths that can't be resolved #847

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
22 changes: 22 additions & 0 deletions services/path_fixer/tests/unit/test_path_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,25 @@ def test_basepath_uses_own_result_if_main_is_none_multuple_base_paths(self):
base_aware_pf("__init__.py", bases_to_try=["/home/travis/build/project"])
== "project/__init__.py"
)


def test_ambiguous_paths():
toc = [
"foobar/bar/baz.py",
"barfoo/bar/baz.py",
]
base_path = "/home/runner/work/owner/repo/foobar/build/coverage/coverage.xml"
# ~~~~~~
bases_to_try = ["/app"]
# The problem here is that the given `file_name` is ambiguous, and neither the
# `base_path` nor the `bases_to_try` is helping us narrow this down.
# The `base_path` does include one of the relevant parent directories,
# but the paths within the coverage file are not relative to *that* file,
# and the `bases_to_try` seem to be completely unrelated.
file_name = "bar/baz.py"

pf = PathFixer.init_from_user_yaml({}, toc, [])
base_aware_pf = pf.get_relative_path_aware_pathfixer(base_path)

assert pf(file_name) is None
assert base_aware_pf(file_name, bases_to_try=bases_to_try) is None
Loading