-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
IDLE shell sidebar fixing CI #25628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDLE shell sidebar fixing CI #25628
Conversation
Specifically, avoid EditorWindow.ResetColorizer() moving the undo and colorizer delegators to the top of the percolator, by removing and inserting them.
This avoids ColorDelegator removing unrelated tags, specifically "stdin", when re-colorizing.
Prompts are now marked in the text by adding the "console" tag to the newline character ('\n') before the beginning of the line. This works around issues with the prompt itself usually no longer being written in the text widget. With another small fix to the PyShell.recall() method, input lines can now be recognized consistently by checking for the "stdin" tag. This is much better than attempting to separately track the prompt and input lines, since those are difficult to keep up to date after undo/redo actions and squeezing/unsqueezing of previous output.
The background color still uses that configured for line numbers.
The fix needed was for History to properly set the "stdin" tag on text it inserts.
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Tal, I presume you made this initially duplicate branch so you could fiddle around with the code and test on Pipelines without having to revert experiments on the main branch. So I don't need to review this initial copy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for test_sidebar itself. I moved this name comments and one code comment to the original, but cannot see any way to cancel this pending review.
The 5 failures are the same on all 3 systems: Ubuntu, Win32, and Win64. Moreover, the failures were all the same in that they only happen when there is an output line (a None in the sidebar list) between first code lines ('>>>' in the sidebar list). Then on these 3 systems, None was moved up above the first '>>>'. The two tests with no None after '>>>' did not fail. A quick fix would be to run the simplest test in setUpClass (or before the class) inside try-except to set a flag on the bad systems and use that to skip the 5 failing tests: Pipelines somehow executes tkinter gui code differently (and seemingly wrongly) from GHA, Travis, and our systems. Does it use different simulator? Steve Dower might know, and we could ask, maybe after narrowing down the difference a bit more. I will upload a patch for debug prints. The tricky part is that shell intercepts stdout/err (and anything added there breaks tests!). So text must be saved to be printed after shell is destroyed. Initially, I am capturing the content of shell.text. You can adjust to capture, for instance, whatever mark and tagging the sidebar uses to create its list. |
On my machine, the text contents, after the boilerplate header, are, for multiline statement,
and for single-line statement.
(The space at top and bottom is the exaggerated interline space, not blank lines)l. The single-line text corresponds to ['>>>', None, '>>>'] in the sidebar, the last prompt being opposite the empty line after the output, waiting for input. |
I believe that our sidebar tests are failing because on Ubuntu and Windows, Pipelines, unlike other test runners, captures sys.stdout for each test method in a way that keep output from reaching shell. The direct evidence is that Pipeline prints the output after the test in verbose mode after failure reports.
The indirect evidence is that it explains all the failure reports with a plausible interpretation. For instance
for
My previously statement 'None is moved' was, I believe wrong. The None for the output print is missing when the output is missing. The replacement as the beginning of the fixed length slice is whatever was before the input prompt. In this case it is None. If the previous line were, for instance Possible fixes, other than skipping, to make tests pass.
I had already thought that only testing within process was slightly dubious. But I don't know all the implications of using subprocess and sockets in tests, or what special helper might be needed or useful. 2. seem easy and maybe fastest in execution. I hope tomorrow to do more manual testing and look at how to change indents to spaces. I believe a PR for the latter will not conflict with this one. For a beta release, these are more important than polishing the code. |
@terryjreedy, thanks for helping to work on this, and that's some excellent analysis! You seem to have found the source of the issue with PyShell's setting of sys.stdout apparently being somehow disabled. I've pushed a commit which tries to reset |
Hurrah, it worked!!!! 🥳 |
Are we done with this? It seems to have served it purpose. |
Indeed. |
TESTING TESTING 123
Trying to fix tests failing in CI, see PR GH-22682.