[tests] Delete saved application state before executing test apps. Fixes #25922#25958
Conversation
Before and after launching a macOS/Mac Catalyst app in tests, delete its saved application state directory (`~/Library/Saved Application State/<bundle-id>.savedState`). This prevents the 'Do you want to try to reopen its windows again?' dialog from blocking automated test runs after a previous crash. Fixes #25922 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR hardens macOS/Mac Catalyst test execution by proactively deleting an app’s saved application state directory (~/Library/Saved Application State/<bundle-id>.savedState) before/after launching test apps, preventing the window-restoration relaunch dialog from blocking unattended runs (per #25922).
Changes:
- Add a
DeleteSavedStatehelper inTestBaseClass.Executeand invoke it before/after running the test executable. - Add a
delete-saved-statemake target and call it before/afterrun-barefor macOS/Mac Catalyst runs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/dotnet/UnitTests/TestBaseClass.cs | Deletes the launched app’s saved state (based on bundle id from Info.plist) around Execute() runs. |
| tests/common/shared-dotnet.mk | Adds a make target to delete saved state and wires it into run-bare for macOS/Mac Catalyst. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #087f81a] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #087f81a] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #087f81a] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #087f81a] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 199 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Before and after launching a macOS/Mac Catalyst app in tests, delete its saved
application state directory (
~/Library/Saved Application State/<bundle-id>.savedState).This prevents the "Do you want to try to reopen its windows again?" dialog
from blocking automated test runs after a previous crash.
Two implementations:
TestBaseClass.cs): TheExecutemethod callsDeleteSavedStatebefore and after running the app. It walks up the executable path to find the.appbundle, reads the bundle identifier fromInfo.plist, and deletes the saved state directory.shared-dotnet.mk): Adelete-saved-statetarget reads the bundle identifier viadefaults readand removes the saved state directory. Therun-baretarget invokes it before and after execution.Fixes #25922
🤖 Pull request created by Copilot