diff --git a/src/main.rs b/src/main.rs index 18e03650..d63dab29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ #![no_std] #![no_main] +#![feature(custom_test_frameworks)] +#![test_runner(crate::test_runner)] +#![reexport_test_harness_main = "test_main"] use core::panic::PanicInfo; @@ -9,9 +12,20 @@ mod vga_buffer; pub extern "C" fn _start() -> ! { println!("Hello World{}", "!"); + #[cfg(test)] + test_main(); + loop {} } +#[cfg(test)] +fn test_runner(tests: &[&dyn Fn()]) { + println!("Running {} tests", tests.len()); + for test in tests { + test(); + } +} + /// This function is called on panic. #[panic_handler] fn panic(info: &PanicInfo) -> ! {