mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 00:56:38 +11:00
move test runner to own module
This commit is contained in:
parent
e75adf9e67
commit
1614e46c4e
4 changed files with 81 additions and 79 deletions
|
@ -50,6 +50,7 @@ impl BlockAllocator {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub unsafe fn number_of_blocks(&self) -> u32 {
|
||||
free(|key| {
|
||||
let mut state = self.state.borrow(*key).borrow_mut();
|
||||
|
|
|
@ -35,6 +35,7 @@ const EWRAM_END: usize = 0x0204_0000;
|
|||
#[global_allocator]
|
||||
static GLOBAL_ALLOC: BlockAllocator = unsafe { BlockAllocator::new() };
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub unsafe fn number_of_blocks() -> u32 {
|
||||
GLOBAL_ALLOC.number_of_blocks()
|
||||
}
|
||||
|
|
|
@ -29,6 +29,6 @@ mod tests {
|
|||
|
||||
display_logo(&mut gfx);
|
||||
|
||||
crate::assert_image_output("gfx/test_logo.png");
|
||||
crate::test_runner::assert_image_output("gfx/test_logo.png");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// This appears to be needed for testing to work
|
||||
#![cfg_attr(test, no_main)]
|
||||
#![cfg_attr(test, feature(custom_test_frameworks))]
|
||||
#![cfg_attr(test, test_runner(crate::test_runner))]
|
||||
#![cfg_attr(test, test_runner(crate::test_runner::test_runner))]
|
||||
#![cfg_attr(test, reexport_test_harness_main = "test_main")]
|
||||
#![deny(clippy::all)]
|
||||
#![feature(alloc_error_handler)]
|
||||
|
@ -224,6 +224,10 @@ impl Gba {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_runner {
|
||||
use super::*;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait Testable {
|
||||
fn run(&self, gba: &mut Gba);
|
||||
|
@ -256,7 +260,6 @@ where
|
|||
}
|
||||
|
||||
#[panic_handler]
|
||||
#[cfg(test)]
|
||||
fn panic_implementation(info: &core::panic::PanicInfo) -> ! {
|
||||
if let Some(mut mgba) = mgba::Mgba::new() {
|
||||
mgba.print(format_args!("[failed]"), mgba::DebugLevel::Error)
|
||||
|
@ -268,11 +271,9 @@ fn panic_implementation(info: &core::panic::PanicInfo) -> ! {
|
|||
loop {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
static mut TEST_GBA: Option<Gba> = None;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(test)]
|
||||
pub fn test_runner(tests: &[&dyn Testable]) {
|
||||
let mut mgba = mgba::Mgba::new().unwrap();
|
||||
mgba.print(
|
||||
|
@ -294,7 +295,6 @@ pub fn test_runner(tests: &[&dyn Testable]) {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[entry]
|
||||
fn agb_test_main(gba: Gba) -> ! {
|
||||
unsafe { TEST_GBA = Some(gba) };
|
||||
|
@ -303,8 +303,7 @@ fn agb_test_main(gba: Gba) -> ! {
|
|||
loop {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn assert_image_output(image: &str) {
|
||||
pub fn assert_image_output(image: &str) {
|
||||
display::busy_wait_for_vblank();
|
||||
display::busy_wait_for_vblank();
|
||||
let mut mgba = crate::mgba::Mgba::new().unwrap();
|
||||
|
@ -315,6 +314,7 @@ fn assert_image_output(image: &str) {
|
|||
.unwrap();
|
||||
display::busy_wait_for_vblank();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
Loading…
Add table
Reference in a new issue