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

--bes_backend flag appears to change behavior of "coverage" command without targets #15925

Open
WillEngFlow opened this issue Jul 19, 2022 · 4 comments
Assignees
Labels
coverage P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged

Comments

@WillEngFlow
Copy link

Description of the bug:

Adding the --bes_backend flag to Bazel appears to alter the end status of an invocation running the coverage command.

It appears as if the existence of the flag changes the build from successful
INFO: Build completed successfully, 1 total action
to an error
ERROR: No test targets were found, yet testing was requested

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

Run all commands inside https://github.com/bazelbuild/examples under the {root}/java-tutorial/ directory.

An actual BES is not necessary to repro so the timeout is set to a very short period (10ms) and the BES failure is ignored.

  1. Run bazel --nohome_rc --noworkspace_rc coverage --bes_timeout=10ms
  2. Note the end status is INFO: Build completed successfully, 1 total action
  3. Run bazel --nohome_rc --noworkspace_rc coverage --bes_backend=grpcs://foo.bar --bes_timeout=10ms
  4. Note the end status is ERROR: No test targets were found, yet testing was requested

This error can also be reproduced using the --build_event_json flag:
bazel --nohome_rc --noworkspace_rc coverage
vs
bazel --nohome_rc --noworkspace_rc coverage --build_event_json_file=foo.json

Which operating system are you running Bazel on?

Ubuntu 20.04.4

What is the output of bazel info release?

release 5.2.0

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 master; git rev-parse HEAD ?

$ git remote get-url origin
https://github.com/bazelbuild/examples
$ git rev-parse main
5a8696429e36090a75eb6fee4ef4e91a3413ef13
$ git rev-parse HEAD
5a8696429e36090a75eb6fee4ef4e91a3413ef13


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

Found nothing.

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

N/A
@sgowroji sgowroji added type: bug team-Rules-Server Issues for serverside rules included with Bazel untriaged labels Jul 20, 2022
@comius comius added coverage team-Core Skyframe, bazel query, BEP, options parsing, bazelrc and removed team-Rules-Server Issues for serverside rules included with Bazel labels Jul 21, 2022
@comius
Copy link
Contributor

comius commented Jul 21, 2022

cc @c-mita
Should this be team-Core?

@haxorz
Copy link
Contributor

haxorz commented Jul 22, 2022

[@comius] Should this be team-Core?

team-Core doesn't own coverage specifically, so if the behavior here is due to an implementation in coverage we probably ought not be responsible for fixing it. But we do own BES/BEP and can definitely at least try to debug and give an assessment. @michaeledgar can you please do that?

@Yannic
Copy link
Contributor

Yannic commented Jul 22, 2022

The same can be reproduced with changing coverage to test:

bazel --nosystem_rc --nohome_rc --noworkspace_rc test

INFO: Analyzed 0 targets (0 packages loaded, 0 targets configured).
INFO: Found 0 test targets...
INFO: Elapsed time: 0.094s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action

bazel --nosystem_rc --nohome_rc --noworkspace_rc test --build_event_json_file=foo.json

INFO: Analyzed 0 targets (0 packages loaded, 0 targets configured).
INFO: Found 0 test targets...
INFO: Elapsed time: 0.098s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: No test targets were found, yet testing was requested
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 1 total action

I actually think that the output with --build_event_json_file=foo.json is correct: there is no pattern specified, so there are no tests to execute, hence the command should fail. The behavior is consistent with what's happening if running bazel test //my/cc_library, which also fails with ERROR: No test targets were found, yet testing was requested

@Yannic
Copy link
Contributor

Yannic commented Jul 22, 2022

This is a fun one:

Bazel always prints ERROR: No test targets were found, yet testing was requested when not specifying a target pattern, but overrides that line when BEP is disabled.

Repro: apply the following diff, run bazel --nosystem_rc --nohome_rc --noworkspace_rc test and watch the command-line!

diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java
index 43f006d919..5424f6febf 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java
@@ -184,6 +184,11 @@ public class TestCommand implements BlazeCommand {
                           FailureDetails.TestCommand.newBuilder().setCode(Code.NO_TEST_TARGETS))
                       .build())
               : buildResult.getDetailedExitCode();
+      try {
+        Thread.sleep(5000);
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
       env.getEventBus()
           .post(new NoTestsFound(detailedExitCode.getExitCode(), buildResult.getStopTime()));
       return BlazeCommandResult.detailedExitCode(detailedExitCode);

@haxorz haxorz added the P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) label Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coverage P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged
Projects
None yet
Development

No branches or pull requests

6 participants