Skip to content

test: post state transitions with deliverImmediately and assert after termination#321

Merged
MarshallOfSound merged 1 commit into
mainfrom
sam/harden-state-transition-test
May 4, 2026
Merged

test: post state transitions with deliverImmediately and assert after termination#321
MarshallOfSound merged 1 commit into
mainfrom
sam/harden-state-transition-test

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Collaborator

The state describe block observes SQRLUpdaterState changes via NSDistributedNotificationCenter from the launched TestApplication. The posts used the default-coalescing form (postNotificationName:object:userInfo:), so the final AwaitingRelaunch notification — posted right before the app calls relaunchToInstallUpdate and exits — can sit in the per-process queue and be discarded at termination. Seen on macOS 14 arm64 as:

expected to eventually equal <(0, 1, 2, 3)>, got <(0, 1, 2)>

Root-cause fix: post with deliverImmediately:YES so each transition is handed to notifyd synchronously.

Ordering fix: wait for testApplication.terminated first, then assert on states. Once the app has exited, every notification has been posted; the assertion only needs to allow for in-flight delivery from notifyd, not race the entire download → verify → stage pipeline against a wall clock.

Also adds the missing withTimeout(SQRLLongTimeout) to the no-update variant, which was still on Nimble's 1s default.

… termination

The state-transition tests observe SQRLUpdaterState changes via
NSDistributedNotificationCenter from the launched TestApplication. The
posts used the default-coalescing form, so the final
AwaitingRelaunch notification — posted right before the app calls
relaunchToInstallUpdate and exits — could sit in the per-process
queue and be discarded at termination.

Post with deliverImmediately:YES so each transition is handed to
notifyd synchronously, and reorder the tests to wait for
testApplication.terminated first. Once the app has exited every
notification has been posted; the states assertion then only needs to
allow for in-flight delivery rather than racing the entire
download/verify/stage pipeline.

Also adds the missing withTimeout to the no-update variant, which was
still on Nimble's 1s default.
@MarshallOfSound MarshallOfSound enabled auto-merge (squash) May 4, 2026 06:06
@MarshallOfSound MarshallOfSound merged commit 8d80880 into main May 4, 2026
6 checks passed
@MarshallOfSound MarshallOfSound deleted the sam/harden-state-transition-test branch May 4, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant