mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(runner): relaunch app when foreground escapes during exploration
This commit is contained in:
1 parent
dea39d3bac
commit
dff91095b8
3 files changed
+111
No files matched your search
@@ -55,6 +55,12 @@ type Driver struct {
|
||||
LogEntries []driver.LogEntry
|
||||
MetricsData driver.Metrics
|
||||
Failures map[ActionKind]error
|
||||
|
||||
// ForegroundResults is consumed one entry per ForegroundApp call (the
|
||||
// last entry repeats). Empty yields "", which disables the runner's
|
||||
// app-scope guard so tests that don't care are unaffected.
|
||||
ForegroundResults []string
|
||||
foregroundIndex int
|
||||
}
|
||||
|
||||
func New() *Driver {
|
||||
@@ -96,6 +102,20 @@ func (d *Driver) Launch(_ context.Context, bundleID string, clearState bool, _ m
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Driver) ForegroundApp(_ context.Context) (string, error) {
|
||||
d.mutex.Lock()
|
||||
defer d.mutex.Unlock()
|
||||
if len(d.ForegroundResults) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
index := d.foregroundIndex
|
||||
if index >= len(d.ForegroundResults) {
|
||||
index = len(d.ForegroundResults) - 1
|
||||
}
|
||||
d.foregroundIndex++
|
||||
return d.ForegroundResults[index], nil
|
||||
}
|
||||
|
||||
func (d *Driver) Terminate(ctx context.Context) error {
|
||||
if err := d.failure(ActionTerminate); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user