https://github.com/oliverlee/rules_multitransition
Bazel rules for running tests with transitions
https://github.com/oliverlee/rules_multitransition
bazel test toolchains transition
Last synced: 30 days ago
JSON representation
Bazel rules for running tests with transitions
- Host: GitHub
- URL: https://github.com/oliverlee/rules_multitransition
- Owner: oliverlee
- License: apache-2.0
- Created: 2025-12-07T23:28:23.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-12-11T05:32:20.000Z (2 months ago)
- Last Synced: 2025-12-11T18:30:45.881Z (2 months ago)
- Topics: bazel, test, toolchains, transition
- Language: Starlark
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rules_multitransition
These rules provide an interface for running tests with multiple configurations.
This is especially useful when testing a project with multiple toolchains.
## Usage
Setup the test with the desired configuration by using `multitransition_test`
```bzl
# //:BUILD.bazel
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load(
"@rules_multitransition//:defs.bzl",
"multitransition_test",
"transition_config",
)
multitransition_test(
cc_test,
name = "my_test",
transitions = [
transition_config(
name = "gcc-dbg",
compilation_mode = "dbg",
extra_toolchains = ["@gcc_toolchain//:..."],
),
transition_config(
name = "llvm-dbg",
compilation_mode = "dbg",
extra_toolchains = ["@llvm_toolchain//:..."],
),
transition_config(
name = "gcc-opt",
compilation_mode = "opt",
extra_toolchains = ["@gcc_toolchain//:..."],
),
...
],
# other 'cc_test' args
srcs = [...],
deps = [...],
)
```
or wrapping it with a macro
```bzl
# //:cc_multi_test.bzl
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load(
"@rules_multitransition//:defs.bzl",
"multitransition_test",
"transition_config",
)
default_transitions = [
transition_config(...),
...
]
def cc_multi_test(
*,
transitions = default_transitions,
**kwargs):
multitransition_test(
cc_test,
transitions = transitions,
**kwargs
)
)
```
Run all the `multitransition_test` targets with Bazel:
```sh
$ bazel test //...
```
Run the associated `test_suite`
```sh
$ bazel test //:my_test.suite
```
Run the base test target
```sh
$ bazel test \
--@rules_multitransition//config:multitransition_test=False \
//:my_test
```