bazelbuild / bazelbuild/bazel

Test rule sample code using legacy feature

Open Beginner friendly
#17,330 5 comments 0 reactions 0 assignees View on GitHub
P3 stale team-Rules-API type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

https://bazel.build/extending/rules#executable_rules_and_test_rules says:

> The action that generates [the executable file] must set the executable bit on the file. For a [ctx.actions.run](https://bazel.build/rules/lib/actions#run) or [ctx.actions.run_shell](https://bazel.build/rules/lib/actions#run_shell) action this should be done by the underlying tool that is invoked by the action. For a [ctx.actions.write](https://bazel.build/rules/lib/actions#write) action, pass `is_executable=True`.

Then, a few lines below:

> See examples of an [executable rule](https://github.com/bazelbuild/examples/blob/main/rules/executable/fortune.bzl) and a [test rule](https://github.com/bazelbuild/examples/blob/main/rules/test_rule/line_length.bzl).

The test rule link leads to https://github.com/bazelbuild/examples/blob/main/rules/test_rule/line_length.bzl which does not set `is_executable=True` in its invocation of `ctx.actions.write`. This is confusing, until you realize that the sample code uses a feature that is labeled as a legacy behavior (the `ctx.outputs.executable` predeclared output).

Please make the sample code follow the recommended practices.

Contributor guide

Open the contributing guide

Research direction

Start with the executable-rules and test-rules guidance at bazel.build/extending/rules, then inspect examples/rules/test_rule/line_length.bzl in bazelbuild/examples. Compare its ctx.actions.write invocation with the documented recommended practice and the legacy ctx.outputs.executable behavior. Done means the linked sample follows the recommendation and no longer conflicts with the surrounding documentation.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.