Repository navigation
Engine tests: the failed-enablement test reads its own clock, so the window's edge is exact (#408) - #447
Merged
Conversation
…its own, so the window's edge is exact (refs #408) The test took freshSince from the real CLOCK_UPTIME_RAW and asserted not-fresh at since + 10 000 ms. When that sum crosses a power of two, Double drops a low bit and can round it down, so now - since came out a hair under the window and read fresh: about 1% of readings under an hour of uptime, the hosted runner's line-546 "XCTAssertFalse failed". Forcing the clock to 520 000.123456789 ms reproduces it every time. The product is unaffected (sub-nanosecond at the edge); the test now injects its clock and asserts the observation's time exactly. Sminos-Session: cursor235#b93055dd (cua on macbook)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #408. Test-only; no shipped behaviour changes, so no version bump.
BackgroundPointerTests.testAFailedEnablementWriteStillOpensTheFreshWindowAndIsReportedfailed on hosted macOS six times (11-15..11-20, #444), always at line 546 alone withXCTAssertFalse failed. The cause was floating-point rounding, not timing. The test readfreshSincefrom the real clock (CLOCK_UPTIME_RAWin fractional ms) and checked that the window had closed atsince + 10_000. When that sum crosses a power of two, the Double loses a low bit,now - sincecomes out as9999.99999999994, and the window reads as still fresh. Sampling real uptimes put this at about 0.9% under one hour of uptime, which is where a freshly booted hosted runner sits. No user can meet it: the difference is under a nanosecond, at the exact 10 s edge.Fix: the test passes its own clock through
WebAccessibility(now:), as the other tests in the file already do. It assertsfreshSince == 5_000exactly (it used to check>= before), and both edge checks are exact.Repro before the fix: pinning the clock at
520_000.123456789, whose sum with 10 000 crosses 2^19, failed the unchanged test every time, at line 546 only. That matches the hosted logs.Checks:
swift test --filter BackgroundPointerTests: 26/26.The hosted 200-run loop that #408 asked for wasn't run. The test no longer reads the real clock, so its result doesn't depend on the runner.
Sminos-Session: cursor235#b93055dd (cua on macbook)