PRint id (#40829)
AmirMS committed
Jun 16, 2026 at 23:08 UTC
cb31738dd2e8ebd73d862ea480534b8319fefc3c
3 files changed
+14
-7
src/windows/wslc/tasks/ContainerTasks.cpp
+9
-2
@@ -249,6 +249,7 @@ void KillContainers(CLIExecutionContext& context)
249
for (const auto& id : containerIds)
250
{
251
ContainerService::Kill(session, WideToMultiByte(id), signal);
252
+ PrintMessage(id);
253
}
254
}
255
@@ -728,8 +729,14 @@ void StartContainer(CLIExecutionContext& context)
729
{
730
WI_ASSERT(context.Data.Contains(Data::Session));
731
WI_ASSERT(context.Args.Contains(ArgType::ContainerId));
731
- const auto& id = WideToMultiByte(context.Args.Get<ArgType::ContainerId>());
732
- context.ExitCode = ContainerService::Start(context.Data.Get<Data::Session>(), id, context.Args.Contains(ArgType::Attach));
732
+ const auto& containerId = context.Args.Get<ArgType::ContainerId>();
733
+ const bool attach = context.Args.Contains(ArgType::Attach);
734
+ context.ExitCode = ContainerService::Start(context.Data.Get<Data::Session>(), WideToMultiByte(containerId), attach);
735
+
736
+ if (!attach)
737
+ {
738
+ PrintMessage(containerId);
739
+ }
740
}
741
742
void StopContainers(CLIExecutionContext& context)
test/windows/wslc/e2e/WSLCE2EContainerCreateTests.cpp
+2
-2
@@ -440,7 +440,7 @@ class WSLCE2EContainerCreateTests
440
441
// Start the container.
442
result = RunWslc(std::format(L"container start {}", WslcContainerName));
443
- result.Verify({.Stderr = L"", .ExitCode = 0});
443
+ result.Verify({.Stdout = std::format(L"{}\r\n", WslcContainerName), .Stderr = L"", .ExitCode = 0});
444
445
// Verify with retry timeout of 1 minute.
446
VerifyContainerIsNotListed(WslcContainerName, std::chrono::seconds(2), std::chrono::minutes(1));
@@ -458,7 +458,7 @@ class WSLCE2EContainerCreateTests
458
459
// Start again - should succeed without error
460
result = RunWslc(std::format(L"container start {}", WslcContainerName));
461
- result.Verify({.Stderr = L"", .ExitCode = 0});
461
+ result.Verify({.Stdout = std::format(L"{}\r\n", WslcContainerName), .Stderr = L"", .ExitCode = 0});
462
463
// Verify the container is still running
464
VerifyContainerIsListed(containerId, L"running");
test/windows/wslc/e2e/WSLCE2EContainerKillTests.cpp
+3
-3
@@ -63,7 +63,7 @@ class WSLCE2EContainerKillTests
63
64
// Kill the container
65
result = RunWslc(std::format(L"container kill {}", containerId));
66
- result.Verify({.Stderr = L"", .ExitCode = 0});
66
+ result.Verify({.Stdout = std::format(L"{}\r\n", containerId), .Stderr = L"", .ExitCode = 0});
67
68
// Verify the container is no longer running
69
VerifyContainerIsListed(containerId, L"exited");
@@ -82,7 +82,7 @@ class WSLCE2EContainerKillTests
82
83
// Kill by container name
84
result = RunWslc(std::format(L"container kill {}", WslcContainerName));
85
- result.Verify({.Stderr = L"", .ExitCode = 0});
85
+ result.Verify({.Stdout = std::format(L"{}\r\n", WslcContainerName), .Stderr = L"", .ExitCode = 0});
86
87
// Verify container is no longer running
88
VerifyContainerIsListed(containerId, L"exited");
@@ -134,7 +134,7 @@ class WSLCE2EContainerKillTests
134
135
// Kill only the first container
136
result = RunWslc(std::format(L"container kill {}", firstContainerId));
137
- result.Verify({.Stderr = L"", .ExitCode = 0});
137
+ result.Verify({.Stdout = std::format(L"{}\r\n", firstContainerId), .Stderr = L"", .ExitCode = 0});
138
139
// Verify first exited, second still running
140
VerifyContainerIsListed(firstContainerId, L"exited");