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

wasm Testing Infrastructure #3162

Closed
cwfitzgerald opened this issue Nov 1, 2022 · 6 comments
Closed

wasm Testing Infrastructure #3162

cwfitzgerald opened this issue Nov 1, 2022 · 6 comments
Labels
api: gles Issues with GLES or WebGL api: webgpu Issues with direct interface with WebGPU area: tests Improvements or issues with our test suite help required We need community help to make this happen. type: enhancement New feature or request

Comments

@cwfitzgerald
Copy link
Member

We currently are only able to run our tests on native. We should implement support for running our tests on top of WebGL/WebGPU in a headless browser.

This would consist of a couple changes:

  • Exposing tests to wasm-bindgen-tests
  • On wasm, the test harness needs to create a canvas, resize it, and make a surface from that, before we request an adapter (as webgl requires a surface to find an adapter at all)
  • Add a CI job that runs the tests using wasm-pack test using a headless chrome instance.

Our tests are designed to be run from separate processes, but running single threaded is okay, so we should be fine.

We may need to embed the test images into the binary because we don't have file IO.

@cwfitzgerald cwfitzgerald added api: gles Issues with GLES or WebGL api: webgpu Issues with direct interface with WebGPU area: tests Improvements or issues with our test suite help required We need community help to make this happen. type: enhancement New feature or request labels Nov 1, 2022
@haraldreingruber-dedalus
Copy link
Contributor

This sounds interesting for me.
I would like to work on a first "dummy test" proof-of-concept.

I guess running something like the hello-triangle example as a wasm-bindgen test in a headless chrome via GH actions would be a good scope for a first version?
Or did you have something other than rendering a triangle in mind?

@cwfitzgerald
Copy link
Member Author

hello-triangle doesn't actually have a corresponding test, so that wouldn't be useful for testing.

Getting https://github.com/gfx-rs/wgpu/blob/master/wgpu/tests/device.rs#L3 working would be a good first shot to make sure the initialize_test function is fully up to snuff to create a context in the web. Once that is going and working in the web, the other tests should be as simple as making them accessable to the wasm-bindgen harness.

@haraldreingruber
Copy link
Contributor

@cwfitzgerald I started a quick&dirty prototype of what I had in mind: #3238

Maybe it's easier now for exchanging more specific ideas.
It's more of an integration test, verifying the expected result of 2 pixels in the rendering result.

Could fn init() be reused for the mentioned test in device.rs? What would you try to verify after initializing the device? Or would not panicking be sufficient?

@cwfitzgerald
Copy link
Member Author

I added a couple comments to the PR.

What would you try to verify after initializing the device?

Nothing, that test is just checking that the device is made correctly.

Could fn init() be reused for the mentioned test in device.rs?

The end goal here is to get the wasm testing adaptations (the canvas/surface setup stuff in init.rs) into initialize_test such that we can run all of our normal tests in wasm without modifying them at all. We don't actually need a surface, except to get the Webgl2 context. I specified device.rs only because it's just testing device creation - so if you get that test working, you should be able to get the test of them working by just appropriately attributing them.

@haraldreingruber
Copy link
Contributor

Ah okay, I think I am starting to understand.

Is the idea to add #[wasm_bindgen_test] to every #[test] function?

@cwfitzgerald
Copy link
Member Author

Yup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: gles Issues with GLES or WebGL api: webgpu Issues with direct interface with WebGPU area: tests Improvements or issues with our test suite help required We need community help to make this happen. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants