Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Incompatible Target Skipping for test args #13219

Conversation

philsc
Copy link
Contributor

@philsc philsc commented Mar 14, 2021

Before the fix, the test in this patch would error out with the
following message:

ERROR: ...: in args attribute of sh_test rule //target_skipping:foo_test: label '//target_skipping:some_foo3_target' in $(location) expression expands to no files

The problem was that the RunfilesSupport class for the
RunfilesProvider instance was computing the arguments as the
incompatible target was being constructed. That meant that the
arguments get evaluated and it would try to resolve things like
$(location :incompatible_dep). That can't really succeed so bazel
would throw an error.

This patch makes it so arguments are ignored when constructing an
incompatible target.

@google-cla google-cla bot added the cla: yes label Mar 14, 2021
@philsc
Copy link
Contributor Author

philsc commented Mar 14, 2021

@gregestren , FYI.

Copy link
Contributor

@gregestren gregestren left a comment

Choose a reason for hiding this comment

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

Nice catch! Overall looks great. Just one quick comment request.

@@ -453,6 +453,20 @@ public static RunfilesSupport withExecutable(
computeActionEnvironment(ruleContext));
}

/**
* Creates and returns a {@link RunfilesSupport} object for the given rule and executable. This
* version discards all arguments. Only use this for Incompatible Target Skipping.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you link this more precisely to a specific file or source javadoc?

This comment comes from the hard-learned lesson that even specific concepts can be fuzzy to devs who haven't focused specifically on them. Precise links are always great for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't verify that the link renders correctly, but I added a link to https://docs.bazel.build/versions/master/platforms.html#skipping-incompatible-targets

Would you prefer a link to the site/docs/platforms.md file instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine, thanks. Just anything to connect the breadcrumbs.

Before the fix the test in this patch would error out with the
following message:

    ERROR: ...: in args attribute of sh_test rule //target_skipping:foo_test: label '//target_skipping:some_foo3_target' in $(location) expression expands to no files

The problem was that the `RunfilesSupport` class for the
`RunfilesProvider` instance was computing the arguments as the
incompatible target was being constructed. That meant that the
arguments get evaluated and it would try to resolve things like
`$(location :incompatible_dep)`. That can't really succeed so bazel
would throw an error.

This patch makes it so arguments are ignored when constructing an
incompatible target.
@philsc philsc force-pushed the unreviewed/incompatible_in_args-publish branch from 3d0f99d to ea86bf5 Compare March 16, 2021 03:27
@bazel-io bazel-io closed this in 807f2a1 Mar 16, 2021
@philsc philsc deleted the unreviewed/incompatible_in_args-publish branch March 17, 2021 21:27
philwo pushed a commit that referenced this pull request Apr 19, 2021
Before the fix, the test in this patch would error out with the
following message:

    ERROR: ...: in args attribute of sh_test rule //target_skipping:foo_test: label '//target_skipping:some_foo3_target' in $(location) expression expands to no files

The problem was that the `RunfilesSupport` class for the
`RunfilesProvider` instance was computing the arguments as the
incompatible target was being constructed. That meant that the
arguments get evaluated and it would try to resolve things like
`$(location :incompatible_dep)`. That can't really succeed so bazel
would throw an error.

This patch makes it so arguments are ignored when constructing an
incompatible target.

Closes #13219.

PiperOrigin-RevId: 363233765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants