From 0beb0d80f8e7667de82b0fed194bdac0128916e8 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sat, 20 Apr 2019 18:29:43 +0200 Subject: [PATCH] Add a custom test runner --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) -> ! {