Skip to content

Commit

Permalink
Add a test for ambiguous paths that can't be resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Nov 4, 2024
1 parent 8fec23c commit ec70a35
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit ec70a35

Please sign in to comment.