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

Add unit test infrastructure #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add unit test infrastructure #5

wants to merge 3 commits into from

Conversation

tstirrat
Copy link
Owner

@tstirrat tstirrat commented Jul 24, 2024

Based on https://github.com/untoxa/gbdk_unit_test, but uses pytest as the test runner:

  • More expression in assertions
  • Much easier to debug

General struture:

  • Makefile set up so that for any rom.c, you can make build/rom.gb
  • snapshot fixture, that will build + run + snapshot before each test (use indirect=True with parametrize())

Example:

# my_rom.c contains a simple rom that calls EMU_BREAKPOINT

# snapshot calls "make build/my_rom.gb" and then runs the rom and captures the snapshot
@pytest.mark.parametrize('snapshot', ['build/my_rom.gb'], indirect=True)
def it_does_something(snapshot):
    rAUD1LOW = get(snapshot, 'IO_REG', '_NR13_REG')
    assert rAUD1LOW == 0x72

@tstirrat tstirrat force-pushed the tstirrat-tests branch 6 times, most recently from 4826247 to 46934b4 Compare July 25, 2024 12:46
@tstirrat tstirrat marked this pull request as ready for review July 25, 2024 12:48
@tstirrat tstirrat force-pushed the tstirrat-big-c-refactor branch from 9fb3ba3 to ed61a57 Compare July 25, 2024 14:50
@tstirrat tstirrat changed the base branch from tstirrat-big-c-refactor to master July 25, 2024 14:52
@tstirrat tstirrat force-pushed the tstirrat-tests branch 5 times, most recently from 565d8de to 0b1e71a Compare July 25, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant