bazel: test inconsistent No test targets were found, yet testing was requested

Description of the problem:

When package package has no test targets, bazel test //package/... sometimes succeeds, sometimes doesn’t.

The former case:

> bazel test //package/...
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action

The latter:

2019-01-29T15:15:58.9218544Z INFO: Build completed successfully, 3 total actions
2019-01-29T15:15:58.9227697Z ERROR: No test targets were found, yet testing was requested
2019-01-29T15:15:58.9292161Z INFO: Build completed successfully, 3 total actions
2019-01-29T15:15:58.9524112Z ##[error]Bash exited with code '4'.

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

I’ve only seen the ERROR: ... case occur on the rules_haskell CI, with this config:

jobs:
- job: Windows
  pool:
    vmImage: 'vs2017-win2016'
  steps:
  - bash: |
      set -e
      curl -LO https://github.com/bazelbuild/bazel/releases/download/0.21.0/bazel-0.21.0-windows-x86_64.exe
      mv bazel-*.exe bazel.exe
      mkdir /c/bazel
      mv bazel.exe /c/bazel
    displayName: 'Install Bazel'
  - bash: |
      set -e
      export MSYS2_ARG_CONV_EXCL="*"
      ...
      # !!!
      # Replacing `build` with `test` fails the job
      /c/bazel/bazel.exe build --config windows "//tests/data/..."
      ...

    displayName: 'Run Bazel'

What operating system are you running Bazel on?

Windows with vmImage: 'vs2017-win2016'

I’m unable to reproduce the issue on other Windows machines.

What’s the output of bazel info release?

release 0.21.0

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

--treat_no_tests_as_success_return_code would be great to have, usecase is using bazel query to select test targets, for example to

  • pick --jobs N differently for different test sets (based on size for example)
  • choose running bazel coverage vs bazel test depending on some query

Filtering all test by tags isn’t always expressive enough.

No, unless the bug is the same confusion over output / suppressed ERROR messages with implicit --curses yes.