mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
cmd/gogio: don't hang on some e2e test errors
For example, if the test app fails to start on wayland, we'd block ~forever (ten minutes) waiting for it to render its first frame. We don't have a good solution right now. But at least we can use a relatively short timeout, to help out the human who rightfully expects a result within ten seconds. While at it, remove a sway "get_seats" command, which was a leftover from my debugging of what input devices are available when running headless. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var raceEnabled = false
|
||||
@@ -148,3 +149,20 @@ func wantColor(t *testing.T, img image.Image, x, y int, want color.Color) {
|
||||
r_, g_, b_, x, y, r, g, b)
|
||||
}
|
||||
}
|
||||
|
||||
func waitForFrame(t *testing.T, frameNotifs <-chan bool) {
|
||||
// Unfortunately, there isn't a way to select on a test failing, since
|
||||
// testing.T doesn't have anything like a context or a "done" channel.
|
||||
//
|
||||
// We can't let selects block forever, since the default -test.timeout
|
||||
// is ten minutes - far too long for tests that take seconds.
|
||||
//
|
||||
// For now, a static short timeout is better than nothing. 2s is plenty
|
||||
// for our simple test app to render on any device.
|
||||
|
||||
select {
|
||||
case <-frameNotifs:
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatalf("timed out waiting for a frame to be ready")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user