Skip to content

Commit

Permalink
Refactor SPI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Aug 23, 2024
1 parent 0d7ad38 commit cfa74f4
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 314 deletions.
24 changes: 9 additions & 15 deletions hil-test/tests/spi_full_duplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ struct Context {
spi: Spi<'static, esp_hal::peripherals::SPI2, FullDuplexMode>,
}

impl Context {
pub fn init() -> Self {
#[cfg(test)]
#[embedded_test::tests]
mod tests {
use defmt::assert_eq;

use super::*;

#[init]
fn init() -> Context {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
Expand All @@ -49,19 +56,6 @@ impl Context {

Context { spi }
}
}

#[cfg(test)]
#[embedded_test::tests]
mod tests {
use defmt::assert_eq;

use super::*;

#[init]
fn init() -> Context {
Context::init()
}

#[test]
#[timeout(3)]
Expand Down
Loading

0 comments on commit cfa74f4

Please sign in to comment.