tinygo/tests/wasm/fmt_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 строки
535 Б
Go

package wasm
import (
"testing"
"github.com/chromedp/chromedp"
)
func TestFmt(t *testing.T) {
wasmTmpDir, server := startServer(t)
err := run(t, "tinygo build -o "+wasmTmpDir+"/fmt.wasm -target wasm testdata/fmt.go")
if err != nil {
t.Fatal(err)
}
ctx, cancel := chromectx()
defer cancel()
var log1 string
err = chromedp.Run(ctx,
chromedp.Navigate(server.URL+"/run?file=fmt.wasm"),
chromedp.InnerHTML("#log", &log1),
waitLog(`did not panic`),
)
t.Logf("log1: %s", log1)
if err != nil {
t.Fatal(err)
}
}