Make cargo test work
diff --git a/.travis.yml b/.travis.yml index b3eadc1..55492aa 100644 --- a/.travis.yml +++ b/.travis.yml
@@ -15,5 +15,5 @@ script: - cargo fmt --all -- --check - - cargo test --lib --all + - cargo test --workspace - ./build_examples.sh
diff --git a/src/lib.rs b/src/lib.rs index 6d49e29..ae46436 100644 --- a/src/lib.rs +++ b/src/lib.rs
@@ -6,9 +6,7 @@ naked_functions, ptr_offset_from )] -#![no_std] - -extern crate alloc; +#![cfg_attr(any(target_arch = "arm", target_arch = "riscv32"), no_std)] mod callback; @@ -31,7 +29,6 @@ pub mod temperature; pub mod timer; pub mod unwind_symbols; -pub use libtock_codegen::main; #[cfg(any(target_arch = "arm", target_arch = "riscv32"))] pub mod entry_point; @@ -41,6 +38,8 @@ pub mod syscalls; +pub use libtock_codegen::main; + // Dummy structure to force importing the panic_handler and other no_std elements when nothing else // is imported. pub struct LibTock;
diff --git a/src/result.rs b/src/result.rs index a7f40e1..9b26c31 100644 --- a/src/result.rs +++ b/src/result.rs
@@ -11,6 +11,13 @@ Other(OtherError), } +#[cfg(not(any(target_arch = "arm", target_arch = "riscv32")))] +impl core::fmt::Debug for TockError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + writeln!(f, "impl Debug only for test builds") + } +} + #[derive(Copy, Clone)] pub struct SubscribeError { pub driver_number: usize,
diff --git a/src/temperature.rs b/src/temperature.rs index e50cbe2..28e366f 100644 --- a/src/temperature.rs +++ b/src/temperature.rs
@@ -51,8 +51,6 @@ #[cfg(test)] mod test { use super::*; - use alloc::string::String; - use alloc::string::ToString; #[test] fn render_temperature() {