-
Notifications
You must be signed in to change notification settings - Fork 18k
all: test Examples on wasm? #25933
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
Comments
Do you have any initial idea on how we could do this? |
Options:
|
For reference, I added this support to GopherJS some time ago (See gopherjs/gopherjs#590), by having the tests write to the filesystem, rather than to a pipe, so basically an implementation of @bradfitz's first suggestion. |
I read the code that runs examples, and it just treats the two parts of the os.Pipe as ReadCloser and WriteCloser, and it doesn't leverage the fact that those are actual files. The problem here is that it then replaces os.Stdout, and that must be an *os.File. I think we could provide a dummy implementation of os.Pipe for wasm that creates two *os.File by just wrapping a call to io.Pipe() and returning a couple of partially functioning files. Any invocation to methods that are not Write, Read or Close would just return an error and zero values, but that would still make most (if not all) examples work. I did a quick grep around sources looking for examples that might break but it looks like this might work. If this makes any sense I could try it out locally to see how many examples leverage the fact that os.Stdout is indeed an *os.File and report back or submit a CL if nothing breaks. |
Change https://golang.org/cl/165097 mentions this issue: |
Alright, so since we've merged CL https://go-review.googlesource.com/c/go/+/165357 which uses os.File for js/wasm, I think the party can now start, with enabling example tests to run on js/wasm. |
Change https://golang.org/cl/167800 mentions this issue: |
In #25913 we disabled testing of Example for js/wasm because it required os.Pipe, which js/wasm doesn't implement.
But disabling all those tests is slightly overkill.
This bug tracks restoring as many of those tests as possible.
/cc @neelance
The text was updated successfully, but these errors were encountered: