@@ -548,19 +548,37 @@ extension RunnerTests {
548548 snapshotXCTestChannelNextRecoveryProbeAt = . distantPast
549549 let expiry = snapshotXCTestChannelPenaltyUntil
550550 let started = Date ( )
551- let payload = try runDeferredPlanOffMain ( target : captureTarget ) {
551+ let payload = try runDeferredPlanOffMain ( target : captureTarget )
552+ XCTAssertLessThan ( Date ( ) . timeIntervalSince ( started ) , 0.5 , " the accepted capture must answer before the optional probe " )
553+ let probeFinished = expectation ( description : " scheduled probe answered " )
554+ commandExecutionQueue . async {
552555 RunnerBlockingSnapshotGate . release . signal ( )
556+ probeFinished . fulfill ( )
553557 }
558+ wait ( for : [ probeFinished ] , timeout : 3 )
554559 XCTAssertEqual ( payload . snapshotQuality ? . backend , SnapshotBackendKind . privateAX . rawValue )
555560 XCTAssertEqual ( RunnerBlockingSnapshotGate . entered . wait ( timeout : . now ( ) ) , . success )
556561 XCTAssertLessThan ( Date ( ) . timeIntervalSince ( started ) , 2 )
557562 XCTAssertEqual ( snapshotXCTestChannelPenaltyUntil , expiry )
558563 let next = snapshotXCTestChannelNextRecoveryProbeAt
559564 XCTAssertGreaterThan ( next . timeIntervalSince ( started ) , 29 )
560565 _ = try runDeferredPlanOffMain ( target : captureTarget )
566+ let queueDrained = expectation ( description : " second capture queued no probe " )
567+ commandExecutionQueue . async { queueDrained . fulfill ( ) }
568+ wait ( for : [ queueDrained ] , timeout : 3 )
561569 XCTAssertEqual ( snapshotXCTestChannelNextRecoveryProbeAt , next )
562570 XCTAssertEqual ( snapshotXCTestChannelPenaltyUntil , expiry )
563571 XCTAssertEqual ( RunnerBlockingSnapshotGate . entered . wait ( timeout : . now ( ) ) , . timedOut )
572+
573+ snapshotXCTestChannelNextRecoveryProbeAt = . distantPast
574+ _ = try runDeferredPlanOffMain ( target : captureTarget ) {
575+ self . clearSnapshotXCTestChannelPenalty ( reason : " replace-before-probe " )
576+ self . penalizeSnapshotXCTestChannel ( bundleId : captureTarget . bundleId , reason : " new-penalty " )
577+ }
578+ let staleProbeDrained = expectation ( description : " stale queued probe refused " )
579+ commandExecutionQueue . async { staleProbeDrained . fulfill ( ) }
580+ wait ( for : [ staleProbeDrained ] , timeout : 3 )
581+ XCTAssertEqual ( RunnerBlockingSnapshotGate . entered . wait ( timeout : . now ( ) ) , . timedOut )
564582 }
565583
566584 private func launchPenalizedPrivateAXBlindTarget ( bundleId : String ) throws -> SnapshotCaptureTarget {
@@ -602,7 +620,7 @@ extension RunnerTests {
602620 }
603621 let box = ResultBox ( )
604622 let planned = expectation ( description : " deferred plan answered " )
605- DispatchQueue ( label : " agent-device.runner.tests.deferred-plan " ) . async {
623+ commandExecutionQueue . async {
606624 do {
607625 box . payload = try self . runSnapshotCapturePlan (
608626 Self . regularVisiblePlan ,
0 commit comments