Add a custom test runner

This commit is contained in:
Philipp Oppermann
2019-04-20 18:29:43 +02:00
parent 3c421e9ccb
commit 0beb0d80f8

View File

@@ -1,5 +1,8 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"]
use core::panic::PanicInfo; use core::panic::PanicInfo;
@@ -9,9 +12,20 @@ mod vga_buffer;
pub extern "C" fn _start() -> ! { pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!"); println!("Hello World{}", "!");
#[cfg(test)]
test_main();
loop {} 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. /// This function is called on panic.
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {