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 - name: go build
run: | run: |
go build -tags=example -v ./... 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=amd64 go build -tags=example -v ./...
env GOOS=windows GOARCH=386 go build -tags=example -v ./... env GOOS=windows GOARCH=386 go build -tags=example -v ./...
@ -73,6 +74,7 @@ jobs:
- name: go build - name: go build
run: | run: |
go build -tags=example -v ./... 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=amd64 go build -tags=example -v ./...
env GOOS=windows GOARCH=386 go build -tags=example -v ./... env GOOS=windows GOARCH=386 go build -tags=example -v ./...
@ -113,6 +115,7 @@ jobs:
- name: go build - name: go build
run: | run: |
go build -tags=example -v ./... go build -tags=example -v ./...
env GOOS=js GOARCH=wasm go build -tags=example -v ./...
- name: go test - name: go test
run: | run: |

View File

@ -22,7 +22,9 @@ import (
"image/draw" "image/draw"
_ "image/png" _ "image/png"
"math" "math"
"regexp"
"runtime" "runtime"
"strconv"
"testing" "testing"
. "github.com/hajimehoshi/ebiten" . "github.com/hajimehoshi/ebiten"
@ -32,6 +34,28 @@ import (
"github.com/hajimehoshi/ebiten/internal/web" "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) { func TestMain(m *testing.M) {
t.MainWithRunLoop(m) t.MainWithRunLoop(m)
} }
@ -545,8 +569,7 @@ func TestImageClear(t *testing.T) {
func TestImageEdge(t *testing.T) { func TestImageEdge(t *testing.T) {
// TODO: This test is not so meaningful after #1218. Do we remove this? // TODO: This test is not so meaningful after #1218. Do we remove this?
if web.IsGopherJS() { if skipTooSlowTests(t) {
t.Skip("too slow on GopherJS")
return return
} }
@ -899,8 +922,7 @@ func TestImageCopy(t *testing.T) {
// Issue #611, #907 // Issue #611, #907
func TestImageStretch(t *testing.T) { func TestImageStretch(t *testing.T) {
if web.IsGopherJS() { if skipTooSlowTests(t) {
t.Skip("too slow on GopherJS")
return return
} }