scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Unit test wasm build

Open constraintAutomaton opened this issue 8 months ago • 2 comments

I was wondering if it would be possible to add some unit tests for the WASM build, as I believe there are none currently (I might have looked wrong...). I'd be happy to submit a PR for this if it's something that would be useful.

On a related note, I wanted to ask if it's normal for the WASM build process to be resource-intensive and take a long time. The long wait times are making development a bit frustrating, and I was curious if I am doing something wrong (I am following the process in the readme).

constraintAutomaton avatar Apr 30 '25 06:04 constraintAutomaton

Testing Wasm is really complicated and we just haven't set it up yet. It would involve rewriting most of the tests if I'm not mistaken. See https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/index.html.

And yes, the compilation is indeed really resource intensive. Most of the work is done in the linking if I'm not mistaken, so I suspect breaking the project into multiple crates will eventually help with that, but that's a bit off for now. For now I guess you can use the profile wasm-dev I made specifically for debugging the Wasm build (just put --profile=wasm-dev in the compilation phase), it will probably help a bit.

bakaq avatar Apr 30 '25 06:04 bakaq

// On a target other then `wasm32-unknown-unknown`, the `#[test]` attribute
// will be used instead, allowing this test to run on any target.
#[wasm_bindgen_test(unsupported = test)]
fn all_targets() {
    assert_eq!(1, 2);
}

Huh, it seems it won't involve rewriting or abstracting the tests actually. I think this would be a really high impact contribution because I'm almost sure that the Wasm build is broken in some way that we didn't notice until now precisely because of the lack of testing. Currently the "tests" in CI are just checking that it builds.

bakaq avatar Apr 30 '25 07:04 bakaq