mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
parent
e77eb9f80f
commit
9902497e3d
@ -29,9 +29,13 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/images"
|
||||
emath "github.com/hajimehoshi/ebiten/internal/math"
|
||||
"github.com/hajimehoshi/ebiten/internal/testflock"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testflock.Lock()
|
||||
defer testflock.Unlock()
|
||||
|
||||
code := 0
|
||||
// Run an Ebiten process so that (*Image).At is available.
|
||||
regularTermination := errors.New("regular termination")
|
||||
|
@ -26,9 +26,13 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
. "github.com/hajimehoshi/ebiten/internal/restorable"
|
||||
"github.com/hajimehoshi/ebiten/internal/testflock"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testflock.Lock()
|
||||
defer testflock.Unlock()
|
||||
|
||||
EnableRestoringForTesting()
|
||||
code := 0
|
||||
regularTermination := errors.New("regular termination")
|
||||
|
@ -25,9 +25,13 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
. "github.com/hajimehoshi/ebiten/internal/shareable"
|
||||
"github.com/hajimehoshi/ebiten/internal/testflock"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testflock.Lock()
|
||||
defer testflock.Unlock()
|
||||
|
||||
code := 0
|
||||
regularTermination := errors.New("regular termination")
|
||||
f := func(screen *ebiten.Image) error {
|
||||
@ -42,8 +46,7 @@ func TestMain(m *testing.M) {
|
||||
|
||||
const bigSize = 2049
|
||||
|
||||
// Temporary disabled per #575.
|
||||
func Disabled_TestEnsureNotShared(t *testing.T) {
|
||||
func TestEnsureNotShared(t *testing.T) {
|
||||
// Create img1 and img2 with this size so that the next images are allocated
|
||||
// with non-upper-left location.
|
||||
img1 := NewImage(bigSize, 100)
|
||||
|
41
internal/testflock/flock.go
Normal file
41
internal/testflock/flock.go
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2018 The Ebiten Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package testflock provides a lock for testing.
|
||||
//
|
||||
// There is a CI service like TravisCI where multiple OpenGL processes
|
||||
// don't work well at the same time, and tests with an OpenGL main routine
|
||||
// should be protected by a file lock (#575).
|
||||
package testflock
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/theckman/go-flock"
|
||||
)
|
||||
|
||||
var theLock = flock.NewFlock(filepath.Join(os.TempDir(), "ebitentest"))
|
||||
|
||||
func Lock() {
|
||||
if err := theLock.Lock(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func Unlock() {
|
||||
if err := theLock.Unlock(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@ -21,12 +21,15 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/go-mplusbitmap"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/testflock"
|
||||
. "github.com/hajimehoshi/ebiten/text"
|
||||
"github.com/hajimehoshi/go-mplusbitmap"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testflock.Lock()
|
||||
defer testflock.Unlock()
|
||||
|
||||
code := 0
|
||||
// Run an Ebiten process so that (*Image).At is available.
|
||||
regularTermination := errors.New("regular termination")
|
||||
|
Loading…
Reference in New Issue
Block a user