Skip to content

Conversation

@timfallmk
Copy link

Summary

This PR fixes the gazelle_python_manifest.test failure on Linux CI by correcting the runfiles path handling in both the Bazel rule definition and the Go test code.

Fixes #3397

Problem

The test was failing on Linux but passing on macOS due to inconsistent file path handling:

  • Used $(rootpath) instead of $(rlocationpath) in the Bazel rule
  • Resolved runfiles paths but then didn't use the resolved values

See issue #3397 for full technical details.

Changes

gazelle/manifest/defs.bzl

  • Line 120: Changed $(rootpath) to $(rlocationpath) for _TEST_MANIFEST
  • Line 122: Changed $(rootpath) to $(rlocationpath) for _TEST_REQUIREMENTS

This makes them consistent with the existing _TEST_MANIFEST_GENERATOR_HASH which already used $(rlocationpath).

gazelle/manifest/test/test.go

  • Line 53: Use manifestPathResolved instead of manifestPath in manifestFile.Decode()
  • Line 73: Use requirementsPathResolved instead of requirementsPath in os.Open()
  • Lines 84-86: Use manifestPathResolved instead of manifestPath in error handling

The test was already calling runfiles.Rlocation() to resolve the paths, but then wasn't using the resolved values.

Testing

Tested on Linux by running:

cd gazelle/examples/bzlmod_build_file_generation
bazel test //:gazelle_python_manifest.test

Result: ✅ PASSED

Notes

  • This fix aligns with Bazel's recommended runfiles handling practices
  • All changes follow the existing pattern used for _TEST_MANIFEST_GENERATOR_HASH
  • Some code generation was assisted by Claude AI, but the human author has reviewed, tested, and takes full responsibility for all changes per the contribution guidelines

Disclaimer: This is my first contribution to this project, so I'm not entirely certain this is the correct contribution method. Please let me know if any changes to the PR process are needed. Happy to make adjustments!

…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 bazel-contrib#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
Copy link
Contributor

Summary of Changes

Hello @timfallmk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a persistent failure of the gazelle_python_manifest.test on Linux CI environments. The issue stemmed from an inconsistency in how runfiles paths were handled, specifically using $(rootpath) instead of the correct $(rlocationpath) in the Bazel rule definition and failing to utilize the resolved paths within the Go test code. By aligning the path resolution mechanisms, the test now passes reliably across different operating systems, ensuring robust CI checks.

Highlights

  • Test Failure Fix: Resolves a persistent failure of the gazelle_python_manifest.test on Linux CI environments, which was passing on macOS.
  • Bazel Rule Path Correction: Corrects the Bazel rule definition in gazelle/manifest/defs.bzl by changing $(rootpath) to $(rlocationpath) for _TEST_MANIFEST and _TEST_REQUIREMENTS environment variables, aligning with recommended runfiles handling.
  • Go Test Path Usage: Updates the Go test code in gazelle/manifest/test/test.go to consistently use the already resolved runfiles paths (manifestPathResolved and requirementsPathResolved) after calling runfiles.Rlocation(), which was previously resolving paths but not using the resolved values.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a runfiles path handling issue in the gazelle_python_manifest test by switching from $(rootpath) to $(rlocationpath) in the Bazel rule and using the resolved runfile paths in the Go test. The changes look good and address the problem described. I've added a suggestion to refactor some duplicated logic in the Go test to improve maintainability.

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: bazel-contrib#3398 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix gazelle_python_manifest test failure on Linux due to incorrect runfiles path handling

2 participants