cmd/gogio: use a standalone WINEPREFIX for the wine e2e test

This way, if the user has a custom winecfg, it can't possibly affect the
tests. I was encountering this as DXVK does not work on virtual Xorg
servers (which we use), and Gio thus failed to render on such a
combination.

>From the numbers below, it can be seen that setting up a new WINEPREFIX
takes roughly five seconds:

	$ rm -rf ~/.cache/gio-e2e-wine
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	16.369s
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	11.810s

A repeated run still has a slow "wine winecfg /?", for some reason. Add
a TODO since I can see it taking a third of the time on my terminal. I
haven't been able to properly investigate why, unfortunately. As far as
I can tell, winecfg is just faster when run with a terminal instead of
an output buffer. They might use isatty on stdout/stderr.

The overall time to run the wine sub-test is increased from ~5s to ~11s,
but it's worth it to make it run everywhere. It looks like there is
plenty of room as per the TODO above, as winecfg seems to mostly do
nothing. We're also not too worried, as all e2e subtests run in
parallel.

Fixes #106.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
Daniel Martí
2020-05-09 16:17:06 +01:00
committed by Elias Naur
parent 29a9e5bc27
commit c2cbcee78d
2 changed files with 32 additions and 2 deletions
+1 -1
View File
@@ -257,7 +257,7 @@ func (d *driverBase) waitForFrame() {
// 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 now, a static short timeout is better than nothing. 5s is plenty
// for our simple test app to render on any device.
select {
case <-d.frameNotifs:
+31 -1
View File
@@ -62,9 +62,39 @@ func (d *WineTestDriver) Start(path string) {
// Then, start our program via Wine on the X server above.
{
cacheDir, err := os.UserCacheDir()
if err != nil {
d.Fatal(err)
}
// Use a wine directory separate from the default ~/.wine, so
// that the user's winecfg doesn't affect our test. This will
// default to ~/.cache/gio-e2e-wine. We use the user's cache,
// to reuse a previously set up wineprefix.
wineprefix := filepath.Join(cacheDir, "gio-e2e-wine")
// First, run a headless winecfg to make sure the wineprefix is
// set up. If Wine encounters any issue setting up, we can also
// report it early. This can easily take 5s the first time. The
// "/?" parameter is just to not try to open the winecfg GUI.
// TODO(mvdan): Why does this take ~2s when run with a terminal
// (pty), but it takes ~6s when run here?
{
start := time.Now()
cmd := exec.Command("wine", "winecfg", "/?")
cmd.Env = []string{"WINEPREFIX=" + wineprefix}
if out, err := cmd.CombinedOutput(); err != nil {
d.Fatalf("%v: %s", err, out)
}
d.Logf("set up WINEPREFIX in %s", time.Since(start))
}
ctx, cancel := context.WithCancel(context.Background())
cmd := exec.CommandContext(ctx, "wine", bin)
cmd.Env = []string{"DISPLAY=" + d.display}
cmd.Env = []string{
"DISPLAY=" + d.display,
"WINEDEBUG=-all", // hide warnings and other noise
"WINEPREFIX=" + wineprefix,
}
stdout, err := cmd.StdoutPipe()
if err != nil {
d.Fatal(err)