Skip to content

Commit

Permalink
Introduce end-to-end tests
Browse files Browse the repository at this point in the history
For now I have added the most simple example for an NES/Famicom game,
which I already had on a private repository (that I plan to open source
soonish).

Tests simply run `nasm` on known source files and compares the results
with an .nes ROM file that has the exact bytes that we expect.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Dec 20, 2024
1 parent d88fab8 commit 0087cc0
Show file tree
Hide file tree
Showing 6 changed files with 644 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ jobs:
- name: Run Clippy
run: cargo clippy --all-targets --all-features

e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Ensure latest Rust stable
run: |
rustup update stable
rustup default stable
- name: Run end-to-end tests
run: bash ./scripts/test-e2e.sh

fuzz_parser:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions scripts/full-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ cargo build --all --all-targets --all-features
cargo clippy --all-targets --all-features
cargo test --all-targets --all-features -- --nocapture

./scripts/test-e2e.sh

pushd lib/xixanta
cargo +nightly fuzz run fuzz_target_parser -- -max_total_time=180
cargo +nightly fuzz run fuzz_target_assembler -- -max_total_time=180
Expand Down
11 changes: 11 additions & 0 deletions scripts/test-e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh

set -ex

rm -rf tests/out/
mkdir -p tests/out/

cargo build

./target/debug/nasm -c nrom -Werror -o tests/out/sprite.nes tests/src/sprite.s
diff tests/out/sprite.nes tests/bin/sprite.nes
Binary file added tests/assets/basic.chr
Binary file not shown.
Binary file added tests/bin/sprite.nes
Binary file not shown.
Loading

0 comments on commit 0087cc0

Please sign in to comment.