Skip to content

Let debugged Go tests find their runfiles#3120

Closed
fmeum wants to merge 1 commit intobazelbuild:masterfrom
fmeum:2313-let-go-tests-find-runfiles
Closed

Let debugged Go tests find their runfiles#3120
fmeum wants to merge 1 commit intobazelbuild:masterfrom
fmeum:2313-let-go-tests-find-runfiles

Conversation

@fmeum
Copy link
Copy Markdown
Contributor

@fmeum fmeum commented Dec 20, 2021

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.

Discussion thread for this change

Issue number: #2313

Description of this change

Go runfiles discovery requires at least one of the runfiles variables
RUNFILES_DIR or RUNFILES_MANIFEST to be set. With the script path
experiment, which is enabled by default, only TEST_SRCDIR is currently
extracted from the script and passed to the test binary. As a result,
runfiles discovery fails on Windows (where a manifest is required) as
well as when following the official runfiles discovery process, which
does not include TEST_SRCDIR.

This is fixed by including all RUNFILES_* variables in the environment
used to start the test binary.

Go runfiles discovery requires at least one of the runfiles variables
RUNFILES_DIR or RUNFILES_MANIFEST to be set. With the script path
experiment, which is enabled by default, only TEST_SRCDIR is currently
extracted from the script and passed to the test binary. As a result,
runfiles discovery fails on Windows (where a manifest is required) as
well as when following the official runfiles discovery process, which
does not include TEST_SRCDIR.

This is fixed by including all RUNFILES_* variables in the environment
used to start the test binary.
@edwardotis
Copy link
Copy Markdown

Looks like this issue got fixed in another PR?
bazel-contrib/rules_go#3029
@fmeum Can you confirm?

@fmeum
Copy link
Copy Markdown
Contributor Author

fmeum commented Mar 30, 2022

Looks like this issue got fixed in another PR?
bazel-contrib/rules_go#3029
@fmeum Can you confirm?

No, this PR resolves a different issue: Tests run with debug symbols thanks to bazel-contrib/rules_go#3029, but they will still fail to find their runfiles. The latter is fixed by setting the runfiles environment variables.

@fmeum
Copy link
Copy Markdown
Contributor Author

fmeum commented Mar 30, 2022

@vsiva @alice-ks Friendly ping. This PR should be quick to review and is quite important for rules_go users.

@alice-ks
Copy link
Copy Markdown
Collaborator

Overall, this change looks good. I'll start the import of it.

Please note that without a test, this functionality might easily break in the future again. Hence, consider to add tests with future PRs.

@alice-ks alice-ks added the Ready to Import PR is ready to be imported to google branch. label Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to Import PR is ready to be imported to google branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants