You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tests: wait for the drive's reads before counting them (#3823) - #4287
find_similar::stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_rest counts the drive's reads right after the activity row clears, so under load the last reads land after the count and the assertion sees 10 or 11 of 12. The test now also waits, within its existing step_until(T, …) budget, for the drive to record all 12 reads before asserting; the assertions (exactly 12 reads, filter holds half the library) are unchanged.
It also clears the session's in-memory decoded sources before the second search. In the Detail view the loupe's render and neighbour prefetch decode through the same drive, so a search plan can cut a thumbnail from a source already in memory (SourceRef::Fit) without touching the drive — which is the same short count, not a stopped search. Clearing them makes the test measure the scenario it describes (the second search reads the files the stopped one had not read), and the signatures the stopped search kept stay. The same wait is added to the two neighbouring tests that count reads.
Not run locally: cargo test -p lightcraft-ui-egui --lib -- tests::find_similar spent the run queued behind a heavily contended shared cargo target lock (its dependency build was still in progress when this PR opened), so CI runs it.
No actionable comments were generated in the recent review.
Walkthrough
Three find-similar tests now wait for expected photo reads to complete. The stopped-search test also clears cached media sources before retrying and verifies that the retry reads the remaining photos.
Changes: Find-similar test synchronization
Layer / File(s)
Summary
Wait for expected photo reads crates/ui-egui/src/tests/find_similar.rs
The menu-search and timed-out-request tests wait for all expected photo reads. The stopped-search test clears cached media sources before retrying, then waits for the remaining reads.
This change makes the find-similar tests wait for all expected photo reads before asserting, which should reduce intermittent failures. It has no production-code impact and no concrete merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the change: tests now wait for the drive's reads before counting them. The raw summary and PR objectives both describe a wait for all 12 reads before the count assertion in find_simila…
Linked Issues check
[#3823] The issue asks that the test wait on the drive read count before asserting, as line 152 already does with step_until. The diff adds `assert!(h.step_until(T, |_| drive.reads.load(Ordering::Se…
Out of Scope Changes check
All changes are in crates/ui-egui/src/tests/find_similar.rs and are test-only. The added waits are tied to the read-count race in #3823. The h.app.session.media.clear_sources() call is in the same…
Full details: Title check
Explanation
The title names the change: tests now wait for the drive's reads before counting them. The raw summary and PR objectives both describe a wait for all 12 reads before the count assertion in find_similar tests, so the title matches the main change. It is concise and specific. It names the test area (drive reads) and the fix (waiting before counting), and it is not vague or off-topic.
Full details: Linked Issues check
Explanation
[#3823] The issue asks that the test wait on the drive read count before asserting, as line 152 already does with step_until. The diff adds assert!(h.step_until(T, |_| drive.reads.load(Ordering::SeqCst) == PHOTOS as usize), ...) after until_done in stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_rest before the 12-read assertion. The same wait is added to two neighbouring read-count tests. If the count never reaches 12, step_until returns false and the test fails. The exact-read and filter-size assertions are unchanged. The author did not run the targeted test locally, so the fix is confirmed by code inspection only. The issue has no non-coding requirements.
Full details: Out of Scope Changes check
Explanation
All changes are in crates/ui-egui/src/tests/find_similar.rs and are test-only. The added waits are tied to the read-count race in #3823. The h.app.session.media.clear_sources() call is in the same test and changes its precondition before the second search. The PR justifies it as making the test measure the stated scenario, and the code and diff support that the call exists in this test. That rationale is not verified by a run, and it alters the test's setup beyond what the issue requests. Reviewers should confirm it through the CI run of the targeted test. No unrelated production or other test changes are present.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between fa5c438 and 98b9c19.
Files selected for processing: 1
crates/ui-egui/src/tests/find_similar.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
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
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.
find_similar::stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_restcounts the drive's reads right after the activity row clears, so under load the last reads land after the count and the assertion sees 10 or 11 of 12. The test now also waits, within its existingstep_until(T, …)budget, for the drive to record all 12 reads before asserting; the assertions (exactly 12 reads, filter holds half the library) are unchanged.It also clears the session's in-memory decoded sources before the second search. In the Detail view the loupe's render and neighbour prefetch decode through the same drive, so a search plan can cut a thumbnail from a source already in memory (
SourceRef::Fit) without touching the drive — which is the same short count, not a stopped search. Clearing them makes the test measure the scenario it describes (the second search reads the files the stopped one had not read), and the signatures the stopped search kept stay. The same wait is added to the two neighbouring tests that count reads.Test-only change; no production code.
Ran:
rustfmt --edition 2024 --check crates/ui-egui/src/tests/find_similar.rs— clean.Not run locally:
cargo test -p lightcraft-ui-egui --lib -- tests::find_similarspent the run queued behind a heavily contended shared cargo target lock (its dependency build was still in progress when this PR opened), so CI runs it.Fixes #3823
Summary by CodeRabbit