Add golden output tests for powershell, sh, sudo, and cmd#352
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds golden tests that pin exact command formatting output for shell, PowerShell, sudo, and executor command wrapping/redaction/decorator behavior.
Changes:
- Adds PowerShell golden tests for command mode selection and quoting helpers.
- Adds POSIX shell and sudo golden tests for command construction and escaping.
- Adds executor golden tests for Windows wrapping, redaction-related behavior, decorator composition, and output trimming.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
powershell/golden_test.go |
Adds exact-output tests for PowerShell command formatting and quoting helpers. |
sh/golden_test.go |
Adds exact-output tests for shell command construction, builders, and shell escaping. |
sudo/sudo_test.go |
Adds exact-output tests for sudo command decoration. |
cmd/golden_test.go |
Adds executor golden tests for Windows wrapping, redaction-related behavior, decorators, and output trimming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pin exact output strings for command formatting APIs that are easy to break
with small cleanup changes. Tests use realistic fixtures (k0s, systemctl,
apt-get, journalctl) rather than synthetic strings.
- powershell: TestCmdGolden pins -Command vs -EncodedCommand selection and
exact command strings for pipe, newline, double-quote, and begin-block inputs;
TestSingleQuoteGolden and TestDoubleQuoteGolden cover PS quoting edge cases
- sh: TestCommandGolden pins sh.Command output for flags, paths, and args with
special characters; TestCommandBuilderGolden pins chained Pipe/Arg/redirect
operations; TestQuoteGolden captures shellescape edge cases including the
note that ^ is not in the special-char set
- sudo: TestSudoGolden pins the sudo -n -- "${SHELL-sh}" -c template for
simple commands, nested-quoted arguments, and pipe-containing commands
- cmd: TestWindowsCommandWrappingGolden pins cmd.exe /C wrapping vs exe
pass-through; TestRedactInCommandLog verifies redaction does not sanitize
wire-level commands; TestDecoratorPipelineGolden pins global-then-per-call
decorator ordering; TestExecOutputTrimGolden pins default-trim behavior
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
cbb2fe7 to
7ab1c7e
Compare
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.
Pin exact output strings for command formatting APIs. Tests use realistic fixtures (k0s, systemctl, apt-get, journalctl) rather than synthetic strings.