mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-02 16:06:19 +00:00
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:
+1
-1
@@ -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 .)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user