tinygo/tests/wasm/chan_test.go
Ayke van Laethem 1d2c17753a tests: improve wasm tests slightly
These wasm tests weren't passing in GitHub Actions and also weren't
passing on my laptop. I'm not sure why, I think there are a few race
conditions that are going on.

This commit attempts to fix this at least to a degree:

  - The context deadline is increased from 5 seconds to 10 seconds.
  - The tests are not running in parallel anymore.
  - Some `Sleep` calls were removed, they do not appear to be necessary
    (and if they were, sleeping is the wrong solution to solve race
    conditions).

Overall the tests are taking a few seconds more, but on the other hand
they seem to be passing more reliable. At least for me, on my laptop
(and hopefully also in CI).
2021-11-21 12:17:34 +01:00

32 строки
457 Б
Go

package wasm
import (
"testing"
"github.com/chromedp/chromedp"
)
func TestChan(t *testing.T) {
wasmTmpDir, server := startServer(t)
err := run(t, "tinygo build -o "+wasmTmpDir+"/chan.wasm -target wasm testdata/chan.go")
if err != nil {
t.Fatal(err)
}
ctx, cancel := chromectx()
defer cancel()
err = chromedp.Run(ctx,
chromedp.Navigate(server.URL+"/run?file=chan.wasm"),
waitLog(`1
4
2
3
true`),
)
if err != nil {
t.Fatal(err)
}
}