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

Run tests w/ fallback on wasm32-unknown-unknown #1114

Closed
wants to merge 1 commit into from

Conversation

RReverser
Copy link
Contributor

With this change, CI can actually run tests against wasm32-unknown-unknown with the fallback non-threaded implementation, which should help catch any bugs early.

This is a bit invasive, because this target requires a custom #[wasm_bindgen_test] attributes as well as a custom runner instead of the standard #[test], but there is no way around it, and, having those changes only at the top of test files, I believe it's reasonably isolated.

With this change, CI can actually run tests against this target which should help catch any bugs early.

This is a bit invasive, because wasm32-unknown-unknown requires a custom `#[wasm_bindgen_test]` attributes as well as a custom runner instead of the standard `#[test]`, but there is no way around it, and, having those changes only at the top of test files, I believe it's reasonably isolated.
Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit invasive, because this target requires a custom #[wasm_bindgen_test] attributes as well as a custom runner instead of the standard #[test], but there is no way around it, and, having those changes only at the top of test files, I believe it's reasonably isolated.

Is this needed for src/*/test.rs modules too?

targets: wasm32-unknown-unknown
- run: cargo build --verbose --target wasm32-unknown-unknown ${{ matrix.cargoflags }}
- uses: jetli/[email protected]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wary of adding 3rd-party github actions -- can we just use the official installer like I did for wasmtime below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reasonably popular action, but, sure, we can use official installer too, especially since wasm-pack provides prebuilt binaries and doesn't need recompilation from source.

targets: wasm32-unknown-unknown
- run: cargo build --verbose --target wasm32-unknown-unknown ${{ matrix.cargoflags }}
- uses: jetli/[email protected]
- run: wasm-pack test --chrome --headless -- --verbose ${{ matrix.cargoflags }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also test rayon-core?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm probably.

@cuviper
Copy link
Member

cuviper commented Jan 18, 2024

BTW, you should be able to copy the action to pr.yaml temporarily to test it out.

@RReverser
Copy link
Contributor Author

BTW, you should be able to copy the action to pr.yaml temporarily to test it out.

I tested it on my branch by just changing on: merge_group to on: push before submitting instead.

@RReverser
Copy link
Contributor Author

Is this needed for src/*/test.rs modules too?

I didn't even see those but yeah :( This is a bit annoying...

@RReverser
Copy link
Contributor Author

I guess I mainly opened the PR to gather feedback first anyway. On one hand, it's a more invasive change than I'd like (and clearly needs to affect even more places), but, on another, it's potentially useful as it catches more errors.

Do you think it's worth pursuing further?

@cuviper
Copy link
Member

cuviper commented Jan 19, 2024

Maybe it's better to have a more targeted test? Just enough to exercise the web_spin_lock stuff a little, because apart from that we shouldn't really expect much to be different. It could even be a separate crate under ci/ so we don't "infect" the normal build with extra dev-dependencies at all (though that should be sufficiently cfg-isolated).

@RReverser
Copy link
Contributor Author

Just enough to exercise the web_spin_lock stuff a little, because apart from that we shouldn't really expect much to be different.

This test doesn't really verify web_spin_lock - for that I have a small targeted test in wasm-bindgen-rayon. Instead, it verifies the non-threaded fallback behaviour in the browser, which was previously built but never executed.

@RReverser
Copy link
Contributor Author

I guess given that it's already tested by wasm32-wasi, it indeed shouldn't be any different barring bugs in Wasm engines (but then, it's outside of scope of Rayon anyway).

I'll probably close this for now.

@RReverser RReverser closed this Jan 19, 2024
@cuviper
Copy link
Member

cuviper commented Jan 19, 2024

Right, I'm happy with wasi for fallback testing. I thought you were trying to run real wasm threads given the -Z build-std and target-features involved.

@RReverser
Copy link
Contributor Author

I thought you were trying to run real wasm threads given the -Z build-std and target-features involved.

Unfortunately not, as I wrote in that comment it would still require wasm-bindgen-rayon in addition to those flags.

@cuviper
Copy link
Member

cuviper commented Jan 19, 2024

Oh, indeed you did write that -- reading is hard sometimes. 🙂

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.

2 participants