cmd/gogio: simplify the test -race setup

In an earlier commit, we made it possible to run the e2e tests with the
race detector enabled everywhere via GOFLAGS=-race go test.

However, that's not at all standard; most users will simply use 'go test
-race'. Moreover, having 'go test -race' run the test program with the
race detector, but not the e2e gio app, is a bit useless.

Instead, have the tests detect when they run with the race detector, and
enable the race detector in the test app too. As before, the JS test is
skipped whenever -race is used.

This also means we can test with -race in the same way in each of the
modules, which simplifies CI.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
Daniel Martí
2019-11-04 18:44:54 +00:00
committed by Elias Naur
parent c2cab4505c
commit 4d7c89fec3
3 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ tasks:
- test_cmd: |
cd gio/cmd
go test ./...
GOFLAGS=-race go test ./...
go test -race ./...
- check_gofmt: |
cd gio
test -z $(gofmt -s -l .)
+6 -1
View File
@@ -72,7 +72,12 @@ 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", "-tags", "nox11", "-o="+bin, path)
flags := []string{"build", "-tags", "nox11", "-o="+bin}
if raceEnabled {
flags = append(flags, "-race")
}
flags = append(flags, path)
cmd := exec.Command("go", flags...)
if out, err := cmd.CombinedOutput(); err != nil {
d.t.Fatalf("could not build app: %s:\n%s", err, out)
}
+6 -1
View File
@@ -69,7 +69,12 @@ 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", "-tags", "nowayland", "-o="+bin, path)
flags := []string{"build", "-tags", "nowayland", "-o="+bin}
if raceEnabled {
flags = append(flags, "-race")
}
flags = append(flags, path)
cmd := exec.Command("go", flags...)
if out, err := cmd.CombinedOutput(); err != nil {
d.t.Fatalf("could not build app: %s:\n%s", err, out)
}