Skip to content

[tests] Delete saved application state before executing test apps. Fixes #25922#25958

Merged
rolfbjarne merged 3 commits into
mainfrom
dev/rolf/issue-25922-macos-window-restoration
Jul 8, 2026
Merged

[tests] Delete saved application state before executing test apps. Fixes #25922#25958
rolfbjarne merged 3 commits into
mainfrom
dev/rolf/issue-25922-macos-window-restoration

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

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:

  • C# (TestBaseClass.cs): The Execute method calls DeleteSavedState before and after running the app. It walks up the executable path to find the .app bundle, reads the bundle identifier from Info.plist, and deletes the saved state directory.
  • Makefile (shared-dotnet.mk): A delete-saved-state target reads the bundle identifier via defaults read and removes the saved state directory. The run-bare target invokes it before and after execution.

Fixes #25922

🤖 Pull request created by Copilot

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>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review July 7, 2026 16:04
Copilot AI review requested due to automatic review settings July 7, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DeleteSavedState helper in TestBaseClass.Execute and invoke it before/after running the test executable.
  • Add a delete-saved-state make target and call it before/after run-bare for 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.

Comment thread tests/common/shared-dotnet.mk Outdated
Comment thread tests/common/shared-dotnet.mk Outdated
Comment thread tests/dotnet/UnitTests/TestBaseClass.cs
rolfbjarne and others added 2 commits July 7, 2026 18:14
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>
@rolfbjarne rolfbjarne enabled auto-merge (squash) July 7, 2026 16:14
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #087f81a] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 087f81a35a4f71acb83781e145dcac38a26b5908 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 087f81a35a4f71acb83781e145dcac38a26b5908 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #087f81a] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 087f81a35a4f71acb83781e145dcac38a26b5908 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #087f81a] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 087f81a35a4f71acb83781e145dcac38a26b5908 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: 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
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 087f81a35a4f71acb83781e145dcac38a26b5908 [PR build]

@rolfbjarne rolfbjarne merged commit f597a6f into main Jul 8, 2026
56 checks passed
@rolfbjarne rolfbjarne deleted the dev/rolf/issue-25922-macos-window-restoration branch July 8, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS window-restoration relaunch dialog blocks automated runs after a crashing test

4 participants