mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
cmd/gogio: make e2e test output consistent
Fix a long-standing TODO: instead of each sub-test handling its own output separately, just make each expose its output via an io.Reader. Then, the shared driverBase code can tell if any of the lines contain the magic "gio frame ready" string. Reduces the amount of code a bit, but most importantly, it keeps the "is a frame ready?" logic in a single place. In the future, this also enables us to do more with all the e2e test app output consistently. For example, we might want to add a -debug flag to always log output lines as they happen. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
@@ -13,7 +12,6 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AndroidTestDriver struct {
|
||||
@@ -80,24 +78,16 @@ func (d *AndroidTestDriver) Start(path string) {
|
||||
"-T1", // don't show prevoius log messages
|
||||
appid+":*", // show all logs from our gio app ID
|
||||
)
|
||||
logcat, err := cmd.StdoutPipe()
|
||||
output, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stderr = cmd.Stdout
|
||||
d.output = output
|
||||
if err := cmd.Start(); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(cancel)
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(logcat)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.HasSuffix(line, ": frame ready") {
|
||||
d.frameNotifs <- true
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Start the app.
|
||||
|
||||
Reference in New Issue
Block a user