Skip to content

widget.py: Avoid extra empty lines when message-lines or error-lines is 0 - #2208

Open
Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/message-lines-zero
Open

Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/message-lines-zero

Conversation

@Thanatos9404

Copy link
Copy Markdown

With message-lines set to 0, the detail of a message is truncated to nothing, but LogLine still prints an empty line, a line holding only the indentation and another empty line after the message. A failure message in verbose mode with error-lines set to 0 is followed by two empty lines instead of one.

The detail is now only printed when some of it is left, and the newline before the failure details is only added when they are shown. Failure messages keep their single trailing empty line, so entries in the failure summary stay separated. Output is unchanged when both options are non-zero.

I added tests in tests/frontend/logging.py that render messages through LogLine, and ran tests/frontend, black, pylint and mypy locally.

Fixes #2145

…is 0

With message-lines set to 0, the detail of a message is truncated
away entirely, but LogLine still prints an empty line, a line with
only the indentation and another empty line after the message.

Likewise, a failure message in verbose mode with error-lines set to 0
skips the log tail, but is still followed by two empty lines instead
of the usual one.

Only print the message detail when some of it is left, and only add
the newline that introduces the failure details when they are printed.
Failure messages keep the single empty line that separates them from
the next message, and from the next entry in the failure summary.

Fixes apache#2145
Render messages with LogLine and check that no empty lines are left
behind when message-lines is 0, that a truncated message still reports
how many lines were left out, and that a failure message is followed
by a single empty line when error-lines is 0.

This is a part of apache#2145
text += self._detail_profile.fmt(log_content)
text += "\n"
text += self._indent + self._err_profile.fmt("=" * 70) + "\n"
extra_nl = True

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.

Shouldn't this also be moved into the if branches, or is there a reason why this should be set independent of the conditionals?

This branch has not been deployed

No deployments
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.

Multiple empty lines are still printed when message-lines (and error-lines) is set to 0

2 participants