test/helpers: introduce CmdStreamBuffer to manipulate a command's output #12252
Merged
test/helpers: introduce CmdStreamBuffer to manipulate a command's output #12252
Conversation
7d1cc2d to
c282642
Compare
gandro
approved these changes
Jun 24, 2020
Member
Author
|
test-me-please |
nebril
requested changes
Jun 24, 2020
Member
nebril
left a comment
There was a problem hiding this comment.
Great change overall! I think we missed some other tests need to be adjusted
The current implementation of `CmdRes` allows to perform a certain number of operations on the standard output stream of a command. However, these operations are not available for the standard error stream of a command. This commit adds a new type, `CmdStreamBuffer` which is a superset of `Buffer`. It has basic operations to process the buffered stream namely `ByLines()`, `KVOutput()`, `Filter()`, `FilterLineJSONPath()` and `FilterLines()`. These methods, which were part of `CmdRes`, are still available to `CmdRes` but they have been updated to call the respective methods from the standard output stream's corresponding methods. Two new methods have been added to `CmdRes`: `GetStdOut()` which returns a `CmdStreamBuffer` for the standard output stream and `GetStdErr()` which returns a `CmdStreamBuffer` for the standard error stream. The new methods `Stdout()` and `Stderr()` return the respective buffers content as string. The method `Output()`, which return the `CmdRes` stdout has been removed to avoid any confusion. All Go code in tests has been adapted to these changes. Signed-off-by: Robin Hahling <robin.hahling@gw-computing.net>
Handling both `\n` and `\r\n` was part of `CmdRes` already but this treatment has never been propagated to `FilterBuffer`. Signed-off-by: Robin Hahling <robin.hahling@gw-computing.net>
c282642 to
31e9af5
Compare
Member
Author
|
test-me-please |
Member
Author
|
@nebril Yup, noticed and hopefully fixed. |
nebril
approved these changes
Jun 24, 2020
Member
nebril
left a comment
There was a problem hiding this comment.
I will monitor whether this breaks nightly, but let's ship it.
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.
The current implementation of
CmdResallows to perform a certainnumber of operations on the standard output stream of a command.
However, these operations are not available for the standard error
stream of a command.
This commit adds a new type,
CmdStreamBufferwhich is a superset ofBuffer. It has basic operations to process the buffered stream namelyByLines(),KVOutput(),Filter(),FilterLineJSONPath()andFilterLines(). These methods, which were part ofCmdRes, are stillavailable to
CmdResbut they have been updated to call the respectivemethods from the standard output stream's corresponding methods.
Two new methods have been added to
CmdRes:GetStdOut()which returnsa
CmdStreamBufferfor the standard output stream andGetStdErr()which returns a
CmdStreamBufferfor the standard error stream.The new methods
Stdout()andStderr()return the respective bufferscontent as string. The method
Output(), which return theCmdResstdout has been removed to avoid any confusion.
All Go code in tests has been adapted to these changes.