Skip to content

CLI: TableOutput unit tests#40095

Open
dkbennett wants to merge 5 commits intofeature/wsl-for-appsfrom
user/dkbennett/tabletests
Open

CLI: TableOutput unit tests#40095
dkbennett wants to merge 5 commits intofeature/wsl-for-appsfrom
user/dkbennett/tabletests

Conversation

@dkbennett
Copy link
Copy Markdown
Member

Summary of the Pull Request

Updates the table class slightly to make it easier for unit testing.
Adds unit tests to verify table output behavior.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Main change to tableoutput is adding a default output function and the ability to override it. The override is mainly for testing, but it may be useful in other contexts in the future.

Validation Steps Performed

Tests validated and passed

Copilot AI review requested due to automatic review settings April 3, 2026 16:44
Copy link
Copy Markdown
Contributor

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 makes TableOutput more unit-testable by adding injectable output and a console-width override, and introduces new CLI-focused unit tests to validate table rendering behavior.

Changes:

  • Add an overridable output function to TableOutput (defaulting to stdout) to enable in-memory capture in tests.
  • Add a console width override to make column-shrinking tests deterministic.
  • Add a new unit test suite covering headers, padding, width expansion/truncation, shrinking, and IsEmpty().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Adds unit tests for TableOutput rendering and sizing behavior using the new output injection hooks.
src/windows/wslc/core/TableOutput.h Adds SetOutputFunction and SetConsoleWidthOverride, and routes rendered lines through the configured output function.

Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp
Comment thread src/windows/wslc/core/TableOutput.h
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
@benhillis
Copy link
Copy Markdown
Member

Hey @dkbennett 👋 — Following up on this draft PR. CI is green, but there are 6 unresolved review threads that still need to be addressed:

  • File header mismatch
  • Spacing assertion too weak
  • Off-by-one in position calculation
  • Missing \
    pos\ guards
  • Empty function guard in \SetOutputFunction\
  • Suggestion to move to a shared helper

Is this change still being worked on? It's been a few days since the last update. Let us know if you need any help with the review feedback!

Copilot AI review requested due to automatic review settings April 17, 2026 21:38
@dkbennett dkbennett marked this pull request as ready for review April 17, 2026 21:40
@dkbennett dkbennett requested a review from a team as a code owner April 17, 2026 21:40
@dkbennett
Copy link
Copy Markdown
Member Author

Hey @dkbennett 👋 — Following up on this draft PR. CI is green, but there are 6 unresolved review threads that still need to be addressed:

  • File header mismatch
  • Spacing assertion too weak
  • Off-by-one in position calculation
  • Missing
    pos\ guards
  • Empty function guard in \SetOutputFunction\
  • Suggestion to move to a shared helper

Is this change still being worked on? It's been a few days since the last update. Let us know if you need any help with the review feedback!

Sorry I got distracted with other things and forgot about this draft PR. I've fixed it up and it is ready.

Copy link
Copy Markdown
Contributor

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 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread src/windows/wslc/core/TableOutput.h
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLITableOutputUnitTests.cpp Outdated
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.

4 participants