Meziu
1 year ago
committed by
GitHub
25 changed files with 418 additions and 240 deletions
@ -1,46 +0,0 @@ |
|||||||
name: Setup |
|
||||||
description: Set up CI environment for Rust + 3DS development |
|
||||||
|
|
||||||
inputs: |
|
||||||
toolchain: |
|
||||||
description: The Rust toolchain to use for the steps |
|
||||||
required: true |
|
||||||
default: nightly |
|
||||||
|
|
||||||
runs: |
|
||||||
using: composite |
|
||||||
steps: |
|
||||||
# https://github.com/nektos/act/issues/917#issuecomment-1074421318 |
|
||||||
- if: ${{ env.ACT }} |
|
||||||
shell: bash |
|
||||||
name: Hack container for local development |
|
||||||
run: | |
|
||||||
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - |
|
||||||
sudo apt-get install -y nodejs |
|
||||||
|
|
||||||
- name: Setup default Rust toolchain |
|
||||||
# Use this helper action so we get matcher support |
|
||||||
# https://github.com/actions-rust-lang/setup-rust-toolchain/pull/15 |
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1 |
|
||||||
with: |
|
||||||
components: clippy, rustfmt, rust-src |
|
||||||
toolchain: ${{ inputs.toolchain }} |
|
||||||
|
|
||||||
- name: Install build tools for host |
|
||||||
shell: bash |
|
||||||
run: sudo apt-get update && sudo apt-get install -y build-essential |
|
||||||
|
|
||||||
- name: Install cargo-3ds |
|
||||||
uses: actions-rs/cargo@v1 |
|
||||||
with: |
|
||||||
command: install |
|
||||||
# TODO: this should probably just be a released version from crates.io |
|
||||||
# once cargo-3ds gets published somewhere... |
|
||||||
args: >- |
|
||||||
--git https://github.com/rust3ds/cargo-3ds |
|
||||||
--rev 78a652fdfb01e2614a792d1a56b10c980ee1dae9 |
|
||||||
|
|
||||||
- name: Set PATH to include devkitARM |
|
||||||
shell: bash |
|
||||||
# For some reason devkitARM/bin is not part of the default PATH in the container |
|
||||||
run: echo "${DEVKITARM}/bin" >> $GITHUB_PATH |
|
@ -1,73 +0,0 @@ |
|||||||
//! Custom test runner for building/running unit tests on the 3DS.
|
|
||||||
|
|
||||||
extern crate test; |
|
||||||
|
|
||||||
use std::io; |
|
||||||
|
|
||||||
use test::{ColorConfig, OutputFormat, TestDescAndFn, TestFn, TestOpts}; |
|
||||||
|
|
||||||
use crate::prelude::*; |
|
||||||
|
|
||||||
/// 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
|
|
||||||
/// panic is just treated the same as any normal application panic).
|
|
||||||
pub(crate) fn run(tests: &[&TestDescAndFn]) { |
|
||||||
let gfx = Gfx::new().unwrap(); |
|
||||||
let mut hid = Hid::new().unwrap(); |
|
||||||
let apt = Apt::new().unwrap(); |
|
||||||
|
|
||||||
let mut top_screen = gfx.top_screen.borrow_mut(); |
|
||||||
top_screen.set_wide_mode(true); |
|
||||||
let _console = Console::new(top_screen); |
|
||||||
|
|
||||||
let opts = TestOpts { |
|
||||||
force_run_in_process: true, |
|
||||||
run_tests: true, |
|
||||||
// TODO: color doesn't work because of TERM/TERMINFO.
|
|
||||||
// With RomFS we might be able to fake this out nicely...
|
|
||||||
color: ColorConfig::AutoColor, |
|
||||||
format: OutputFormat::Pretty, |
|
||||||
// Hopefully this interface is more stable vs specifying individual options,
|
|
||||||
// and parsing the empty list of args should always work, I think.
|
|
||||||
// TODO Ideally we could pass actual std::env::args() here too
|
|
||||||
..test::test::parse_opts(&[]).unwrap().unwrap() |
|
||||||
}; |
|
||||||
// Use the default test implementation with our hardcoded options
|
|
||||||
let _success = run_static_tests(&opts, tests).unwrap(); |
|
||||||
|
|
||||||
// Make sure the user can actually see the results before we exit
|
|
||||||
println!("Press START to exit."); |
|
||||||
|
|
||||||
while apt.main_loop() { |
|
||||||
gfx.wait_for_vblank(); |
|
||||||
|
|
||||||
hid.scan_input(); |
|
||||||
if hid.keys_down().contains(KeyPad::START) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// Adapted from [`test::test_main_static`] and [`test::make_owned_test`].
|
|
||||||
fn run_static_tests(opts: &TestOpts, tests: &[&TestDescAndFn]) -> io::Result<bool> { |
|
||||||
let tests = tests.iter().map(make_owned_test).collect(); |
|
||||||
test::run_tests_console(opts, tests) |
|
||||||
} |
|
||||||
|
|
||||||
/// Clones static values for putting into a dynamic vector, which test_main()
|
|
||||||
/// needs to hand out ownership of tests to parallel test runners.
|
|
||||||
///
|
|
||||||
/// This will panic when fed any dynamic tests, because they cannot be cloned.
|
|
||||||
fn make_owned_test(test: &&TestDescAndFn) -> TestDescAndFn { |
|
||||||
match test.testfn { |
|
||||||
TestFn::StaticTestFn(f) => TestDescAndFn { |
|
||||||
testfn: TestFn::StaticTestFn(f), |
|
||||||
desc: test.desc.clone(), |
|
||||||
}, |
|
||||||
TestFn::StaticBenchFn(f) => TestDescAndFn { |
|
||||||
testfn: TestFn::StaticBenchFn(f), |
|
||||||
desc: test.desc.clone(), |
|
||||||
}, |
|
||||||
_ => panic!("non-static tests passed to test::test_main_static"), |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue