ebiten: Use internal/testing for tests

This commit is contained in:
Hajime Hoshi 2020-04-01 18:34:59 +09:00
parent ab94cebd02
commit 19333c51e4

View File

@ -16,13 +16,11 @@ package ebiten_test
import ( import (
"bytes" "bytes"
"errors"
"image" "image"
"image/color" "image/color"
"image/draw" "image/draw"
_ "image/png" _ "image/png"
"math" "math"
"os"
"runtime" "runtime"
"testing" "testing"
@ -30,24 +28,11 @@ import (
"github.com/hajimehoshi/ebiten/ebitenutil" "github.com/hajimehoshi/ebiten/ebitenutil"
"github.com/hajimehoshi/ebiten/examples/resources/images" "github.com/hajimehoshi/ebiten/examples/resources/images"
"github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/testflock" t "github.com/hajimehoshi/ebiten/internal/testing"
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
testflock.Lock() t.MainWithRunLoop(m)
defer testflock.Unlock()
code := 0
// Run an Ebiten process so that (*Image).At is available.
regularTermination := errors.New("regular termination")
f := func(screen *Image) error {
code = m.Run()
return regularTermination
}
if err := Run(f, 320, 240, 1, "Test"); err != nil && err != regularTermination {
panic(err)
}
os.Exit(code)
} }
func openEbitenImage() (*Image, image.Image, error) { func openEbitenImage() (*Image, image.Image, error) {