refactor(stella-core): take the two shared sleeper doubles from stella-time - #6499
Merged
Conversation
Contributor
There was a problem hiding this comment.
Sorry @macanderson, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 2 days and 5 hours by commenting @sourcery-ai review. Upgrade to get a review now.
…a-time About thirty test files across stella-core, stella-engine and their tests/ directories each wrote the same Sleeper double, a no-op one under three names and one on tokio's paused clock, and each copy grew a now() body in #6486. They are deleted. Integration tests and stella-engine take PausedSleeper and NoopSleeper from stella_time::test_util through a dev-dependency; stella-core's own unit tests keep one copy in src/tests.rs, because a lib's unit tests are a second build of the lib and a dev-dependency that links the lib implements the trait for the first. stella-time's one_home witness now scans test files too. Closes #6484
macanderson
force-pushed
the
fix/6484-shared-sleeper-doubles
branch
from
September 11, 2026 18:29
fd17d35 to
ef34918
Compare
Contributor
Reviewer's GuideThis refactor removes duplicated sleeper test doubles from Flow diagram for the sleeper duplication witnessflowchart TD
Scan["one_home.rs scans crate src and tests .rs files"] --> Detect["Find sleeper double definitions"]
Detect --> Allowed["Compare against kept-list"]
Allowed --> Pass["Pass when shared doubles are used and required exceptions remain"]
Allowed --> Fail["Fail on duplicated or missing sleeper doubles"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
macanderson
enabled auto-merge (squash)
September 11, 2026 18:42
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.
What & why
The test-double half of #6484, on top of the merged
stella-timePR (#6488). Re-opened: the first copy (#6491) was closed by GitHub when #6488's branch was deleted on merge. About thirty test files acrossstella-core,stella-engineand theirtests/directories each wrote the sameSleeperdouble — a no-op one under three names, and one on tokio's paused clock — and each copy grew anow()body in #6486. Every one of them is deleted here.stella-enginetakePausedSleeperandNoopSleeperfromstella_time::test_utilthrough a dev-dependency onstella-timewithtest-utilon. Forstella-corethat is a dependency cycle, which cargo allows; it is the tokio / tokio-test shape.stella-core's own unit tests keep one copy,src/tests.rs, because a lib's unit tests are a second build of the lib and a dev-dependency that links the lib implements the trait for the first. The compiler forces that copy (the first attempt at taking the crate's doubles fromstella-timefailed on every unit test with "multiple different versions of cratestella_core"). It is namedtests.rssomake core-no-ioreads it as test code, which is how that guard tells test code from shipping code.one_homewitness instella-timenow scans test files too. Its kept list shrinks to the four doubles with a shape a shared one cannot have — the retry tests' recording sleeper, the monitor's advancing sleeper, the hanging sleeper, andstep/tests.rs's unpaused-time sleeper — plus the forced copy.Closes #6484
The witness
main, passes here)crates/stella-time/tests/one_home.rsreads every.rsundercrates/*/srcandcrates/*/tests. On the base branch it fails on twenty-three files that each define a sleeper double; here it passes, and a second test fails if a kept one disappears. Locally:stella-core's 893 lib tests and every integration test,stella-engine's tests and the time crate's 6 + 3 tests pass.The gate
cargo fmt --check-D warnings— CI; ran locally onstella-core,stella-engine,stella-time--help, doc comments)Closes #Nappears both above and as a commit trailerFix over file
Ground-rule check
stella-core;src/tests.rsis#[cfg(test)]andmake core-no-iois greenAnything reviewers should know?
TokioSleeper→PausedSleeperin the test tree is deliberate: the paused-clock double must not share a name with the realstella_time::TokioSleeper.#[cfg(test)] modlines),src/tests.rscould take a more descriptive name; it is named for the guard's current file-name rule.Summary by Sourcery
Consolidate test sleeper doubles in
stella-timeand enforce a single ownership location across the workspace.Enhancements:
stella-timeand updatestella-coreandstella-enginetests to use them.stella-coreunit-test copy.Build:
stella-timeas a test-only dependency with thetest-utilfeature where shared sleeper doubles are used.Documentation:
stella-coreunit-test exception.Tests: