-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathlib.rs
More file actions
87 lines (72 loc) · 2.57 KB
/
lib.rs
File metadata and controls
87 lines (72 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copied from https://github.com/knurling-rs/defmt/blob/main/firmware/defmt-test/src/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::needless_doctest_main)]
#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
mod fmt;
pub use embedded_test_macros::tests;
#[cfg(all(feature = "panic-handler", not(feature = "ariel-os")))]
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
error!("====================== PANIC ======================");
error!("{}", info);
semihosting::process::abort()
}
/// Private implementation details used by the proc macro.
/// WARNING: This API is not stable and may change at any time.
#[doc(hidden)]
pub mod export;
mod sealed {
pub trait Sealed {}
impl Sealed for () {}
impl<T, E> Sealed for Result<T, E> {}
}
/// Indicates whether a test succeeded or failed.
///
/// This is comparable to the `Termination` trait in libstd, except stable and tailored towards the
/// needs of embedded-test. It is implemented for `()`, which always indicates success, and `Result`,
/// where `Ok` indicates success.
#[cfg(feature = "defmt")]
pub trait TestOutcome: defmt::Format + sealed::Sealed {
fn is_success(&self) -> bool;
}
/// Indicates whether a test succeeded or failed.
///
/// This is comparable to the `Termination` trait in libstd, except stable and tailored towards the
/// needs of embedded-test. It is implemented for `()`, which always indicates success, and `Result`,
/// where `Ok` indicates success.
#[cfg(feature = "log")]
pub trait TestOutcome: core::fmt::Debug + sealed::Sealed {
fn is_success(&self) -> bool;
}
/// Indicates whether a test succeeded or failed.
///
/// This is comparable to the `Termination` trait in libstd, except stable and tailored towards the
/// needs of embedded-test. It is implemented for `()`, which always indicates success, and `Result`,
/// where `Ok` indicates success.
#[cfg(all(not(feature = "log"), not(feature = "defmt")))]
pub trait TestOutcome: sealed::Sealed {
fn is_success(&self) -> bool;
}
impl TestOutcome for () {
fn is_success(&self) -> bool {
true
}
}
#[cfg(feature = "log")]
impl<T: core::fmt::Debug, E: core::fmt::Debug> TestOutcome for Result<T, E> {
fn is_success(&self) -> bool {
self.is_ok()
}
}
#[cfg(feature = "defmt")]
impl<T: defmt::Format, E: defmt::Format> TestOutcome for Result<T, E> {
fn is_success(&self) -> bool {
self.is_ok()
}
}
#[cfg(all(not(feature = "log"), not(feature = "defmt")))]
impl<T, E> TestOutcome for Result<T, E> {
fn is_success(&self) -> bool {
self.is_ok()
}
}