Skip to content

Commit fc31f32

Browse files
committed
Modify the code to allow running tests on the host machine
1 parent 6462074 commit fc31f32

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#![no_std]
2-
#![no_main]
2+
#![cfg_attr(not(test), no_main)] // #![no_main] interfers with 'cargo test' when targeting the host machine.
33

44
extern crate avr_std_stub;
55

66
#[no_mangle]
7+
#[cfg(not(test))] // The main function interfers with 'cargo test' when targeting the host machine.
78
fn main() {
89
}
10+
11+
#[cfg(test)]
12+
mod test {
13+
#[test]
14+
fn test_foo() {
15+
assert_eq!(1, 1);
16+
}
17+
}

0 commit comments

Comments
 (0)