Skip to content

Commit f943802

Browse files
committed
Improve generated doc
1 parent 0c54f6c commit f943802

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ keywords = ["embedded", "test", "testing", "test-runner", "test-framework"]
88
description = "A test harness and runner for embedded devices"
99
categories = ["embedded", "no-std", "development-tools::testing"]
1010

11+
[package.metadata.docs.rs]
12+
default-target = "riscv32imac-unknown-none-elf"
13+
1114
[dependencies]
1215
semihosting = { version = "0.1.7", features = ["args"] }
1316
embedded-test-macros = { version = "0.6.0", path = "./macros" }

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Embedded Test
22

33
[![Crates.io](https://img.shields.io/crates/v/embedded-test?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/embedded-test)
4+
[![Documentation](https://docs.rs/embedded-test/badge.svg)](https://docs.rs/embedded-test)
45
![Crates.io](https://img.shields.io/crates/l/embedded-test?labelColor=1C2C2E&style=flat-square)
56

67
The embedded-test library provides a test harness for embedded systems (riscv, arm and xtensa).
@@ -38,7 +39,6 @@ Add the following to your `Cargo.toml`:
3839
[dev-dependencies]
3940
embedded-test = { version = "0.6.0" }
4041

41-
4242
[[test]]
4343
name = "example_test"
4444
harness = false
@@ -148,12 +148,15 @@ mod tests {
148148
| `external-executor` | No | Allows you to bring your own embassy executor which you need to pass to the `#[tests]` macro (e.g. `#[embedded_test::tests(executor = esp_hal::embassy::executor::thread::Executor::new())]`) |
149149
| `xtensa-semihosting` | No | Enables semihosting for xtensa targets. |
150150

151+
Please also note the doc for
152+
the [Attribute Macro embedded_test::tests](https://docs.rs/embedded-test/latest/embedded-test/attr.tests.html).
153+
151154
## License
152155

153156
Licensed under either of:
154157

155-
- Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
156-
- MIT license (http://opensource.org/licenses/MIT)
158+
- [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
159+
- [MIT license](http://opensource.org/licenses/MIT)
157160

158161
at your option.
159162

macros/src/lib.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ use syn::{parse, spanned::Spanned, Attribute, Item, ItemFn, ItemMod, ReturnType,
88

99
/// Attribute to be placed on the test suite's module.
1010
///
11+
/// ## Arguments
12+
/// - `default-timeout`: The default timeout in seconds for all tests in the suite. This can be overridden on a per-test basis. If not specified here or on a per-test basis, the default timeout is 60 seconds.
13+
/// - `executor`: The custom executor to use for running async tests. This is only required if the features `embassy` and `external-executor` are enabled.
14+
/// - `setup`: A function that will be called before running the tests. This can be used to setup logging or other global state.
15+
///
1116
/// ## Examples
1217
///
1318
/// Define a test suite with a single test:
@@ -27,10 +32,10 @@ use syn::{parse, spanned::Spanned, Attribute, Item, ItemFn, ItemMod, ReturnType,
2732
/// }
2833
/// ```
2934
///
30-
/// Define a test suite with a default timeout, and per-test timeouts:
35+
/// Define a test suite and customize everything:
3136
///
3237
/// ```rust,no_run
33-
/// #[embedded_test::tests(default_timeout = 10)]
38+
/// #[embedded_test::tests(default_timeout = 10, executor = embassy::executor::Executor::new(), setup = rtt_target::rtt_init_log!())]
3439
/// mod tests {
3540
/// #[init]
3641
/// fn init() {
@@ -39,7 +44,8 @@ use syn::{parse, spanned::Spanned, Attribute, Item, ItemFn, ItemMod, ReturnType,
3944
///
4045
/// #[test]
4146
/// fn test() {
42-
/// // Test the hardware
47+
/// log::info("Start....")
48+
/// // Test the hardware
4349
/// }
4450
///
4551
/// #[test]

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copied from https://github.com/knurling-rs/defmt/blob/main/firmware/defmt-test/src/lib.rs
22

33
#![no_std]
4+
#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
45

56
mod fmt;
67

0 commit comments

Comments
 (0)