Skip to content

Add golden output tests for powershell, sh, sudo, and cmd#352

Merged
kke merged 1 commit into
mainfrom
golden-tests-command-formatting
May 28, 2026
Merged

Add golden output tests for powershell, sh, sudo, and cmd#352
kke merged 1 commit into
mainfrom
golden-tests-command-formatting

Conversation

@kke
Copy link
Copy Markdown
Contributor

@kke kke commented May 27, 2026

Pin exact output strings for command formatting APIs. 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
  • 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 commands; TestDecoratorPipelineGolden pins global-then-per-call decorator ordering; TestExecOutputTrimGolden pins default-trim behavior

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmd/golden_test.go Outdated
Comment thread cmd/golden_test.go Outdated
Comment thread sudo/sudo_test.go Outdated
@kke kke requested a review from Copilot May 27, 2026 07:26
@kke kke marked this pull request as ready for review May 27, 2026 07:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread sh/golden_test.go Outdated
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>
@kke kke force-pushed the golden-tests-command-formatting branch from cbb2fe7 to 7ab1c7e Compare May 27, 2026 11:09
@kke kke requested a review from Copilot May 27, 2026 11:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@kke kke merged commit 3cf06b6 into main May 28, 2026
12 checks passed
@kke kke deleted the golden-tests-command-formatting branch May 28, 2026 11:27
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.

2 participants