CLI: TableOutput unit tests#40095
Conversation
There was a problem hiding this comment.
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. |
|
Hey @dkbennett 👋 — Following up on this draft PR. CI is green, but there are 6 unresolved review threads that still need to be addressed:
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. |
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
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