Skip to content

Commit 70b1e83

Browse files
author
Pooja Trivedi
committed
[WSLC] Add E2E version command test and strengthen unit test
- Add WSLCE2E_VersionCommand E2E test in WSLCE2EGlobalTests verifying stdout, empty stderr, and exit code for 'wslc version' - Add assertion to VersionCommand_HasNoArguments unit test to verify only the auto-added --help argument is present Authored-By: Pooja Trivedi <trivedipooja@microsoft.com> Co-Authored-By: Claude Sonnet 4.6
1 parent 660b493 commit 70b1e83

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

test/windows/wslc/WSLCCLICommandUnitTests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class WSLCCLICommandUnitTests
116116
{
117117
auto cmd = VersionCommand(L"wslc");
118118
VERIFY_ARE_EQUAL(0u, cmd.GetArguments().size());
119+
// Test out that auto added help command is the only one
120+
VERIFY_ARE_EQUAL(1u, cmd.GetAllArguments().size());
119121
}
120122

121123
// Test: Verify RootCommand contains VersionCommand as a subcommand

test/windows/wslc/e2e/WSLCE2EGlobalTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class WSLCE2EGlobalTests
4444
RunWslcAndVerify(L"INVALID_CMD", {.Stdout = GetHelpMessage(), .Stderr = L"Unrecognized command: 'INVALID_CMD'\r\n", .ExitCode = 1});
4545
}
4646

47+
TEST_METHOD(WSLCE2E_VersionCommand)
48+
{
49+
WSL2_TEST_ONLY();
50+
RunWslcAndVerify(L"version", {.Stdout = GetVersionMessage(), .Stderr = L"", .ExitCode = 0});
51+
}
52+
4753
private:
4854
std::wstring GetHelpMessage() const
4955
{
@@ -56,6 +62,11 @@ class WSLCE2EGlobalTests
5662
return output.str();
5763
}
5864

65+
std::wstring GetVersionMessage() const
66+
{
67+
return std::format(L"wslc v{}\r\n", WSL_PACKAGE_VERSION);
68+
}
69+
5970
std::wstring GetDescription() const
6071
{
6172
return L"WSLC is the Windows Subsystem for Linux Container CLI tool. It enables management and interaction with WSL "

0 commit comments

Comments
 (0)