mirror of
https://github.com/CharlesWiltgen/Axiom.git
synced 2026-09-20 19:58:20 +08:00
e996de9d79
AXe's default tap style sends a simulator tap that SwiftUI controls ignore while AXe still prints a success line. Measured on Xcode 27.1 with AXe 1.8.0, across iPhone 17 (iOS 27.0) and iPhone Duo (iOS 27.1): neither a Button, a List row, a Button inside a List, a Menu, a row of an open Menu nor a TabView tab activated under the default or the `simulator` style, and `--tap-style physical` activated all six. The same default left system alerts on screen while `dialog accept` reported them handled. `tap` and the `dialog` accept/dismiss taps now supply the physical style unless the caller picks one, and an AXe older than 1.7.0 — which has no `--tap-style` — is named as the cause instead of surfacing as an unknown-flag failure. With more than one simulator booted and no `--udid`, every device verb now exits 2 and lists each booted device's UDID, name and runtime, rather than driving whichever sorted first while reporting success. `doctor` reports that list, fails its gate in that state, and leaves `booted_udid` empty, because nothing may be targeted until the caller chooses.
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestExecRunCapturesStdout(t *testing.T) {
|
|
res, err := ExecRun(context.Background(), 5*time.Second, "echo", "hello")
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if strings.TrimSpace(string(res.Stdout)) != "hello" {
|
|
t.Errorf("stdout = %q, want %q", res.Stdout, "hello")
|
|
}
|
|
}
|
|
|
|
func TestExecRunTimeout(t *testing.T) {
|
|
_, err := ExecRun(context.Background(), 50*time.Millisecond, "sleep", "5")
|
|
if !IsTimeoutError(err) {
|
|
t.Errorf("expected TimeoutError, got %v", err)
|
|
}
|
|
}
|
|
|
|
// execCall records one subprocess xcui would have run.
|
|
type execCall struct {
|
|
name string
|
|
args []string
|
|
}
|
|
|
|
// withFakeExec replaces the ExecRun seam for the duration of a test, answering
|
|
// every call with stdout. It returns the calls made, so a test can assert that a
|
|
// path shelled out — or, more usefully, that it did not.
|
|
func withFakeExec(t *testing.T, stdout string) *[]execCall {
|
|
t.Helper()
|
|
calls := &[]execCall{}
|
|
orig := execRun
|
|
execRun = func(ctx context.Context, timeout time.Duration, name string, args ...string) (ExecResult, error) {
|
|
*calls = append(*calls, execCall{name: name, args: args})
|
|
return ExecResult{Stdout: []byte(stdout)}, nil
|
|
}
|
|
t.Cleanup(func() { execRun = orig })
|
|
return calls
|
|
}
|