bazelbuild / bazelbuild/bazel

--build_manual_tests applies to non-tests

Open
#11,103 7 comments 0 reactions 0 assignees View on GitHub
help wanted P3 team-Core team-Documentation type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the problem:

The `--build_manual_tests` flag builds targets tagged "manual" but which are not test targets. This behavior seems inconsistent with the [documentation](https://docs.bazel.build/versions/3.0.0/command-line-reference.html#flag--build_manual_tests), which seems to imply that the flag applies specifically to test targets:

>Forces test targets tagged 'manual' to be built. 'manual' tests are excluded from processing. This option forces them to be built (but not executed).

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Consider a workspace consisting of three files:

BUILD:
```
java_binary(
name = "bin",
srcs = glob(["Manual.java"]),
main_class = "Manual",
tags = ["manual"],
)
```

Manual.java:
```
public class Manual {
public static void main(String[] args) {
System.out.println("Hello");
}
}
```

WORKSPACE:
(empty)

Steps:
1. Edit Manual.java
2. Run `bazel build --build_manual_tests ...`

Expected outcome: no targets are built.

Actual outcome: The `bin` target is built:
```
$ bazel build --build_manual_tests --subcommands=pretty_print ...

INFO: Analyzed target //:bin (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //:bin [action 'Building bin.jar (1 source file)', configuration: dbadffe9d0533bf51e2ba2aac08b5435397cdb67cd0b74b86e24900343122bb0]
(cd /home/sebelino/.cache/bazel/_bazel_sebelino/c3c7a33107b6cbc76f7cc84608df699f/execroot/__main__ && \
exec env - \
LC_CTYPE=en_US.UTF-8 \
PATH=/usr/local/bin:/usr/local/sbin:/opt/google-cloud-sdk/bin:/home/sebelino/scripts:/home/sebelino/bin:/usr/bin:/home/sebelino/code/go/bin:/opt/ida/bin:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/sonar-scanner/bin \
external/remotejdk11_linux/bin/java \
-XX:+UseParallelOldGC \
-XX:-CompactStrings \
'--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' \
'--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' \
'--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' \
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' \
'--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' \
'--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED' \
'--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' \
'--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' \
'--patch-module=java.compiler=external/remote_java_tools_linux/java_tools/java_compiler.jar' \
'--patch-module=jdk.compiler=external/remote_java_tools_linux/java_tools/jdk_compiler.jar' \
'--add-opens=java.base/java.nio=ALL-UNNAMED' \
'--add-opens=java.base/java.lang=ALL-UNNAMED' \
-jar \
external/remote_java_tools_linux/java_tools/JavaBuilder_deploy.jar \
@bazel-out/k8-fastbuild/bin/bin.jar-0.params \
@bazel-out/k8-fastbuild/bin/bin.jar-1.params)
Target //:bin up-to-date:
bazel-bin/bin.jar
bazel-bin/bin
INFO: Elapsed time: 0.130s, Critical Path: 0.05s
INFO: 1 process: 1 worker.
INFO: Build completed successfully, 2 total actions
```

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

Linux 5.5.13-arch2-1

### What's the output of `bazel info release`?

release 3.0.0

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported workspace with a manual-tagged java_binary and `bazel build --build_manual_tests ...`, then trace the `--build_manual_tests` target-filtering entry point. Done means manual non-test targets are excluded while manual test targets retain the documented build behavior, with coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.