Skip to content

Commit 64092a8

Browse files
committed
tock-register-interface: remove std_unit_tests feature
With no tests relying on the standard library being generated, the feature for explicitly enabling the generation of these tests can be removed.
1 parent 2c20426 commit 64092a8

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

libraries/tock-register-interface/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ edition = "2021"
1515
travis-ci = { repository = "tock/tock", branch = "master" }
1616

1717
[features]
18-
default = [ "register_types", "std_unit_tests" ]
18+
default = [ "register_types" ]
1919

2020
# Include actual register types (except LocalRegisterCopy). Disabling
2121
# the feature makes this an interface-only library and removes all
2222
# usage of unsafe code
2323
register_types = []
24-
25-
# Feature flag to enable generation of unit tests for the
26-
# registers. Enabling this may break compilation in
27-
# `custom-test-frameworks` environments.
28-
std_unit_tests = []

libraries/tock-register-interface/README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,16 @@ struct Registers {
9090
}
9191
```
9292

93-
By default, `std` unit tests for the struct are generated as well (that is,
94-
tests attributed with `#[test]`). The unit tests make sure that the offsets and
95-
padding are consistent with the actual fields in the struct, and that alignment
96-
is correct.
97-
98-
Since those tests would break compilation in `custom-test-frameworks`
99-
environments, it is possible to opt out of the test generation. To do
100-
so, disable the default feature set containing the `std_unit_tests`
101-
feature:
102-
103-
```toml
104-
[dependencies.tock-registers]
105-
version = "0.4.x"
106-
default-features = false
107-
features = ["register_types"]
108-
```
93+
This crate will generate additional, compile time (`const`) assertions
94+
to validate various invariants of the register structs, such as
95+
96+
- proper start offset of padding fields,
97+
- proper start and end offsets of actual fields,
98+
- invalid alignment of field types,
99+
- the `@END` marker matching the size of the struct.
100+
101+
For more information on the generated assertions, check out the [`test_fields!`
102+
macro documentation](https://docs.tockos.org/tock_registers/macro.test_fields.html).
109103

110104
By default, the visibility of the generated structs and fields is private. You
111105
can make them public using the `pub` keyword, just before the struct name or the

0 commit comments

Comments
 (0)