docs(skills): split build style rules
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Rust build rules
|
||||
# Dependency rules
|
||||
|
||||
## Use workspace dependency versions
|
||||
|
||||
@@ -28,27 +28,3 @@ Apply this rule to `rust_library`, `rust_binary`, and `rust_test` targets.
|
||||
|
||||
Cargo and Bazel resolve Rust dependencies independently.
|
||||
Complete declarations keep `cargo check`, Rust Analyzer, and Bazel builds consistent.
|
||||
|
||||
## Declare Rust tests in Bazel
|
||||
|
||||
### Rule
|
||||
|
||||
Declare Rust test files in the nearest Bazel `BUILD` file with `rust_test`.
|
||||
Do not add `[[test]]` entries to `Cargo.toml` unless the operator explicitly requests Cargo test declarations.
|
||||
|
||||
### Rationale
|
||||
|
||||
Bazel is the source of truth for Rust test targets in this repository.
|
||||
Keeping test declarations in Bazel avoids duplicate test target lists.
|
||||
|
||||
## Use one source input style per `rust_test`
|
||||
|
||||
### Rule
|
||||
|
||||
Do not set both `crate` and `srcs` on a `rust_test` target.
|
||||
Use exactly one input style for each Rust test target.
|
||||
|
||||
### Rationale
|
||||
|
||||
`rules_rust` rejects `rust_test` targets that set both `crate` and `srcs`.
|
||||
Keeping one input style per target makes the test declaration valid and unambiguous.
|
||||
25
src/skills/style/build/rules/tests.md
Normal file
25
src/skills/style/build/rules/tests.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Test rules
|
||||
|
||||
## Declare Rust tests in Bazel
|
||||
|
||||
### Rule
|
||||
|
||||
Declare Rust test files in the nearest Bazel `BUILD` file with `rust_test`.
|
||||
Do not add `[[test]]` entries to `Cargo.toml` unless the operator explicitly requests Cargo test declarations.
|
||||
|
||||
### Rationale
|
||||
|
||||
Bazel is the source of truth for Rust test targets in this repository.
|
||||
Keeping test declarations in Bazel avoids duplicate test target lists.
|
||||
|
||||
## Use one source input style per `rust_test`
|
||||
|
||||
### Rule
|
||||
|
||||
Do not set both `crate` and `srcs` on a `rust_test` target.
|
||||
Use exactly one input style for each Rust test target.
|
||||
|
||||
### Rationale
|
||||
|
||||
`rules_rust` rejects `rust_test` targets that set both `crate` and `srcs`.
|
||||
Keeping one input style per target makes the test declaration valid and unambiguous.
|
||||
Reference in New Issue
Block a user