@ -9,15 +9,17 @@ use test::{ColorConfig, Options, OutputFormat, RunIgnored, TestDescAndFn, TestFn
use crate ::console ::Console ;
use crate ::console ::Console ;
use crate ::gfx ::Gfx ;
use crate ::gfx ::Gfx ;
use crate ::services ::hid ::{ Hid , KeyPad } ;
use crate ::services ::hid ::{ Hid , KeyPad } ;
use crate ::services ::Apt ;
/// A custom runner to be used with `#[test_runner]`. This simple implementation
/// A custom runner to be used with `#[test_runner]`. This simple implementation
/// runs all tests in series, "failing" on the first one to panic (really, the
/// runs all tests in series, "failing" on the first one to panic (really, the
/// panic is just treated the same as any normal application panic).
/// panic is just treated the same as any normal application panic).
pub ( crate ) fn test_ runner ( tests : & [ & TestDescAndFn ] ) {
pub ( crate ) fn run ( tests : & [ & TestDescAndFn ] ) {
crate ::init ( ) ;
crate ::init ( ) ;
let gfx = Gfx ::default ( ) ;
let gfx = Gfx ::default ( ) ;
let hid = Hid ::init ( ) . unwrap ( ) ;
let hid = Hid ::init ( ) . unwrap ( ) ;
let apt = Apt ::init ( ) . unwrap ( ) ;
let mut top_screen = gfx . top_screen . borrow_mut ( ) ;
let mut top_screen = gfx . top_screen . borrow_mut ( ) ;
top_screen . set_wide_mode ( true ) ;
top_screen . set_wide_mode ( true ) ;
@ -38,18 +40,17 @@ pub(crate) fn test_runner(tests: &[&TestDescAndFn]) {
exclude_should_panic : false ,
exclude_should_panic : false ,
run_ignored : RunIgnored ::No ,
run_ignored : RunIgnored ::No ,
run_tests : true ,
run_tests : true ,
// Benchmarks are not supported
// Don't run benchmarks. We may want to create a separate runner for them in the future
bench_benchmarks : false ,
bench_benchmarks : false ,
logfile : None ,
logfile : None ,
nocapture : false ,
nocapture : false ,
// TODO: color doesn't work because of TERM/TERMINFO.
// TODO: color doesn't work because of TERM/TERMINFO.
// With RomFS we might be able to fake this out nicely...
// With RomFS we might be able to fake this out nicely...
color : ColorConfig ::Always Color ,
color : ColorConfig ::Auto Color ,
format : OutputFormat ::Pretty ,
format : OutputFormat ::Pretty ,
shuffle : false ,
shuffle : false ,
shuffle_seed : None ,
shuffle_seed : None ,
// tweak values? This seems to work out of the box
test_threads : None ,
test_threads : Some ( 3 ) ,
skip : Vec ::new ( ) ,
skip : Vec ::new ( ) ,
time_options : None ,
time_options : None ,
options : Options ::new ( ) ,
options : Options ::new ( ) ,
@ -61,19 +62,19 @@ pub(crate) fn test_runner(tests: &[&TestDescAndFn]) {
// Make sure the user can actually see the results before we exit
// Make sure the user can actually see the results before we exit
println! ( "Press START to exit." ) ;
println! ( "Press START to exit." ) ;
gfx . flush_buffers ( ) ;
while apt . main_loop ( ) {
gfx . swap_buffers ( ) ;
gfx . flush_buffers ( ) ;
gfx . swap_buffers ( ) ;
gfx . wait_for_vblank ( ) ;
loop {
hid . scan_input ( ) ;
hid . scan_input ( ) ;
if hid . keys_down ( ) . contains ( KeyPad ::KEY_START ) {
if hid . keys_down ( ) . contains ( KeyPad ::KEY_START ) {
break ;
break ;
}
}
}
}
}
}
/// Adapted from [`test::test_main_static`], along with [` make_owned_test`].
/// Adapted from [`test::test_main_static`] and [`test:: make_owned_test`].
fn run_static_tests ( opts : & TestOpts , tests : & [ & TestDescAndFn ] ) -> io ::Result < bool > {
fn run_static_tests ( opts : & TestOpts , tests : & [ & TestDescAndFn ] ) -> io ::Result < bool > {
let tests = tests . iter ( ) . map ( make_owned_test ) . collect ( ) ;
let tests = tests . iter ( ) . map ( make_owned_test ) . collect ( ) ;
test ::run_tests_console ( opts , tests )
test ::run_tests_console ( opts , tests )
@ -98,8 +99,7 @@ fn make_owned_test(test: &&TestDescAndFn) -> TestDescAndFn {
}
}
/// The following functions are stubs needed to link the test library,
/// The following functions are stubs needed to link the test library,
/// but do nothing because we don't actually need them for it to work (hopefully).
/// but do nothing because we don't actually need them for the runner to work.
// TODO: move to linker-fix-3ds ?
mod link_fix {
mod link_fix {
#[ no_mangle ]
#[ no_mangle ]
extern "C" fn execvp (
extern "C" fn execvp (
@ -114,15 +114,6 @@ mod link_fix {
- 1
- 1
}
}
#[ no_mangle ]
extern "C" fn pthread_sigmask (
_how : ::libc ::c_int ,
_set : * const libc ::sigset_t ,
_oldset : * mut libc ::sigset_t ,
) -> ::libc ::c_int {
- 1
}
#[ no_mangle ]
#[ no_mangle ]
extern "C" fn sigemptyset ( _arg1 : * mut libc ::sigset_t ) -> ::libc ::c_int {
extern "C" fn sigemptyset ( _arg1 : * mut libc ::sigset_t ) -> ::libc ::c_int {
- 1
- 1