bjorn3 / browser_wasi_shim

A WASI shim for in the browser
Apache License 2.0
299 stars 40 forks source link

Added browser tests using wasmtime test artifacts #42

Open jsoverson opened 11 months ago

jsoverson commented 11 months ago

This PR adds the start of browser-based tests. It adds a playwright configuration to test across Firefox, Chromium, and Webkit and uses test artifacts from the wasmtime project to assert compatibility.

Only one test has been added so far (test-programs/preview1_path_open_read_write). It required some project changes that need review before moving forward.

To run tests:

$ npm install
$ npm run test:build  # clone wasmtime and compile test .wasm
$ npm run build       # compile project typescript
$ npm run test        # run tests

Change Notes:

jsoverson commented 11 months ago

@bjorn3 I hope these changes are again in the right direction. Testing could go any one of a dozen ways, and this seemed like the best cost/value.

bjorn3 commented 11 months ago

Using wasmtime's wasi tests is a great idea. Thanks for working on this. FYI I probably won't have time to review this in the next couple of days.

Part of https://github.com/bjorn3/browser_wasi_shim/issues/7

jsoverson commented 11 months ago

@bjorn3 np, thanks for being willing and responsive!

bjorn3 commented 11 months ago

I'm not entirely sure all fs_rights_base changes are correct. Would you mind pulling out all changes to the actual code except for fs_rights_base into a separate PR? Also could you add CI integration?

bjorn3 commented 9 months ago

@jsoverson are you still interested in working on this or would you prefer if I work on splitting it up into several commits and landing it myself?

jsoverson commented 9 months ago

@bjorn3 sorry, this fell off my radar during a few hectic weeks. I'll jump on it this coming week.

jsoverson commented 9 months ago

Status: I'm going to fork wasmtime to create releases consisting of strictly the test wasm files. Getting CI setup to clone wasmtime to build the test artifacts is excessive.

bjorn3 commented 9 months ago

You can use --filter=blob:none when cloning to tell git to only fetch the blobs that are actually necessary. For me that only takes 10s for a total download of 24MB. It can be reduced even further using a sparse checkout, but I think 10s is more than fast enough.

jsoverson commented 9 months ago

It's more the overhead of setting up a rust environment to build wasm files that really shouldn't change. It will dramatically extend the duration of CI tests, vs. downloading a tarball of wasm artifacts.

bjorn3 commented 9 months ago

I see. How about caching the wasm test files in a github actions cache after they are built. And then only setup a rust toolchain for building if the cache is missing. That should be easier to keep up to date with new wasmtime versions than building locally and checking into a repo.