fix(gazelle): correct runfiles path handling in gazelle_python_manifest test by timfallmk · Pull Request #3398 · bazel-contrib/rules_python

@timfallmk

…st test

The gazelle_python_manifest test was failing on Linux but passing on macOS
due to incorrect file path handling. The test used $(rootpath) instead of
$(rlocationpath) for data files and didn't use the resolved runfiles paths
returned by runfiles.Rlocation().

Changes:
- Update defs.bzl to use $(rlocationpath) for _TEST_MANIFEST and
  _TEST_REQUIREMENTS environment variables (matching the existing pattern
  for _TEST_MANIFEST_GENERATOR_HASH)
- Fix test.go to use the resolved paths from runfiles.Rlocation() instead
  of the unresolved paths at lines 53, 73, and 84-86

This ensures the test works consistently across all platforms by properly
using the Bazel runfiles mechanism.

Fixes #3397

Note: Some code generation was assisted by Claude AI. The human author has
reviewed, tested, and takes full responsibility for all changes.

gemini-code-assist[bot]

@timfallmk

Address code review feedback from Gemini Code Assist bot by creating a
getResolvedRunfile helper function. This reduces code duplication and
improves error messages by consolidating the logic for:
- Getting environment variable values
- Validating they are set
- Resolving paths through runfiles.Rlocation()

Applied the helper to all three environment variables:
- _TEST_REQUIREMENTS
- _TEST_MANIFEST
- _TEST_MANIFEST_GENERATOR_HASH

This reduces ~20 lines of duplicated code to 3 function calls and
provides more specific error messages that include the env var name
and unresolved path.

Addresses: #3398 (comment)

@timfallmk

…-plugin-requirements-data-paths

aignas

@timfallmk

@timfallmk timfallmk deleted the tfall/fix-rules-python-gazelle-plugin-requirements-data-paths branch

November 12, 2025 17:30