Mapping Bazel test action to remote strategy

Viewed 79

I have a Bazel project with lots of unit tests and where a subset requires GPU support.

I would like to map the unit tests that have GPU requirements to remote strategy but keep all other unit tests as sandboxed, running locally. Since all tests share the same mnemonic (TestRunner) I am not sure how to do that using the strategy or the strategy_regexp parameters.

Is this use case supported by Bazel? Or do you have to either map all or no tests to remote execution?

Kind regards!

1 Answers

We had a similar problem (another flavour though: have some //some/test/target run locally while others run as remote/worker/sandboxed) and ended up writing

test --strategy=remote,worker,sandboxed  # force sandbox: no local
test --strategy_regexp=//some/test/target=local  # allow local
test --worker_sandboxing=true
test --incompatible_legacy_local_fallback=false

unfortunately, this regex can become quite big so consider some clever naming if you have bunch of those "exceptional" tests, e.g. call all of them _special_tag and write a regex like

test --strategy_regexp=//.*_special_tag=local  # allow local for `*_special_tag

What can help to debug is to run

bazel aquery //some/test/target 2>/dev/null

to understand what actually matches on that regexp.

Related