test(workspaces): avoid module-list races when finding fixture processes #50596

Open
LegendaryBlair opened 1:52am on September 16, 2026 wants to merge 126 ฮ” into microsoft/powertoys main from
LegendaryBlair/fix-workspaces-process-image-query
Diff Delta:
126
About 154 Diff Delta/hour
Classified as:  Feature Add

LegendaryBlair's Description of Work

Summary of the Pull Request

Avoid an intermittent ERROR_PARTIAL_COPY failure when Workspaces UI tests identify a newly created fixture process.

Replace the helper's Process.MainModule.FileName read with QueryFullProcessImageName, using limited-query access. A live process can exist before its loader has initialized the module list; its executable image can already be queried without enumerating modules.

This is a minimal test-only change: one caller replacement, a native image-query helper, and one controlled startup regression. No product, IPC, installer, or pipeline behavior changes are included.

PR Checklist


  • [x] Communication: The focused test-stability fix was requested during the Workspaces CI investigation.

  • [x] Tests: Added a suspended-process regression; it fails with the original helper and passes with the image query.

N/A: localization, new binaries/dependencies, settings migrations, and user documentation changes.

Detailed Description of the Pull Request / Additional comments



  • src/modules/Workspaces/Tests/Workspaces.UITests.Next/TestAppFixture.cs keeps its process-name filtering, full-path identity comparison, exit handling, and window-readiness assertions. Only the path lookup changes.


  • src/modules/Workspaces/Tests/Workspaces.UITests.Next/NativeMethods.cs opens a limited-query process handle, reads the Win32 executable path, disposes the handle, and propagates unexpected failures.


  • src/modules/Workspaces/Tests/Workspaces.UITests.Next/ProcessImagePathTests.cs starts the existing test fixture suspended, queries its path before module initialization, and terminates only that owned process without resuming it or opening a window.

The existing exception filter only tolerates a process that has exited. It does not handle a live process whose module list is still initializing. This was observed in CI 388931 at TestAppFixture.ProcessIds() and reproduced independently.

No blanket exception suppression, fixed sleep, longer timeout, or weaker ownership assertion is introduced. This addresses process-image observation, not unrelated window-positioning failures.

Validation Steps Performed


  • Built the actual x64 Release UI-test project with the repository build script.

  • Ran the new non-UI regression against the old helper: failed with Win32 error 299 from process-module enumeration.

  • Ran the same regression with the fix: 1 passed, 0 failed, 0 skipped. The child stayed suspended and was cleaned up through its retained handles.

  • No new warnings remain in the image-query helper or regression.

  • A local Windows 10 VM is unavailable, as confirmed by the contributor. No local full-UI or VM-matrix pass is claimed.


  • CI 388945 fully succeeded. The same UI-test project, including the new startup regression, passed 34/34 on Windows 10, 34/34 on Windows 11, and 34/34 on ARM64, with no skipped cases.

3 total changed files
Loading changes...
Loading changes...
Loading changes...
You've reached the end of this PR review
Thus concludes todayโ€™s episode of โ€œJust One Small Changeโ€