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

Export BAZEL_TEST=1 for bazel test executables #15393

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions site/en/reference/test-encyclopedia.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ The initial environment block shall be composed as follows:
class="external">JUnit test result schema</a>.</td>
<td>optional</td>
</tr>
<tr>
<td><code>BAZEL_TEST</code></td>
<td>Signifies test executable is being driven by <code>bazel test</code></td>
<td>required</td>
</tr>
</table>

The environment may contain additional entries. Tests should not depend on the
Expand Down
5 changes: 5 additions & 0 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ function is_absolute {
# root.
EXEC_ROOT="$PWD"

# Declare that the executable is running in a `bazel test` environment
# This allows test frameworks to enable output to the unprefixed environment variable
# For example, if `BAZEL_TEST` and `XML_OUTPUT_FILE` are defined, write JUnit output
export BAZEL_TEST=1

# Bazel sets some environment vars to relative paths to improve caching and
# support remote execution, where the absolute path may not be known to Bazel.
# Convert them to absolute paths here before running the actual test.
Expand Down