ebiten: Skip some tests on Go1.12 Wasm

This commit is contained in:
Hajime Hoshi 2020-08-17 04:12:31 +09:00
parent 16697ffbf2
commit a48c0d9f2c
2 changed files with 29 additions and 4 deletions

View File

@ -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: |

View File

@ -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
}