Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove test-runner crate #20

Merged
merged 8 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,19 @@ on:
workflow_dispatch:

jobs:
lint:
strategy:
matrix:
toolchain:
- nightly-2024-02-18

runs-on: ubuntu-latest
container: devkitpro/devkitarm
steps:
- name: Checkout branch
uses: actions/checkout@v4

- uses: ./setup
with:
toolchain: ${{ matrix.toolchain }}

- name: Check formatting
working-directory: test-runner
run: cargo fmt --all --verbose -- --check

- name: Run clippy
working-directory: test-runner
run: cargo 3ds clippy --color=always --verbose --all-targets

test:
strategy:
matrix:
toolchain:
# Oldest supported nightly
- nightly-2024-02-18
- nightly
ctru-rs-ref:
# "known good" version of `test-runner` crate
- 3247af67d5f9aafb0ea4af485a81b74ce922c8af
- master

continue-on-error: ${{ matrix.toolchain == 'nightly' }}
continue-on-error: ${{ matrix.toolchain == 'nightly' || matrix.ctru-rs-ref == 'master' }}
runs-on: ubuntu-latest
container:
image: devkitpro/devkitarm
Expand All @@ -57,11 +37,17 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}

- uses: actions/checkout@v4
with:
repository: 'rust3ds/ctru-rs'
path: 'ctru-rs'
ref: ${{ matrix.ctru-rs-ref }}

- name: Build and run tests (unit + integration)
uses: ./run-tests
with:
working-directory: test-runner
args: -- -v
working-directory: ctru-rs
args: --package test-runner -- -v

- name: Build and run doc tests
# Still run doc tests even if lib/integration tests fail:
Expand All @@ -72,8 +58,8 @@ jobs:
RUSTDOCFLAGS: " --persist-doctests target/armv6k-nintendo-3ds/debug/doctests"
uses: ./run-tests
with:
working-directory: test-runner
args: --doc -- -v
working-directory: ctru-rs
args: --package test-runner --doc -- -v

- name: Upload citra logs and capture videos
uses: actions/upload-artifact@v3
Expand Down
43 changes: 7 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
# test-runner

A set of tools for running automated Rust tests against Citra (3DS emulator).
A set of Github Actions for working with 3DS applications and the `rust3ds` toolchain.

It's recommended to use the `test-runner` crate from [ctru-rs](https://github.com/rust3ds/ctru-rs)
when working with these actions, in order to get useful test output on failures.

## Components

* `test-runner`: a Rust crate for writing tests for 3DS homebrew
* GitHub Actions:
* `setup`: action for setting up the Rust 3DS toolchain in workflows
* `run-tests`: action for running test executables with Citra in workflows
* `setup`: action for setting up the Rust 3DS toolchain in workflows
* `run-tests`: action for running test executables with Citra in workflows

## Usage

First the test runner to your crate:

```sh
cargo add --dev test-runner --git https://github.com/rust3ds/test-runner
```

In `lib.rs` and any integration test files:

```rs
#![feature(custom_test_frameworks)]
#![test_runner(test_runner::run_gdb)]
```

Then use the `setup` and `run-tests` actions in your github workflow. This
example shows the default value for each of the inputs.
This example shows the default value for each of the inputs.

```yml
jobs:
Expand Down Expand Up @@ -66,25 +53,9 @@ using these actions (including uploading output artifacts from the tests).

## Caveats

* GDB doesn't seem to support separate output streams for `stdout` and `stderr`,
so all test output to `stderr` will end up combined with `stdout` and both will be
printed to the runner's `stdout`. If you know a workaround for this that doesn't
require patching + building GDB itself please open an issue about it!

* Since the custom test runner runs as part of `cargo test`, it won't be able to
find a `3dsx` that hasn't built yet. `cargo-3ds` doesn't build `3dsx` executables until
_after_ the cargo command it runs internally, so this means that tests can't depend
on any features of the `3dsx` (like embedded romFS). A workaround for this is to
simply build the tests as a separate step before running them, after which the
runner will be able to find the `3dsx`.

* 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 (or `fn main()` if the test defines it):

```rust
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.
18 changes: 0 additions & 18 deletions test-runner/Cargo.toml

This file was deleted.

54 changes: 0 additions & 54 deletions test-runner/src/console.rs

This file was deleted.

77 changes: 0 additions & 77 deletions test-runner/src/gdb.rs

This file was deleted.

Loading
Loading