diff --git a/Cargo.toml b/Cargo.toml index a4da7a6e..6eeea60f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,10 @@ version = "0.1.0" authors = ["Philipp Oppermann "] edition = "2018" +[[test]] +name = "should_panic" +harness = false + [dependencies] bootloader = "0.6.4" volatile = "0.2.3" diff --git a/tests/should_panic.rs b/tests/should_panic.rs index 3fe187cd..d624bcbe 100644 --- a/tests/should_panic.rs +++ b/tests/should_panic.rs @@ -1,27 +1,20 @@ #![no_std] #![no_main] -#![feature(custom_test_frameworks)] -#![test_runner(test_runner)] -#![reexport_test_harness_main = "test_main"] use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode}; use core::panic::PanicInfo; #[no_mangle] pub extern "C" fn _start() -> ! { - test_main(); - + should_fail(); + serial_println!("[test did not panic]"); + exit_qemu(QemuExitCode::Failed); loop {} } -pub fn test_runner(tests: &[&dyn Fn()]) { - serial_println!("Running {} tests", tests.len()); - if let Some(test) = tests.first() { - test(); - serial_println!("[test did not panic]"); - exit_qemu(QemuExitCode::Failed); - } - exit_qemu(QemuExitCode::Success); +fn should_fail() { + serial_print!("should_fail... "); + assert_eq!(0, 1); } #[panic_handler] @@ -30,9 +23,3 @@ fn panic(_info: &PanicInfo) -> ! { exit_qemu(QemuExitCode::Success); loop {} } - -#[test_case] -fn should_fail() { - serial_print!("should_fail... "); - assert_eq!(0, 1); -}