forked from joejulian/gio
cmd/gogio: groundwork for Windows e2e tests on Wine
First, move from debian unstable to testing, since sway was promoted to testing as of earlier this week. Second, use the --sync option when using xdotool to move an X11 mouse. This makes the command block until the mouse has finished moving to the specified location, removing a potential race with the following 'xdotool click' command. Third, deduplicate some logic into driverBase: tempDir to create a temporary directory within a test, and needPrograms to skip a test if the required programs aren't available. Lastly, split the code that starts the X11 server into a method, so that the future Wine e2e driver can reuse it. Since Wine is tightly coupled with X11, we can reuse a good part of the code, including the X11 server and the xdotool mechanisms. We also add a TODO to perhaps improve the handling of the app's output under each of the e2e test cases. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
@@ -8,6 +8,9 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -45,6 +48,10 @@ type TestDriver interface {
|
||||
type driverBase struct {
|
||||
*testing.T
|
||||
|
||||
// TODO(mvdan): Make this lower-level, so that each driver can simply
|
||||
// send us each line of output from the app. That will let us
|
||||
// deduplicate some code, and also show app output as test logs in a
|
||||
// consistent way.
|
||||
frameNotifs chan bool
|
||||
}
|
||||
|
||||
@@ -254,3 +261,22 @@ func (d *driverBase) waitForFrame() {
|
||||
d.Fatalf("timed out waiting for a frame to be ready")
|
||||
}
|
||||
}
|
||||
|
||||
func (d *driverBase) needPrograms(names ...string) {
|
||||
d.Helper()
|
||||
for _, name := range names {
|
||||
if _, err := exec.LookPath(name); err != nil {
|
||||
d.Skipf("%s needed to run", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *driverBase) tempDir(name string) string {
|
||||
d.Helper()
|
||||
dir, err := ioutil.TempDir("", name)
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(func() { os.RemoveAll(dir) })
|
||||
return dir
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user