bazelbuild / bazelbuild/bazel

Disallow "TestRunner" as action mnemonic in starlark actions

Open
#27,806 0 comments 2 reactions 1 assignee Claimed by @meisterT View on GitHub
team-Core type: feature request untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the feature request:

In [`actions.run`](https://bazel.build/rules/lib/builtins/actions#run.mnemonic) and [`actions.run_shell`](https://bazel.build/rules/lib/builtins/actions#run_shell.mnemonic), users specify the *mnemonic* for their action. This is a short string that describes the kind of action being run. A mnemonic need not be unique: unrelated rules may use the same mnemonic. The primary use for the mnemonic string is for Bazel configuration flags: `--strategy`, for example, sets the strategy using the mnemonic as a key (eg. `--strategy=Genrule=local`). Another important mnemonic-keyed flag is `--modify_execution_info`.

One mnemonic that is "special" is `TestRunner`. This is the mnemonic used by test-execution actions generated by Bazel when the command is `test` (or `coverage`). If users wish to customize test execution on the command-line, they might use `--modify_execution_info=TestRunner=+requires-net:external`. If users wish to identify all test-execution actions in a given target pattern they can run `blaze aquery 'mnemonic(TestRunner, //my/project/...)'`.

A wrinkle is that we cannot actually guarantee that those examples I just listed are only going to identify actions generated internally by Bazel. Users may specify the mnemonic `TestRunner` themselves in normal build-time actions.

In lieu of an actually namespaced mnemonic-like identifier, Bazel could simply forbid the specific mnemonic `TestRunner` from Starlark build actions. This would be a backwards-incompatible change aimed at eliminating a footgun.

### Which category does this issue belong to?

Core

### What underlying problem are you trying to solve with this feature?

The problem is that there is no way to identify with 100% certainty within the action graph the actions that are generated by Bazel to execute tests.

### Which operating system are you running Bazel on?

Linux

### What is the output of `bazel info release`?

_No response_

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

```text

```

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.