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

feat(bazel): allow integration commands to resolve executables through expansion #285

Conversation

devversion
Copy link
Member

@devversion devversion commented Nov 6, 2021

Given a tool built using nodejs_binary or sh_binary, the tool cannot
be used as binary in an integration test command currently because:

  • Bazel location expansion does not respect the executable "FilesToRun"
    information of the binaries, and rather sees all outputs, erroring
    that $(locations X) need to be used instead. See e.g. sh_binary has multiple outputs in some contexts bazelbuild/bazel#11820)

  • The command is currently split by space and this decouples the Make
    funtion expression incorrectly into a broken expansion. e.g.
    $(rootpath X) will become ["$(rootpath", "X"]).

This commit fixes both things by relying on the Bazel
CommandHelper.java class which handles the expansion of commands as
expected, with similar semantics of a genrule as per GenRuleBase.java.

This allows test authors to conveniently use a nodejs_binary or
sh_binary as command binary because the CommandHelper knows
exactly which targets provide executables or not. There is no good API
for the plain Make expansion of a command itself, so we use a little trick
(which is documented sufficiently in the code).

…h expansion

Gives a tool built using `nodejs_binary` or `sh_binary`, the tool cannot
be used as binary in an integration test command currently because:

* Bazel location expansion does not respect the executable "FilesToRun"
  information of the binaries, and rather sees _all_ outputs, erroring
  that `$(locations X)` need to be used instead. See e.g. bazelbuild/bazel#11820)

* The command is currently split by space and this decouples the Make
  funtion expression incorrectly into a broken expansion. e.g.
  `$(rootpath X)` will become `["$(rootpath", "X"]`).

This commit fixes both things by relying on the Bazel
`CommandHelper.java` class which handles the expansion of commands as
expected, with similar semantics of a `genrule` as per `GenRuleBase.java`.

This allows test authors to conveniently use a `nodejs_binary` or
`sh_binary` as command binary because the `CommandHelper` knows
exactly which targets provide executables or not. There is no good API
for the plain Make expansion of a command itself, so we use a little trick
(which is documented sufficiently in the code).
@devversion devversion force-pushed the feat/integration-rule-command-tool-resolution branch from f35236e to 7362236 Compare November 6, 2021 16:56
@devversion devversion added the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 6, 2021
bazel/integration/index.bzl Outdated Show resolved Hide resolved
@devversion devversion removed the request for review from josephperrott November 6, 2021 21:45
@devversion devversion added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 6, 2021
@devversion devversion merged commit 7605373 into angular:main Nov 6, 2021
@devversion devversion deleted the feat/integration-rule-command-tool-resolution branch November 6, 2021 21:55
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants