Display output for teardown commands (#40825)
* Print id * Fix tests
AmirMS committed
Jun 16, 2026 at 18:49 UTC
b33dbf0d8efd0d1bd9df5aab2c7d704a7df0985d
4 files changed
+11
-9
src/windows/wslc/tasks/ContainerTasks.cpp
+2
@@ -360,6 +360,7 @@ void RemoveContainers(CLIExecutionContext& context)
360
for (const auto& id : containerIds)
361
{
362
ContainerService::Delete(session, WideToMultiByte(id), force);
363
+ PrintMessage(id);
364
}
365
}
366
@@ -750,6 +751,7 @@ void StopContainers(CLIExecutionContext& context)
751
for (const auto& id : containersToStop)
752
{
753
ContainerService::Stop(context.Data.Get<Data::Session>(), WideToMultiByte(id), options);
754
+ PrintMessage(id);
755
}
756
}
757
test/windows/wslc/e2e/WSLCE2EContainerRemoveTests.cpp
+4
-4
@@ -75,7 +75,7 @@ class WSLCE2EContainerRemoveTests
75
76
// Delete the container
77
result = RunWslc(std::format(L"container remove {}", WslcContainerName));
78
- result.Verify({.Stdout = L"", .Stderr = L"", .ExitCode = 0});
78
+ result.Verify({.Stdout = std::format(L"{}\r\n", WslcContainerName), .Stderr = L"", .ExitCode = 0});
79
80
// Verify the container is no longer listed
81
VerifyContainerIsNotListed(WslcContainerName);
@@ -93,7 +93,7 @@ class WSLCE2EContainerRemoveTests
93
VerifyContainerIsListed(containerId, L"created");
94
95
result = RunWslc(std::format(L"container remove {}", containerId));
96
- result.Verify({.Stdout = L"", .Stderr = L"", .ExitCode = 0});
96
+ result.Verify({.Stdout = std::format(L"{}\r\n", containerId), .Stderr = L"", .ExitCode = 0});
97
98
VerifyContainerIsNotListed(containerId);
99
VerifyContainerIsNotListed(WslcContainerName);
@@ -123,7 +123,7 @@ class WSLCE2EContainerRemoveTests
123
124
// Removing with force should succeed
125
result = RunWslc(std::format(L"container remove --force {}", containerId));
126
- result.Verify({.Stdout = L"", .Stderr = L"", .ExitCode = 0});
126
+ result.Verify({.Stdout = std::format(L"{}\r\n", containerId), .Stderr = L"", .ExitCode = 0});
127
128
VerifyContainerIsNotListed(containerId);
129
VerifyContainerIsNotListed(WslcContainerName);
@@ -148,7 +148,7 @@ class WSLCE2EContainerRemoveTests
148
VerifyContainerIsListed(containerId2, L"created");
149
150
result = RunWslc(std::format(L"container remove {} {}", containerId1, containerId2));
151
- result.Verify({.Stdout = L"", .Stderr = L"", .ExitCode = 0});
151
+ result.Verify({.Stdout = std::format(L"{}\r\n{}\r\n", containerId1, containerId2), .Stderr = L"", .ExitCode = 0});
152
153
VerifyContainerIsNotListed(containerId1);
154
VerifyContainerIsNotListed(containerId2);
test/windows/wslc/e2e/WSLCE2EContainerStopTests.cpp
+4
-4
@@ -79,7 +79,7 @@ class WSLCE2EContainerStopTests
79
80
// Stop the container
81
result = RunWslc(std::format(L"container stop {} -t 0", containerId));
82
- result.Verify({.Stderr = L"", .ExitCode = 0});
82
+ result.Verify({.Stdout = std::format(L"{}\r\n", containerId), .Stderr = L"", .ExitCode = 0});
83
84
// Verify the container is no longer running
85
VerifyContainerIsListed(containerId, L"exited");
@@ -98,7 +98,7 @@ class WSLCE2EContainerStopTests
98
99
// Stop by container name
100
result = RunWslc(std::format(L"container stop {} -t 0", WslcContainerName));
101
- result.Verify({.Stderr = L"", .ExitCode = 0});
101
+ result.Verify({.Stdout = std::format(L"{}\r\n", WslcContainerName), .Stderr = L"", .ExitCode = 0});
102
103
// Verify container is no longer running
104
VerifyContainerIsListed(containerId, L"exited");
@@ -153,7 +153,7 @@ class WSLCE2EContainerStopTests
153
154
// Stop only the first container
155
result = RunWslc(std::format(L"container stop {} -t 0", firstContainerId));
156
- result.Verify({.Stderr = L"", .ExitCode = 0});
156
+ result.Verify({.Stdout = std::format(L"{}\r\n", firstContainerId), .Stderr = L"", .ExitCode = 0});
157
158
// Verify first exited, second still running
159
VerifyContainerIsListed(firstContainerId, L"exited");
@@ -173,7 +173,7 @@ class WSLCE2EContainerStopTests
173
174
// Stop the container using signal name
175
result = RunWslc(std::format(L"container stop {} -s SIGKILL -t 0", containerId));
176
- result.Verify({.Stderr = L"", .ExitCode = 0});
176
+ result.Verify({.Stdout = std::format(L"{}\r\n", containerId), .Stderr = L"", .ExitCode = 0});
177
178
// Verify the container is no longer running
179
VerifyContainerIsListed(containerId, L"exited");
test/windows/wslc/e2e/WSLCE2EHelpers.cpp
+1
-1
@@ -351,7 +351,7 @@ void EnsureImageContainersAreDeleted(const TestImage& image)
351
if (container.Image.find(nameAndTag) != std::string::npos)
352
{
353
auto result = RunWslc(std::format(L"container remove --force {}", container.Id));
354
- result.Verify({.Stdout = L"", .Stderr = L"", .ExitCode = 0});
354
+ result.Verify({.Stdout = std::format(L"{}\r\n", container.Id), .Stderr = L"", .ExitCode = 0});
355
}
356
}
357
}