Gekkio / mooneye-test-suite

Mooneye Test Suite is a suite of Game Boy test ROMs
MIT License
93 stars 9 forks source link

Wrapper crate #6

Open TylerBloom opened 7 months ago

TylerBloom commented 7 months ago

Would it be possible to wrap the precompiled ROMs in a Rust crate in order to easily include them during testing? I'm willing to contribute to this, but I'd like to know if a similar effort has been proposed and if this is advisable.

Gekkio commented 7 months ago

Something like that could be useful, but I'm not sure what the "API" would be and whether I would be willing to maintain it. I'm a Rust user too, but what about a pip package for Python users, npm package for JS/TS users, etc...? Providing zip/xz/gz releases puts everybody on equal grounds, and requires very little maintenance or complicated build infrastructure.

Gekkio commented 7 months ago

Note that you can automate a zip fetch+unpack in many ways, including a build.rs script. Here's an example: https://gist.github.com/Gekkio/ae7d0e773f2355f4ad8ababfb60166d4

That example script downloads a specific mts version, and generates a source file that can then be included using the include! macro to some file (e.g. lib.rs of a crate). That code includes every ROM as a static byte array, so the API looks like this:

Screenshot from 2024-03-28 22-46-08

But this just one way, and different projects may wish to do this differently, so publishing this as a crates.io crate and keeping up with mts builds would require too much maintenance overhead for relatively little value.

TylerBloom commented 7 months ago

Thanks for responding. The linked build script is close to what I'm looking for. My goal is to be able to run regression tests in CI using the ROM suite. Ideally, this is as simple as cargo test.

As for the API, my thought was simply distributing the ROMs via a library. This would only require defining some module structure (or keeping everything flat) and using include_bytes!. Potentially, the end RAM state might be included, but that too would just be an include_bytes!.

All of that would be possible via a build script and would work in CI. The main reason I think a crate would be useful is that any other emulator devs using Rust could just add the crate as a dev-dependency to gain access to testing data. I would be more than happy to create and maintain this crate, but I didn't want to start this without feedback.