bazel_test
Resolver-generated Bazel test rule materialized as a Struo graph target.
Description#
bazel_test is created by the
bazel_workspace resolver for every
rule whose class ends in _test (for example rust_test, cc_test,
py_test). Direct authoring in struo.toml is rejected: the resolver must
materialize it so the bazel_label and bazel_rule_kind attributes stay
tied to real Bazel state.
Set coverage_per_test = true and product coverage_sources on the workspace
seed to measure each native test rule as one atomic invocation. This opt-in
delegates measurement to bazel coverage, with native test caching disabled,
one run and no sharding or flaky retries. Native build-event completion,
JUnit results and combined LCOV instrumentation must all agree before an
observation is complete. Missing, remote-only, cached, failed or skipped
observations cannot authorize exclusion. Native framework cases receive no
copies of the invocation's aggregate profile.
Coverage-enabled rules expose test-discovery with a current native rule query
and one target::invocation unit. Python 3, native Bazel coverage support and
complete toolchain_inputs are required. Toolchain contents bind historical
compatibility even when compilation uses Bazel's native cache.
Source files absent from the native instrumentation universe
retain graph-selected work. Without the opt-in the execution strategy below
is unchanged.
Both capabilities select the default output, runfiles and validation closure
from Bazel's analysis and execute it in <workspace>/.struo/bazel-actions/.
Build skips test execution. Test uses the exposed launcher and runfiles
manifest with environment, timeout and sharding. Bazel's exposed argv already
contains expanded rule arguments; Struo forwards them once without appending the
unexpanded rule attribute. GNU timeout or gtimeout must be available on the
host. Test execution is intentionally uncached, while compilation and runfiles
preparation remain cacheable with the workspace's toolchain declarations.
Test command options from .bazelrc are not inferred; declare required runtime
values in test_env.
Opaque required actions or unsupported test action shapes delegate to
bazel test <label> --test_output=errors (or bazel build <label> for build).
The provider reports the unsupported mnemonics. Delegated commands remain
uncached by Struo. Flaky retries and general configured rule-attribute expansion
are not implemented by the owned test strategy.
Test rules are not roots of the resolver output: struo build or
struo bazel build //... never picks them up implicitly. Invoke the test
explicitly with struo bazel test or struo test <struo-id>.
Attributes#
| Attribute | Type | Required | Default | Description |
|---|---|---|---|---|
bazel_label | string | yes | Fully qualified Bazel label of the test rule, for example //src:kura_lib_test. Set by the resolver. | |
bazel_rule_kind | string | yes | Bazel rule class, for example rust_test. Set by the resolver. | |
bazel | string | no | bazel | Bazel executable forwarded from the workspace seed. |
env | map<string,string> | no | {} | Declared environment forwarded from the workspace seed. Empty values override inherited host variables; native aquery action environments take precedence. |
toolchain_inputs | list<string> | no | [] | Complete implicit host toolchain inputs, forwarded from the workspace seed. Required for spawn caching. |
test_env | map<string,string> | no | {} | Additional declared test runtime environment, overriding rule environment. |
Providers and capabilities#
The target emits bazel_test and bazel_target and exposes the build and
test capabilities. It does not expose run.
Direct use#
struo bazel test //src:kura_lib_testSee the bazel_workspace reference for
the workspace-level attributes that control graph enumeration.
Sources#
- Bazel command-line reference
documents
bazel test, which this target kind wraps.