Repository navigation
Fix a flaky window title test with concurrent select menus - #1824
Merged
Merged
Conversation
test_instance_titles_do_not_cross_between_concurrent_select_menus sets the title "B" while the second menu is running and then, once the first menu has finished, "B active". A title set during a prompt is written by a callback on the prompt's event loop, and a title set before that callback runs replaces it. Nothing made the second menu's loop run before "B active" was set, so under load "B" was never written and the test failed. Wait for the second menu's loop to get past the callback before going on.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1824 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 23 23
Lines 6664 6664
=======================================
Hits 6648 6648
Misses 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
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.
test_instance_titles_do_not_cross_between_concurrent_select_menusfailed on ubuntu / Python 3.14 in CIfor #1815, on a commit which passed the same job in a second run:
Cause
The test sets the title
Bwhile the second menu is running, waits for the first menu to finish, andthen sets
B active. A title set during a prompt is written by a callback on that prompt's event loop,and a title set before the callback runs replaces it, as
set_window_title()documents. Nothing in thetest made the second menu's loop run between the two calls. When that thread was not scheduled in
time, only
B activewas written and the assertion thatBwas written failed.This is a race in the test.
cmd2behaves as documented, and no library code changes.Fix
After setting
B, queue a callback on the second menu's loop and wait for it. Callbacks run in order,so the title has been written by then.
Verification
Running the test 400 times per round on 14 xdist workers with every CPU saturated:
Every failure before the fix had
B activein the second stream and noB, matching the CI failure.Without load the test passed 400 of 400 times either way.