mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
cmd/gogio: support running e2e with and without -race
Right now, we can only run the e2e gio app with -race, not without -race, because the flag is hard-coded in the tests. The reason for this change was that 'GOFLAGS=-race go test' would fail with the JS test, since js/wasm doesn't support the race detector. Fix that by skipping the JS test when -race is used. Now, we can run multiple levels of -race: go test # no -race at all go test -race # -race for the tests, not the e2e gio app GOFLAGS=-race go test # -race for everything (best-effort) To detect the race detector being on, we use a file with a build tag. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var raceEnabled = false
|
||||
|
||||
var headless = flag.Bool("headless", true, "run end-to-end tests in headless mode")
|
||||
|
||||
// TestDriver is implemented by each of the platforms we can run end-to-end
|
||||
|
||||
@@ -33,6 +33,10 @@ type JSTestDriver struct {
|
||||
func (d *JSTestDriver) Start(t_ *testing.T, path string, width, height int) (cleanups []func()) {
|
||||
d.t = t_
|
||||
|
||||
if raceEnabled {
|
||||
d.t.Skipf("js/wasm doesn't support -race; skipping")
|
||||
}
|
||||
|
||||
// First, build the app.
|
||||
dir, err := ioutil.TempDir("", "gio-endtoend-js")
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
// +build race
|
||||
|
||||
package main_test
|
||||
|
||||
func init() { raceEnabled = true }
|
||||
@@ -72,7 +72,7 @@ func (d *WaylandTestDriver) Start(t_ *testing.T, path string, width, height int)
|
||||
cleanups = append(cleanups, func() { os.RemoveAll(dir) })
|
||||
|
||||
bin := filepath.Join(dir, "red")
|
||||
cmd := exec.Command("go", "build", "-race", "-tags", "nox11", "-o="+bin, path)
|
||||
cmd := exec.Command("go", "build", "-tags", "nox11", "-o="+bin, path)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
d.t.Fatalf("could not build app: %s:\n%s", err, out)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func (d *X11TestDriver) Start(t_ *testing.T, path string, width, height int) (cl
|
||||
cleanups = append(cleanups, func() { os.RemoveAll(dir) })
|
||||
|
||||
bin := filepath.Join(dir, "red")
|
||||
cmd := exec.Command("go", "build", "-race", "-tags", "nowayland", "-o="+bin, path)
|
||||
cmd := exec.Command("go", "build", "-tags", "nowayland", "-o="+bin, path)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
d.t.Fatalf("could not build app: %s:\n%s", err, out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user