Skip to content

Commit

Permalink
Improve generated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
t-moe committed Dec 3, 2024
1 parent 0c54f6c commit f102b4b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ keywords = ["embedded", "test", "testing", "test-runner", "test-framework"]
description = "A test harness and runner for embedded devices"
categories = ["embedded", "no-std", "development-tools::testing"]

[package.metadata.docs.rs]
default-target = "riscv32imac-unknown-none-elf"

[dependencies]
semihosting = { version = "0.1.7", features = ["args"] }
embedded-test-macros = { version = "0.6.0", path = "./macros" }
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Embedded Test

[![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)
[![Documentation](https://docs.rs/embedded-test/badge.svg)](https://docs.rs/embedded-test)
![Crates.io](https://img.shields.io/crates/l/embedded-test?labelColor=1C2C2E&style=flat-square)

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


[[test]]
name = "example_test"
harness = false
Expand Down Expand Up @@ -148,12 +148,15 @@ mod tests {
| `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())]`) |
| `xtensa-semihosting` | No | Enables semihosting for xtensa targets. |

Please also note the doc for
the [Attribute Macro embedded_test::tests](https://docs.rs/embedded-test/latest/embedded-test/attr.tests.html).

## License

Licensed under either of:

- Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (http://opensource.org/licenses/MIT)
- [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
- [MIT license](http://opensource.org/licenses/MIT)

at your option.

Expand Down
12 changes: 9 additions & 3 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ use syn::{parse, spanned::Spanned, Attribute, Item, ItemFn, ItemMod, ReturnType,

/// Attribute to be placed on the test suite's module.
///
/// ## Arguments
/// - `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.
/// - `executor`: The custom executor to use for running async tests. This is only required if the features `embassy` and `external-executor` are enabled.
/// - `setup`: A function that will be called before running the tests. This can be used to setup logging or other global state.
///
/// ## Examples
///
/// Define a test suite with a single test:
Expand All @@ -27,10 +32,10 @@ use syn::{parse, spanned::Spanned, Attribute, Item, ItemFn, ItemMod, ReturnType,
/// }
/// ```
///
/// Define a test suite with a default timeout, and per-test timeouts:
/// Define a test suite and customize everything:
///
/// ```rust,no_run
/// #[embedded_test::tests(default_timeout = 10)]
/// #[embedded_test::tests(default_timeout = 10, executor = embassy::executor::Executor::new(), setup = rtt_target::rtt_init_log!())]
/// mod tests {
/// #[init]
/// fn init() {
Expand All @@ -39,7 +44,8 @@ use syn::{parse, spanned::Spanned, Attribute, Item, ItemFn, ItemMod, ReturnType,
///
/// #[test]
/// fn test() {
/// // Test the hardware
/// log::info("Start....")
/// // Test the hardware
/// }
///
/// #[test]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copied from https://github.com/knurling-rs/defmt/blob/main/firmware/defmt-test/src/lib.rs

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

mod fmt;

Expand Down

0 comments on commit f102b4b

Please sign in to comment.