[cli] Print status at intervals when no TTY#4819
Closed
ShadiBahaa wants to merge 1 commit intocanonical:mainfrom
Closed
[cli] Print status at intervals when no TTY#4819ShadiBahaa wants to merge 1 commit intocanonical:mainfrom
ShadiBahaa wants to merge 1 commit intocanonical:mainfrom
Conversation
When stdout is not a TTY, the animated spinner outputs ANSI escape codes that produce garbled output. This makes integration test output silent and hard to debug. Detect non-TTY via the existing Terminal::cout_is_live() and fall back to printing plain-text status lines with periodic dots instead of the animated spinner. Closes: canonical#2939
Member
|
Duplicate of #4706. |
Collaborator
|
Hi @ShadiBahaa, there is a PR already in flight to address this, as @xmkg pointed out above. |
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.
Summary
When stdout is not a TTY (e.g. in CI pipelines, integration tests, or piped output), the
AnimatedSpinnerunconditionally outputs ANSI escape codes and backspace characters. This produces garbled or silent output, making it difficult to monitor progress or debug issues in headless environments.This PR makes the spinner TTY-aware:
is_liveparameter toAnimatedSpinnerthat indicates whether stdout is a terminalterm->cout_is_live()when constructing the spinner, using the existingTerminalTTY-detection infrastructure (POSIXisatty()on Unix,GetConsoleScreenBufferInfo()on Windows)Test plan
test_common_callbacks.cppcontinue to passmultipass start) in a terminal and verify the animated spinner still worksmultipass start 2>&1 | cat) and verify plain-text output with no ANSI escape codesCloses #2939