fix(ios): three unbacked reads report not-supported instead of success

RecentLogs returned an empty slice, Metrics a zeroed sample and Health a
hardcoded Ready: true, which are the same values a working read returns. Every
property over state.logs held vacuously on iOS with nothing saying the logs were
never read. driver.ErrNotSupported makes the silence representable.
This commit is contained in:
pj committed 2026-08-22 21:16:24 +05:30
1 parent 08df960e0f
commit 1de179995b
3 files changed
+56 -16

No files matched your search

+11 -8
View File
@@ -1107,21 +1107,24 @@ func (d *Driver) WaitForIdle(ctx context.Context, _ time.Duration) error {
return nil
}
// RecentLogs returns no entries: the companion log RPC is a follow-up, so v1
// reports an empty slice rather than failing. Every property reading state.logs
// therefore holds vacuously on iOS and nothing says so; closing it means
// tailing idb's streaming log RPC and mapping os_log levels onto the
// single-letter scale driver.LogEntry declares.
// RecentLogs, Metrics and Health have no companion RPC behind them yet, so
// each reports driver.ErrNotSupported. An empty log slice, a zeroed sample and
// a hardcoded Ready are the same values a working read can return, so answering
// with them told the runner three checks had passed that never ran and left
// every property reading state.logs holding vacuously with nothing saying so.
// Closing them means tailing the streaming log RPC and mapping os_log levels
// onto the single-letter scale driver.LogEntry declares, sampling the app
// process, and probing the bridge for readiness.
func (d *Driver) RecentLogs(_ context.Context, _ time.Time, _ string) ([]driver.LogEntry, error) {
return []driver.LogEntry{}, nil
return nil, driver.ErrNotSupported
}
func (d *Driver) Metrics(_ context.Context, _ string) (driver.Metrics, error) {
return driver.Metrics{}, nil
return driver.Metrics{}, driver.ErrNotSupported
}
func (d *Driver) Health(_ context.Context) (driver.Health, error) {
return driver.Health{Ready: true, Platform: "ios"}, nil
return driver.Health{}, driver.ErrNotSupported
}
// ForegroundApp reports the foreground app. It returns the app under test when
+27 -6
View File
@@ -699,14 +699,35 @@ func TestForegroundAppFallsBackToOtherRunningUserApp(t *testing.T) {
}
}
func TestHealthReportsIOS(t *testing.T) {
// The three reads the companion has no RPC for must say so. Answering an empty
// log slice, a zeroed sample or Ready reports three checks as having passed
// that never ran, and a spec's log properties then hold on evidence nobody
// collected.
func TestUnbackedReadsReportNotSupported(t *testing.T) {
d := newTestDriver(&fakeCompanion{})
health, err := d.Health(context.Background())
if err != nil {
t.Fatalf("Health: %v", err)
logs, err := d.RecentLogs(context.Background(), time.Time{}, "E")
if !errors.Is(err, driver.ErrNotSupported) {
t.Errorf("RecentLogs err = %v, want driver.ErrNotSupported", err)
}
if !health.Ready || health.Platform != "ios" {
t.Fatalf("Health = %+v, want ready ios", health)
if len(logs) != 0 {
t.Errorf("RecentLogs returned %d entries alongside its error", len(logs))
}
metrics, err := d.Metrics(context.Background(), "com.fixture")
if !errors.Is(err, driver.ErrNotSupported) {
t.Errorf("Metrics err = %v, want driver.ErrNotSupported", err)
}
if metrics != (driver.Metrics{}) {
t.Errorf("Metrics = %+v, want the zero sample", metrics)
}
health, err := d.Health(context.Background())
if !errors.Is(err, driver.ErrNotSupported) {
t.Errorf("Health err = %v, want driver.ErrNotSupported", err)
}
if health.Ready {
t.Errorf("Health = %+v: the driver reports a readiness check it never ran", health)
}
}