Add option to avoid persisting test logs while still printing them to stdout
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the feature request:
It would be useful to have a Bazel option that allows test logs to be printed to stdout during test execution, but prevents these logs from being persisted to disk (i.e., not written to `bazel-testlogs/.../test.log` or similar files). The goal is to support workflows where developers want immediate feedback in the terminal but do not need or want the logs to be saved after the test run.
### Which category does this issue belong to?
Configurability
### What underlying problem are you trying to solve with this feature?
Currently, Bazel provides several --test_output modes (summary, errors, all, streamed) that control how test logs are displayed in the terminal. However, in all cases, Bazel also persists the logs to disk for each test run. This can lead to:
Unnecessary disk usage, especially in large test suites or CI environments where logs are not needed after the run.
Potential privacy or security concerns if logs contain sensitive information and are retained on disk.
Extra cleanup steps for users who only want to see logs in real time.
There is no documented way to print test logs to stdout/stderr only, without also saving them to files.
#### Proposed Solution
Introduce a new flag or option (e.g., `--no_persist_test_logs`) that, when set:
- Prints test logs to stdout/stderr as usual (honoring the selected `--test_output mode`).
- Does not write test logs to disk after the test completes.
This would be especially useful for local development and ephemeral CI jobs where log persistence is not required. It is particularly useful in environments with strict disk usage or privacy requirements, or when running Bazel tests that emit very large logs.
### Which operating system are you running Bazel on?
Linux
### What is the output of `bazel info release`?
release 8.2.1
### 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
9b4566856bb23b857d4a4008812449940230aa64
```
### Have you found anything relevant by searching the web?
Some alternatives considered:
- Manually deleting test logs after each run (inefficient and error-prone).
- Using custom scripts to redirect or suppress log file creation (not officially supported and may break with Bazel updates).
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start by tracing Bazel's existing --test_output modes and the code paths that persist test logs. Review how stdout/stderr handling and test-log files are covered by tests, then determine the option's interaction with each mode. Done means the selected mode still prints logs while no per-test log file is written, with coverage for the new behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100