Skip to content

tst_mainwindow: wait for a quiet store tree before staging or negatives - #2423

Merged
annejan merged 2 commits into
mainfrom
test/quiet-tree
Nov 30, 2026
Merged

annejan merged 2 commits into
mainfrom
test/quiet-tree

Conversation

@annejan

@annejan annejan commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #2422, for the two non-blocking notes in its review.

  • Staged waits could come undone. newSearchTextCancelsAWaitingOpen and acceptedSettingsCancelAWaitingOpen stage the tree by setting a name filter on its model (hideAllBut()). A reload the new entries set off swaps in a model from makeModel() without that filter. The test then skips with kCannotStage, which on a slow macOS runner hides what it is for.
  • Negative checks could pass without looking. searchMatchesWordsLiterallyAndInOrder checks what the filtered tree does not show. A tree between two models shows nothing, so those checks passed regardless.

tst_mainwindow::waitForQuietTree() waits until the tree has been quiet for a second: no reload queued (m_reloadTimer), no fresh model being built (m_fresh), and no listing still under way after a swap (m_stillListing). The two staged tests call it before staging. The search test calls it first and checks at the end that the model it looked at is still the one the tree shows. StoreTree names tst_mainwindow a friend for this, as it already does tst_storetree; no product behaviour changes.

Test plan

  • tst_mainwindow three times in a row: 148 passed, 0 failed; the two skips are the Windows-only and case-insensitive-FS tests, not kCannotStage
  • Six tst_mainwindow runs in parallel: all 148 passed
  • doxygen Doxyfile prints no warnings
  • macOS (Qt 6.11) green on this PR

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated main-window tests to wait for file-tree activity to settle before checking search results, cancellation behavior, or menu removal.
    • Added a check that the source model remains unchanged during search-result verification.
    • Replaced a fixed delay in the menu-removal test with a stability check and added state details to help diagnose timeouts.

Two notes from the review of #2422:

- newSearchTextCancelsAWaitingOpen and acceptedSettingsCancelAWaitingOpen
  stage the tree by setting a name filter on its model. A reload the new
  entries set off swaps in a model without it, and the test then skips
  (kCannotStage), which on a slow runner hides what it is for.
- searchMatchesWordsLiterallyAndInOrder checks what the filtered tree
  does not show; between two models it shows nothing, so those checks
  could pass without having looked.

waitForQuietTree() waits until the tree has been quiet for a second: no
reload queued, no fresh model being built, no listing still under way
after a swap. The staged tests call it before staging; the search test
calls it first and checks at the end that the model it looked at is
still the one the tree shows. StoreTree names tst_mainwindow a friend
for this, as it does tst_storetree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anne Jan Brouwer <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The main window tests now wait for StoreTree to remain inactive before checking search results, staging waiting-open cases, or removing a folder. The search test checks that its source model remains unchanged. Menu timeout failures report additional tree and filesystem state.

Changes: StoreTree test stability

Layer / File(s) Summary
Quiet-tree test setup and assertions
src/storetree.h, tests/auto/mainwindow/tst_mainwindow.cpp
tst_mainwindow gains friend access to StoreTree. The test file adds waitForQuietTree(), which waits up to 20 seconds for reload, fresh-model, and pending-listing activity to remain inactive for one second. The search test, two waiting-open tests, and menu-removal test use the helper. The search test checks that the source model remains unchanged during filter checks. The menu timeout failure reports reload, model, listing, current-file, folder, and watcher-directory state.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • IJHack/QtPass#2410: Changes when a StoreTree restore ends after a model swap, involving listing and restore lifecycle states used by the quiet-tree wait.
  • IJHack/QtPass#2409: Adds the StoreTree rebuild and queued-reload mechanism whose states the test helper checks.
  • IJHack/QtPass#2422: Updates related tst_mainwindow model-row lookup helpers and extends the search test also changed here.

Suggested reviewers: nogeenhenk

Merge Risk: Minimal · up to 8340c

This follow-up makes the main window tests wait for the tree to settle and adds failure diagnostics. It does not change product behavior. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test file and the main change: the tests now wait for a quiet store tree before staging or checking negative search results. The changeset adds waitForQuietTree() and applies it in…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the test file and the main change: the tests now wait for a quiet store tree before staging or checking negative search results. The changeset adds waitForQuietTree() and applies it in the word-search and waiting-open cancellation tests, and the menu-removal test as well. The title is specific and matches the primary change. It does not mention the StoreTree friend declaration or the diagnostic output, which is expected for a short title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • 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.

Share

A rabbit waits while reloads wind down
One quiet second, then checks the tree
Search keeps its source model in place
Menu clues arrive if time runs out
The tests hop on when the state is clear

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 2018ad31-3724-4036-965f-cdf76cf35aa4
Commits

Reviewing files that changed from the base of the PR and between 4858493 and 8340cc4.

Files selected for processing: 1

  • tests/auto/mainwindow/tst_mainwindow.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@coveralls

coveralls commented Nov 30, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 94.557% (+0.1%) from 94.424% — test/quiet-tree into main

aTreeMenuClosesWhenItsFolderIsGone failed on the macOS runner of #2423
with the menu still open after 30 s. It let the listings settle with a
fixed qWait(1000); a reload still building when the folder is removed
swaps in a list that has it. It now uses waitForQuietTree(), and when
the menu has to be closed the failure names what the tree was doing
(reload queued, fresh model, listings under way, current entry, whether
the folder exists, watched folders), so a next failure shows which step
stalled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anne Jan Brouwer <[email protected]>
@annejan

annejan commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

The macOS job failed in aTreeMenuClosesWhenItsFolderIsGone (menu still open after 30 s), the fourth flake from before #2422. 8340cc4 replaces its fixed qWait(1000) with waitForQuietTree(), and if the menu still has to be closed the failure message now names the tree's state (reload queued, fresh model, listings under way, current entry, folder exists, watched folders).

@nogeenhenk nogeenhenk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 8340cc4. Test only, plus a friend in storetree.h; it covers both notes from my review of #2422. waitForQuietTree() waits for the three states a swap goes through (m_reloadTimer, m_fresh, m_stillListing), so staging and the negative checks happen on the model the tree keeps. Neither a name filter nor a search touches the disk, so nothing the tests do after the wait sets off another reload. The final check in the search test, that the source model is still the one it looked at, turns a swap during the negatives into a failure instead of a silent pass. Nothing to add.

On the last commit, one note, not blocking. The explanation for the macOS failure, a reload still building when the folder goes and swapping in a list that has it, should not leave the menu open for 30 s in the product: the removal changes the store root, reload() then finds m_fresh busy and sets m_reloadAgain, and the reload after the swap no longer finds the folder. So waiting for a quiet tree makes the test pass, but if that path is what stalled on macOS, a user with a menu open during a pull could hit it too. The state the test now prints on failure is the right way to find out; if it shows up again, I would look at that path before widening the wait.


Generated by Claude Code

@annejan
annejan merged commit 6d80d81 into main Nov 30, 2026
33 checks passed
@annejan
annejan deleted the test/quiet-tree branch November 30, 2026 23:35
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.

3 participants