rust_test_suite.bzl
rust_test_suite
load("@rules_rust//rust:rust_test_suite.bzl", "rust_test_suite")
rust_test_suite(name, srcs, shared_srcs, **kwargs)
A rule for creating a test suite for a set of rust_test targets.
This rule can be used for setting up typical rust integration tests. Given the following directory structure:
[crate]/
BUILD.bazel
src/
lib.rs
main.rs
tests/
integrated_test_a.rs
integrated_test_b.rs
integrated_test_c.rs
patterns/
fibonacci_test.rs
helpers/
mod.rs
The rule can be used to generate rust_test targets for each source file under tests
and a test_suite which encapsulates all tests.
load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test_suite")
rust_library(
name = "math_lib",
srcs = ["src/lib.rs"],
)
rust_binary(
name = "math_bin",
srcs = ["src/main.rs"],
)
rust_test_suite(
name = "integrated_tests_suite",
srcs = glob(["tests/**"]),
shared_srcs=glob(["tests/helpers/**"]),
deps = [":math_lib"],
)
PARAMETERS
| Name | Description | Default Value |
|---|---|---|
| name | The name of the test_suite. | none |
| srcs | All test sources, typically glob(["tests/**/*.rs"]). | none |
| shared_srcs | Optional argument for sources shared among tests, typically helper functions. | [] |
| kwargs | Additional keyword arguments for the underlying rust_test targets. The tags argument is also passed to the generated test_suite target. | none |