Skip to content

fix: make the close/reset timer tests deterministic - #394

Merged
abelonogov-ld merged 1 commit into
mainfrom
andrey/unit-test-fixes
Aug 21, 2026
Merged

fix: make the close/reset timer tests deterministic#394
abelonogov-ld merged 1 commit into
mainfrom
andrey/unit-test-fixes

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

closeCancelsPendingTimer and resetCancelsPendingTimer slept for a fraction of the debounce window and then asserted the timer never fired. On a loaded runner that sleep can overshoot the window, and once the timer has begun firing neither close() nor reset() can recall it, so the tests failed for reasons unrelated to the behaviour they cover.

Both now drive a ManualTaskExecutor instead of sleeping, asserting that the scheduled task was cancelled and that draining the queue runs nothing.

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Overview
Makes closeCancelsPendingTimer and resetCancelsPendingTimer deterministic by driving a ManualTaskExecutor instead of sleeping a fraction of the debounce window.

Those sleeps could overshoot on a loaded runner, so the timer fired before close()/reset() could cancel it. The tests now assert the scheduled task was cancelled and that draining the queue runs nothing.

Reviewed by Cursor Bugbot for commit 0160533. Bugbot is set up for automated code reviews on this repo. Configure here.

closeCancelsPendingTimer and resetCancelsPendingTimer slept for a fraction
of the debounce window and then asserted the timer never fired. On a loaded
runner that sleep can overshoot the window, and once the timer has begun
firing neither close() nor reset() can recall it, so the tests failed for
reasons unrelated to the behaviour they cover.

Both now drive a ManualTaskExecutor instead of sleeping, asserting that the
scheduled task was cancelled and that draining the queue runs nothing.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner August 21, 2026 20:06
@abelonogov-ld
abelonogov-ld merged commit 984d2e6 into main Aug 21, 2026
8 checks passed
@abelonogov-ld
abelonogov-ld deleted the andrey/unit-test-fixes branch August 21, 2026 20:19
abelonogov-ld added a commit that referenced this pull request Aug 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[5.15.1](5.15.0...5.15.1)
(2026-08-21)


### Bug Fixes

* make the close/reset timer tests deterministic
([0160533](0160533))
* make the close/reset timer tests deterministic
([#394](#394))
([984d2e6](984d2e6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Release Please patch bump from **5.15.0** to **5.15.1**.
> 
> Updates `version` in `gradle.properties` and the release-please
manifest, and adds a changelog entry for making close/reset timer tests
deterministic. No product code changes in this PR.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1f0af77. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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.

2 participants