Skip to content

CLI: Unit test to ensure no argument name or alias collisions exist#40312

Merged
dkbennett merged 4 commits intofeature/wsl-for-appsfrom
user/dkbennett/aliascollisiontest
Apr 24, 2026
Merged

CLI: Unit test to ensure no argument name or alias collisions exist#40312
dkbennett merged 4 commits intofeature/wsl-for-appsfrom
user/dkbennett/aliascollisiontest

Conversation

@dkbennett
Copy link
Copy Markdown
Member

@dkbennett dkbennett commented Apr 24, 2026

Summary of the Pull Request

Simple test that walks the CLI command tree and ensures no commands have ambiguous names or aliases that map to different arguments.

Example of finding a collision (I intentionally gave session the same alias as help to force a collision)
image

Example of no collisions (the above alias removed)
image

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

Walks the command tree from the Root and examines arguments of each command and ensures there are no duplicate names or aliases in any of them.

Validation Steps Performed

Test passes!

@dkbennett dkbennett requested a review from a team as a code owner April 24, 2026 18:52
Copilot AI review requested due to automatic review settings April 24, 2026 18:52
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a CLI unit test that walks the command tree from the root and asserts that argument names and aliases are unique per command, preventing ambiguous CLI argument parsing.

Changes:

  • Added a breadth/depth traversal over the CLI command tree starting at RootCommand.
  • Added per-command checks for duplicate argument long names and short aliases.

Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Copy link
Copy Markdown

@AmelBawa-msft AmelBawa-msft left a comment

Choose a reason for hiding this comment

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

Approve with suggestions

Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 20:05
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 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread test/windows/wslc/WSLCCLICommandUnitTests.cpp
@dkbennett dkbennett enabled auto-merge (squash) April 24, 2026 20:13
@dkbennett dkbennett merged commit c4b819d into feature/wsl-for-apps Apr 24, 2026
8 checks passed
@dkbennett dkbennett deleted the user/dkbennett/aliascollisiontest branch April 24, 2026 21:58
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