close
Skip to content

fix: make logger rotation tests deterministic#172

Merged
ChrisRomp merged 1 commit intomainfrom
fix/logger-test-determinism
Mar 31, 2026
Merged

fix: make logger rotation tests deterministic#172
ChrisRomp merged 1 commit intomainfrom
fix/logger-test-determinism

Conversation

@ChrisRomp
Copy link
Copy Markdown
Owner

Replace setTimeout sleeps in logger rotation tests with an awaitable waitForRotation() function. The logger now tracks its rotation promise internally; tests await it instead of guessing timing.

Result: Logger test suite runs in ~9ms instead of ~1500ms. No more timing-dependent flakiness.

Closes #171

Replace setTimeout sleeps with awaitable waitForRotation(). Logger now
tracks the rotation promise internally; tests await it instead of
guessing timing. Logger test suite runs in 9ms instead of ~1500ms.

Closes #171

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 31, 2026 18:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the logger rotation tests deterministic by removing fixed setTimeout sleeps and replacing them with an awaitable mechanism tied to the logger’s actual rotation work. It fits the codebase by improving the reliability and speed of the Vitest suite around src/logger.ts’s self-managed log rotation.

Changes:

  • Track the in-progress rotation via an internal _rotationPromise updated when rotation starts.
  • Expose a testing-oriented waitForRotation() helper so tests can await completion rather than sleep.
  • Update src/logger.test.ts to use await waitForRotation() at rotation points, reducing runtime and flakiness.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/logger.ts Tracks rotation with _rotationPromise and exports waitForRotation() to await rotation completion (used by tests).
src/logger.test.ts Replaces timing-based sleeps with waitForRotation() to make rotation assertions deterministic and faster.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ChrisRomp ChrisRomp merged commit 00fc486 into main Mar 31, 2026
10 checks passed
@ChrisRomp ChrisRomp deleted the fix/logger-test-determinism branch March 31, 2026 18:10
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.

chore: make logger rotation tests deterministic

2 participants