diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6232d2bbb..93116e987 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,6 +38,7 @@ jobs: - name: go build run: | go build -tags=example -v ./... + env GOOS=js GOARCH=wasm go build -tags=example -v ./... env GOOS=windows GOARCH=amd64 go build -tags=example -v ./... env GOOS=windows GOARCH=386 go build -tags=example -v ./... @@ -73,6 +74,7 @@ jobs: - name: go build run: | go build -tags=example -v ./... + env GOOS=js GOARCH=wasm go build -tags=example -v ./... env GOOS=windows GOARCH=amd64 go build -tags=example -v ./... env GOOS=windows GOARCH=386 go build -tags=example -v ./... @@ -113,6 +115,7 @@ jobs: - name: go build run: | go build -tags=example -v ./... + env GOOS=js GOARCH=wasm go build -tags=example -v ./... - name: go test run: | diff --git a/image_test.go b/image_test.go index 1a8363628..0be73fd53 100644 --- a/image_test.go +++ b/image_test.go @@ -22,7 +22,9 @@ import ( "image/draw" _ "image/png" "math" + "regexp" "runtime" + "strconv" "testing" . "github.com/hajimehoshi/ebiten" @@ -32,6 +34,28 @@ import ( "github.com/hajimehoshi/ebiten/internal/web" ) +func skipTooSlowTests(t *testing.T) bool { + if web.IsGopherJS() { + t.Skip("too slow on GopherJS") + return true + } + if runtime.GOOS == "js" { + v := runtime.Version() + if m := regexp.MustCompile(`^go(\d+)\.(\d+)$`).FindStringSubmatch(v); m != nil { + major, _ := strconv.Atoi(m[1]) + minor, _ := strconv.Atoi(m[2]) + + // In Go1.12, converting JS arrays from/to slices uses TypedArrayOf, and this might allocates + // too many ArrayBuffers. + if major == 1 && minor <= 12 { + t.Skip(fmt.Sprintf("too slow on Go%d.%dWasm", major, minor)) + return true + } + } + } + return false +} + func TestMain(m *testing.M) { t.MainWithRunLoop(m) } @@ -545,8 +569,7 @@ func TestImageClear(t *testing.T) { func TestImageEdge(t *testing.T) { // TODO: This test is not so meaningful after #1218. Do we remove this? - if web.IsGopherJS() { - t.Skip("too slow on GopherJS") + if skipTooSlowTests(t) { return } @@ -899,8 +922,7 @@ func TestImageCopy(t *testing.T) { // Issue #611, #907 func TestImageStretch(t *testing.T) { - if web.IsGopherJS() { - t.Skip("too slow on GopherJS") + if skipTooSlowTests(t) { return }