mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
cmd/gogio: improve the UX of the e2e tests
First, add a headless boolean flag that defaults to true. That way, one can run 'go test -headless=false' to, for example, see how Chrome runs the webassembly endtoend test. Second, skip the Chrome test if the browser isn't installed. While at it, run 'gofmt -s' on the package. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
+10
-4
@@ -5,6 +5,8 @@ package main_test
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"flag"
|
||||||
"image/png"
|
"image/png"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -18,6 +20,8 @@ import (
|
|||||||
_ "gioui.org/unit" // the build tool adds it to go.mod, so keep it there
|
_ "gioui.org/unit" // the build tool adds it to go.mod, so keep it there
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var headless = flag.Bool("headless", true, "run end-to-end tests in headless mode")
|
||||||
|
|
||||||
func TestJSOnChrome(t *testing.T) {
|
func TestJSOnChrome(t *testing.T) {
|
||||||
// First, build the app.
|
// First, build the app.
|
||||||
dir, err := ioutil.TempDir("", "gio-endtoend-js")
|
dir, err := ioutil.TempDir("", "gio-endtoend-js")
|
||||||
@@ -35,8 +39,8 @@ func TestJSOnChrome(t *testing.T) {
|
|||||||
|
|
||||||
// Second, start Chrome.
|
// Second, start Chrome.
|
||||||
opts := append(chromedp.DefaultExecAllocatorOptions[:],
|
opts := append(chromedp.DefaultExecAllocatorOptions[:],
|
||||||
// Uncomment to get the browser's GUI.
|
chromedp.Flag("headless", *headless),
|
||||||
// chromedp.Flag("headless", false),
|
|
||||||
// We need use-gl=egl instead of the default of use-gl=desktop;
|
// We need use-gl=egl instead of the default of use-gl=desktop;
|
||||||
// "desktop" doesn't seem to work when we're in headless mode.
|
// "desktop" doesn't seem to work when we're in headless mode.
|
||||||
// TODO(mvdan): Does egl require a GPU? If so, consider
|
// TODO(mvdan): Does egl require a GPU? If so, consider
|
||||||
@@ -52,8 +56,10 @@ func TestJSOnChrome(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
if err := chromedp.Run(ctx); err != nil {
|
if err := chromedp.Run(ctx); err != nil {
|
||||||
// TODO(mvdan): Skip the test if chrome/chromium/headless-shell
|
if errors.Is(err, exec.ErrNotFound) {
|
||||||
// aren't installed.
|
t.Skipf("test requires Chrome to be installed: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -220,22 +220,22 @@ type arch struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var allArchs = map[string]arch{
|
var allArchs = map[string]arch{
|
||||||
"arm": arch{
|
"arm": {
|
||||||
iosArch: "armv7",
|
iosArch: "armv7",
|
||||||
jniArch: "armeabi-v7a",
|
jniArch: "armeabi-v7a",
|
||||||
clangArch: "armv7a-linux-androideabi",
|
clangArch: "armv7a-linux-androideabi",
|
||||||
},
|
},
|
||||||
"arm64": arch{
|
"arm64": {
|
||||||
iosArch: "arm64",
|
iosArch: "arm64",
|
||||||
jniArch: "arm64-v8a",
|
jniArch: "arm64-v8a",
|
||||||
clangArch: "aarch64-linux-android",
|
clangArch: "aarch64-linux-android",
|
||||||
},
|
},
|
||||||
"386": arch{
|
"386": {
|
||||||
iosArch: "i386",
|
iosArch: "i386",
|
||||||
jniArch: "x86",
|
jniArch: "x86",
|
||||||
clangArch: "i686-linux-android",
|
clangArch: "i686-linux-android",
|
||||||
},
|
},
|
||||||
"amd64": arch{
|
"amd64": {
|
||||||
iosArch: "x86_64",
|
iosArch: "x86_64",
|
||||||
jniArch: "x86_64",
|
jniArch: "x86_64",
|
||||||
clangArch: "x86_64-linux-android",
|
clangArch: "x86_64-linux-android",
|
||||||
|
|||||||
Reference in New Issue
Block a user