Comments (14)
I am not sure I follow. You write tests as usual, using goroutines/channels and what not, and then just use the tool to execute them in the browser.
from wasmbrowsertest.
What if I want to run goroutines inside the browser, as part of the component being tested? Doesn't the go scheduler need to be invoked somehow by the browser event loop?
from wasmbrowsertest.
The entire Go runtime is compiled into the wasm binary. You can create goroutines as normal and they will be executed as if GOMAXPROCS
was 1. I'd suggest to read some more tutorials on Go WASM to understand it a bit more.
from wasmbrowsertest.
The primary thread, ie GOMAXPROCS 1, in the browser, where does it run? Is it a web worker thread? Or does it share time on the main browser thread? If there is a link somewhere explaining all this, I'd be grateful. I've been googling around trying to find an explanation.
from wasmbrowsertest.
I guess this is it?
from wasmbrowsertest.
Maybe I'm asking the wrong questions. Is there a wasmbrowser test, where the go component being tested is using goroutines, already in github somewhere?
from wasmbrowsertest.
@unicomp21 what is your overall goal here? If your goal is to build a simple program with Go running in the browser, this is a great resource to help you get started: https://www.aaron-powell.com/posts/2019-02-04-golang-wasm-1-introduction/
If you have already taken that step and want to take the next step - writing an app in the browser - then you'll undoubtedly want to also run tests in your browser. wasmbrowsertest helps you do this by spinning up Chrome / Chromedp and the taking your test binary which is compiled with the WASM target, loading it into the browser, and then executing the tests for you and reporting on the test results for you. I think of wasmbrowsertest as a thin layer over top of Go's built in WASM support whose sole purpose is to make sure your tests work in your target GOOS/GOARCH. From a Go language development perspective, it was super important to be able to regression test the Go language across every GOOS/GOARCH it is targeting. Wasmbrowsertest fulfills that need for the WASM compilation target. From an app development perspective this is also helpful - I usually would run my tests against a windows compilation target but the WASM compilation target has some nuances so it's best to test against it too.
I personally took both of the above steps maybe a year ago? The next step was to test code which interacts across the WASM <-> Javascript divide. To do this, you will ultimately need to write your own javascript which interacts with your Go program. Tinygo has some tutorials on how to do this and you can find some other information in the Golang language's WASM help center. This step will NOT involve wasmbrowsertest because wasmbrowsertest was not created to run your func main
- it was created to run your func TestMain
. To complete this step I did a lot of manual testing.
If you understand the basics of how the whole chain of technologies work together - Go, WASM, JS - then at least for me I had an "ah ha!" moment and I understood how wasmbrowsertest works.
from wasmbrowsertest.
I think the problem right now @unicomp21 is that your questions don't exactly make sense.
wasmbrowsertest is an infrastructure tool. It does not know or care how Golang deals with GOMAXPROCS, goroutines, or any other language feature is mapped into WASM. Its job is to take a WASM binary which was compiled by the Go language, put it into a browser, run the binary, and then convert the outputs from the WASM code into a format which is identical or nearly identical to the outputs from the go test
command we all know and love.
from wasmbrowsertest.
If your goal is to learn about how Go's WASM compilation target works, I strongly recommend first following that tutorial I linked and then reading all of the files in https://github.com/golang/go/tree/master/misc/wasm
TinyGo has similar files which you have already linked which have similar educational value (although I personally am completely unaware of how TinyGo works).
from wasmbrowsertest.
It does not know or care how Golang deals with GOMAXPROCS
That's the problem, I do care. My struggle is understanding how the executor/scheduler is working in both the test runner and in the actual web browser app.
from wasmbrowsertest.
The primary thread, ie GOMAXPROCS 1, in the browser, where does it run? Is it a web worker thread?
I feel like you are asking how does WebAssembly work. There are tons of material out there which should help you get started.
Here are some talks that you can watch: https://github.com/golang/go/wiki/webassembly#go-webassembly-talks
Here's an introductory blog post I wrote: https://blog.gopheracademy.com/advent-2018/go-in-the-browser/.
If you have further questions, please feel free to drop in to the #webassembly channel in Gophers slack.
I'll close the issue as I think it's out of scope for this tool. But if you have any questions on the tool, please feel free to create a new issue.
from wasmbrowsertest.
from wasmbrowsertest.
lol
The slack channel is perfect for the questions you are asking.
from wasmbrowsertest.
Perhaps this would have been better in discussions ;)
Not really, what you are asking about isn't about wasmbrowsertest. :) The slack channel would be great for this.
from wasmbrowsertest.
Related Issues (17)
- Need GPU disabled in chromedp to run HOT 17
- Tests work in real Chrome in Windows but not chromedp in WSL HOT 1
- Run examples HOT 12
- wasmbrowsertest taking too long and not printing any output HOT 39
- "panic: newosproc: not implemented" when executing in travis HOT 1
- `could not dial` errors on the latest Chrome on GitHub Actions HOT 4
- Support -shuffle flag HOT 1
- Accept permission HOT 2
- please enable discussions on this repo HOT 4
- Is there an example dockerfile? HOT 1
- Error: command line too long HOT 6
- cross browser testing HOT 5
- using -- to signify end of options HOT 8
- `total length of command line and environment variables exceeds limit` in GitHub Actions HOT 27
- Support collecting code coverage HOT 7
- Support passing through environment variables HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasmbrowsertest.