Skip to content

Commit

Permalink
Merge pull request #12 from ian-h-chamberlain/fix/find-3dsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-h-chamberlain authored Sep 30, 2023
2 parents abe134b + 0794cc2 commit adf4d57
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,28 @@ jobs:
See [`ci.yml`](.github/workflows/ci.yml) to see a full lint and test workflow
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.
15 changes: 9 additions & 6 deletions run-tests/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash

# Uncomment for debugging the action itself. Maybe consider a job summary or
# grouping the output, to keep this stuff visible but make it simpler to use:
# TODO: Maybe consider a job summary or grouping the output, to keep xtrace output
# visible but make it simpler to use:
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
# set -o xtrace

# set -x
set -o nounset
set -o pipefail

function cleanup_jobs() {
# shellcheck disable=SC2317 # Unreachable because it's only used in trap
Expand All @@ -21,15 +23,16 @@ function cleanup_jobs() {
trap cleanup_jobs EXIT

EXE_ELF=$1
EXE_3DSX="$(dirname "$EXE")/$(basename "$EXE" .elf).3dsx"
EXE_NOEXT="$(dirname "$EXE_ELF")/$(basename "$EXE_ELF" .elf)"
EXE_3DSX="$EXE_NOEXT.3dsx"

EXE_TO_RUN="$EXE_ELF"
if [ -f "$EXE_3DSX" ]; then
echo >&2 "Found $(basename "$EXE_3DSX"), it will be run instead of $(basename "$EXE_ELF")"
EXE_TO_RUN="$EXE_3DSX"
fi

VIDEO_OUT="$(dirname "$EXE_ELF")/$(basename "$EXE_ELF" .elf)_capture.webm"
VIDEO_OUT="${EXE_NOEXT}_capture.webm"

CITRA_LOG_DIR=~/.local/share/citra-emu/log
CITRA_OUT="$CITRA_LOG_DIR/citra_output.txt"
Expand All @@ -54,7 +57,7 @@ cleanup_jobs
CITRA_LOG="$CITRA_LOG_DIR/citra_log.txt"

for f in "$CITRA_LOG" "$CITRA_OUT"; do
OUT="$(dirname "$EXE_ELF")/$(basename "$EXE_ELF" .elf)_$(basename "$f")"
OUT="${EXE_NOEXT}_$(basename "$f")"
if test -f "$f"; then
cp "$f" "$OUT"
if [ $STATUS -ne 0 ]; then
Expand Down

0 comments on commit adf4d57

Please sign in to comment.