A helper crate for running automated Rust tests on a 3DS. Since the builtin
Rust test framework expects a more traditional OS with subprocesses etc.,
it's necessary to use custom_test_frameworks when running tests on 3DS
hardware or in an emulator to get a similar experience as a usual cargo test.
First the test runner to your crate:
cargo add --dev test-runner --git https://github.com/rust3ds/ctru-rsIn lib.rs and any integration test files:
#![feature(custom_test_frameworks)]
#![test_runner(test_runner::run_gdb)]-
GDB doesn't seem to support separate output streams for
stdoutandstderr, so all test output tostderrwill end up combined withstdoutand both will be printed to the runner'sstdout. If you know a workaround for this that doesn't require patching + building GDB itself please open an issue about it! -
Doctests require a bit of extra setup to work with the runner, since they don't use the crate's
#![test_runner]. To write doctests, add the following to the beginning of the doctest (orfn main()if the test defines it):let _runner = test_runner::GdbRunner::default();
The runner must remain in scope for the duration of the test in order for the test output to be printed.