Skip to content

Commit 3dad2ba

Browse files
committed
test(ios): trim the pinned-capture review findings
State the deferred-plan probe override exactly, keep the pin-seed constraint at one owner, name why the two new tests run the plan inline, and mirror their cleanup on invalidateCachedTarget.
1 parent 888c7f2 commit 3dad2ba

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ extension RunnerTests {
239239
/// cause that does not exist.
240240
///
241241
/// The 'requested-backend' answer names a plan decision, not a failure, so the runner carries
242-
/// it in its own slot (`preSelectionReason`) where a tier that actually failed replaces it as
243-
/// the verdict reason. The breaker's 'deferred' and 'budget' answers stay first-failure seeds:
244-
/// their established contract is that the pre-selection IS the reason a deferred plan answers
245-
/// with, whatever the bounded probe's tier did on the way.
242+
/// it in its own slot (`preSelectionReason`) and a tier that actually failed replaces it as the
243+
/// verdict reason. The breaker's 'deferred' and 'budget' answers stay first-failure seeds: a
244+
/// deferred plan reports the pre-selection until its bounded probe's tier runs; then the verdict
245+
/// reports that probe's 'budget' constraint.
246246
static func xcTestChannelStateFirstFailure(
247247
_ state: SnapshotXCTestChannelPlanState,
248248
requestPinnedBackend: Bool = false,
@@ -404,16 +404,10 @@ extension RunnerTests {
404404
preferredBackend: options.preferredBackend
405405
)
406406
let effectivePlan = effective.plan
407-
// The pre-selection reason names why the plan was shaped this way, not what went wrong on
408-
// this capture. The breaker's 'deferred' and probe 'budget' answers seed the first-failure
409-
// slot and keep their established contract: a deferred plan reports the pre-selection
410-
// whatever its bounded probe did. A 'requested-backend' answer (the request-pin) travels in
411-
// its own slot instead, and is reported only where nothing failed on this capture — an
412-
// accepted payload keeps it, a failing terminal reports the real reason. A pinned backend
413-
// that rejected the screen must say so (#3885 follow-up): 'requested-backend' on a sparse
414-
// terminal claimed nothing degraded while the pinned tier had just failed, and hid the
415-
// typed reason the caller needs. Only a customActions-implied pin is request-pinned; the
416-
// daemon's same-backend evidence probe pins for its own reasons and keeps 'deferred'.
407+
// The pin seed must not occupy the failure slot: a tier that failed on this capture owns
408+
// the verdict reason there, and the pre-selection is reported only when nothing failed
409+
// (see xcTestChannelStateFirstFailure). Only a customActions-implied pin is request-pinned;
410+
// the daemon's same-backend evidence probe pins for its own reasons and keeps 'deferred'.
417411
let preSelectionReason = Self.xcTestChannelStateFirstFailure(
418412
effective.xCTestChannelState,
419413
requestPinnedBackend: options.customActions && !xCTestChannelPenalizedByBreaker,

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SnapshotCapturePlanOccupancyTests.swift‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,9 @@ extension RunnerTests {
509509
/// #758 signature ends sparse, and the verdict must name the rejection. Seeding the pin into the
510510
/// failure slot reported 'requested-backend' — the daemon and the caller read a hostile-screen
511511
/// failure as "nothing degraded, the pin was honored", and the host turned the same payload into
512-
/// a viewport error that hid the typed reason.
512+
/// a viewport error that hid the typed reason. The plan runs inline on main: the verdict-slot
513+
/// decision is thread-independent and the stub answers at once, so no occupancy machinery is
514+
/// part of what this classifies.
513515
@MainActor
514516
func testTreePinnedCaptureTheAxServerRejectsReportsTheRejection() throws {
515517
guard
@@ -535,8 +537,7 @@ extension RunnerTests {
535537
defer {
536538
method_setImplementation(snapshotMethod, originalImplementation)
537539
clearSnapshotXCTestChannelPenalty(reason: "test-cleanup")
538-
clearPrivateAXAcceptedDepth(reason: "test-cleanup")
539-
mainOwned.app = nil
540+
invalidateCachedTarget(reason: "unit_test_cleanup")
540541
app.terminate()
541542
}
542543

@@ -554,9 +555,6 @@ extension RunnerTests {
554555
)
555556

556557
let quality = try XCTUnwrap(payload.snapshotQuality)
557-
if quality.reasonCode == "budget" {
558-
throw XCTSkip("abandoned work from a prior test kept the tree tier out of this capture")
559-
}
560558
XCTAssertEqual(quality.state, .sparse)
561559
XCTAssertEqual(
562560
quality.reasonCode,
@@ -568,7 +566,8 @@ extension RunnerTests {
568566

569567
/// The healthy side of the same pin: a tree that answers keeps reporting the pin itself as the
570568
/// verdict reason (the perf suite's `snapshot-forced-tree` step reads exactly that as proof the
571-
/// pin was honored), so the rejection fix must not silence it.
569+
/// pin was honored), so the rejection fix must not silence it. Runs inline on main like the
570+
/// rejection test above.
572571
@MainActor
573572
func testTreePinnedCaptureThatServesTheScreenStillReportsThePin() throws {
574573
app.launchArguments = ["--agent-device-selector-read-regression"]
@@ -578,7 +577,7 @@ extension RunnerTests {
578577
mainOwned.bundleId = "com.callstack.agentdevice.runner.pinned-tree-healthy-test"
579578
defer {
580579
clearSnapshotXCTestChannelPenalty(reason: "test-cleanup")
581-
mainOwned.app = nil
580+
invalidateCachedTarget(reason: "unit_test_cleanup")
582581
app.terminate()
583582
}
584583

0 commit comments

Comments
 (0)