Simplify e2e build-test image cleanup with per-test RAII ownership - #41094
Merged
Conversation
Replace the hand-maintained DeleteAllBuiltImages() static list (run in both TEST_METHOD_SETUP and TEST_METHOD_CLEANUP, sweeping every built image twice per test and flooding the log with VERIFY lines) with: - A per-test DeleteImageOnExit() RAII guard so each test owns and cleans up exactly the image(s) it builds. It is best-effort and non-throwing (no VERIFY) since it may run during stack unwinding after a failure. - A single class-level DeleteImagesWithRepositoryPrefix() prune in ClassSetup and ClassCleanup as the authoritative safety net for images left behind by a crashed run. This removes the per-method sweeps, the static image list, and the excessive per-field VERIFY logging that dominated test output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the WSLC image-build end-to-end testsâ cleanup strategy to reduce per-test log noise and improve resilience by moving from a hardcoded âsweep everythingâ list to per-test RAII cleanup plus a class-level safety-net prune.
Changes:
- Replaced per-method
DeleteAllBuiltImages()sweeps with per-testDeleteImageOnExit()RAII guards for images built in each test. - Added
DeleteImagesWithRepositoryPrefix()helper and used it in class setup/cleanup as the crash-recovery safety net. - Removed the hand-maintained
DeleteAllBuiltImages()list and associated setup/cleanup hooks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/windows/wslc/e2e/WSLCE2EImageBuildTests.cpp | Switches to per-test RAII image deletion and class-level prefix-based pruning. |
| test/windows/wslc/e2e/WSLCE2EHelpers.h | Declares the new prefix-based image deletion helper. |
| test/windows/wslc/e2e/WSLCE2EHelpers.cpp | Implements prefix-based bulk image deletion via image list --format json. |
Added comments to clarify image deletion logic in WSLCE2EHelpers.cpp.
David Bennett (dkbennett)
approved these changes
Jul 16, 2026
John Stephens (johnstep)
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the image cleanup logic in the
WSLCE2EImageBuildTestsend-to-end test suite to be more robust and maintainable. It introduces a new helper function for bulk image deletion by repository prefix, replaces per-method sweeping with targeted per-test cleanup, and removes the old manual deletion code. The changes improve test reliability, especially in the presence of test failures or crashes.Test cleanup improvements:
DeleteImagesWithRepositoryPrefixthat deletes all images whose repository names start with a given prefix, making bulk cleanup more reliable and less error-prone. [1] [2]WSLCE2EImageBuildTeststo use the new prefix-based image deletion helper, ensuring any leftover images from previous runs are removed.DeleteAllBuiltImages) in favor of using an RAII-styleDeleteImageOnExitguard for each test, which ensures only images created by a test are cleaned up, even if the test fails. [1] [2] [3] [4] [5] [6] [7] [8]DeleteAllBuiltImagesmethod and its invocations, simplifying the codebase.This removes the per-method sweeps, the static image list, and the excessive per-field VERIFY logging that dominated test output.
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed