From 613ab7c47d5711cf450854a8f78073a7cf303c02 Mon Sep 17 00:00:00 2001 From: Enea Cortese <148778899+breachato@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:42:46 +0100 Subject: [PATCH 1/2] bvh_index: ask report_paths for the report-path guard The private same_output_path becomes an alias of report_paths.same_report_path, and the import keeps same_report_path on its own line: tests/test_report_paths.py looks for that exact line when the tool is added to SHARED. --- tools/bvh_index.py | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/tools/bvh_index.py b/tools/bvh_index.py index 272dfc016c..d9f454a639 100644 --- a/tools/bvh_index.py +++ b/tools/bvh_index.py @@ -38,12 +38,13 @@ import sys import tempfile import time -import unicodedata import zlib from contextlib import suppress sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from file_mode import published_mode # noqa: E402 +from report_paths import path_key # noqa: E402 +from report_paths import same_report_path # noqa: E402 ROOT = os.path.dirname(os.path.abspath(__file__)) if ROOT not in sys.path: @@ -473,45 +474,16 @@ def offset(text): return value -_PC_CASE_SENSITIVE = 11 # on macOS; os.pathconf_names doesn't list it - - -def _case_insensitive_volume(path): - """True when the volume that will hold `path` ignores letter case, as macOS's default APFS volume does. - os.path.normcase folds case only on Windows, so on macOS `R.json` and `r.json` would pass as two reports.""" - if sys.platform != "darwin": - return False - while not os.path.exists(path): - parent = os.path.dirname(path) - if parent == path: - break - path = parent - try: - return os.pathconf(path, _PC_CASE_SENSITIVE) == 0 - except (OSError, ValueError): - return True # the macOS default; folding can only refuse a pair, never overwrite one - - -def _path_key(path): - path = os.path.normcase(os.path.realpath(path)) - if _case_insensitive_volume(path): - # APFS and HFS+ also treat composed and decomposed accents as one name. - path = unicodedata.normalize("NFD", path.casefold()) - return path - - def same_output_path(first, second): - if _path_key(first) == _path_key(second): - return True - try: - return os.path.samefile(first, second) - except OSError: - return False + """True when writing ``second`` would truncate ``first``: one name (case-folded on a folding volume) or one + file through a hard link. `tools/report_paths.same_report_path` owns that answer; this keeps the name the rest + of the tool and `tests/test_report_path_case.py` call.""" + return same_report_path(first, second) def _inside(path, folder): """True when `path` is `folder` or lies below it, compared as the report check compares paths.""" - path, folder = _path_key(path), _path_key(folder) + path, folder = path_key(path), path_key(folder) try: return os.path.commonpath([path, folder]) == folder except ValueError: # different drives on Windows From 71f82c8a1c842b803d52295373244a4539be8f37 Mon Sep 17 00:00:00 2001 From: Enea Cortese <148778899+breachato@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:42:47 +0100 Subject: [PATCH 2/2] tests: list bvh_index in SHARED The reviewers' red test: with this entry on main, test_switched_tools_import_the_helper_and_define_no_copy fails with "'from report_paths import same_report_path' not found"; with this branch it passes. --- tests/test_report_paths.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_report_paths.py b/tests/test_report_paths.py index 5a22fe2cc5..0efd41c007 100644 --- a/tests/test_report_paths.py +++ b/tests/test_report_paths.py @@ -21,9 +21,9 @@ import report_paths # noqa: E402 # Tools that use report_paths and must not define their own copy again. -SHARED = ("anim_index", "awc_manifest", "bink_index", "gamedata_index", "gamedata_xml", "gen_d3d12_stubs", - "glb_inspect", "meshlet_page", "navmesh_index", "rpf_probe", "tile_probe", "world_index", - "world_lights_paths", "world_names") +SHARED = ("anim_index", "awc_manifest", "bink_index", "bvh_index", "gamedata_index", "gamedata_xml", + "gen_d3d12_stubs", "glb_inspect", "meshlet_page", "navmesh_index", "rpf_probe", "tile_probe", + "world_index", "world_lights_paths", "world_names") # The one tool that still carries its own copy (an open pull request edits its call site). Do not add to this list: # import report_paths instead. LEGACY_COPIES = {"navmesh_decode"}