Skip to content

[tests] Use temporary directory in DocumentTest/FileCoordinatorTest and launch packaged macOS tests with spawner. Fixes #27138 - #27145

Merged
rolfbjarne merged 4 commits into
mainfrom
dev/rolf/fix-macos-test-tcc-hangs
Oct 30, 2026
Merged

rolfbjarne merged 4 commits into
mainfrom
dev/rolf/fix-macos-test-tcc-hangs

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

On the Sonoma (mac_14_x64) and Sequoia (mac_15_arm64) CI bots, DocumentTest.PerformAsynchronousFileAccess_Null hung for 600s in File.Delete ('/Users/builder/Documents/mydocument.txt'):

  • DocumentTest.GetFileName () (and FileCoordinatorTest.GetUrl ()) used Environment.SpecialFolder.MyDocuments, which resolves to ~/Documents on Mac Catalyst.
  • Packaged macOS test runs did not launch test apps via tools/spawner/spawner, so tccd attributed TCC checks to the Azure DevOps agent's node binary. After an agent update on the bots, the new node binary path lacked Full Disk Access and did not match the com.apple.macl xattr on the leftover ~/Documents/mydocument.txt file created before the update, causing sandboxd/tccd to block unlink() on a modal kTCCServiceSystemPolicyDocumentsFolder prompt.
  • Even with spawner, test apps do not have TCC grants for ~/Documents (which is why FileManagerTest, UrlTest, and AudioConverterTest were moved off NSSearchPathDirectory.DocumentDirectory in [tools] Add a tool to launch processes disclaming responsibility. #24249).

Switch DocumentTest and FileCoordinatorTest to use NSFileManager.TemporaryDirectory with per-process file names, and package and use tools/spawner/spawner when executing packaged macOS tests.

Fixes #27138

🤖 Pull request created by Copilot

…nd launch packaged macOS tests with spawner. Fixes #27138

On the Sonoma (mac_14_x64) and Sequoia (mac_15_arm64) CI bots, DocumentTest.PerformAsynchronousFileAccess_Null hung for 600s in File.Delete ('/Users/builder/Documents/mydocument.txt'):
- DocumentTest.GetFileName () (and FileCoordinatorTest.GetUrl ()) used Environment.SpecialFolder.MyDocuments, which resolves to ~/Documents on Mac Catalyst.
- Packaged macOS test runs did not launch test apps via tools/spawner/spawner, so tccd attributed TCC checks to the Azure DevOps agent's node binary. After an agent update on the bots, the new node binary path lacked Full Disk Access and did not match the com.apple.macl xattr on the leftover ~/Documents/mydocument.txt file created before the update, causing sandboxd/tccd to block unlink() on a modal kTCCServiceSystemPolicyDocumentsFolder prompt.
- Even with spawner, test apps do not have TCC grants for ~/Documents (which is why FileManagerTest, UrlTest, and AudioConverterTest were moved off NSSearchPathDirectory.DocumentDirectory in #24249).

Switch DocumentTest and FileCoordinatorTest to use NSFileManager.TemporaryDirectory with per-process file names, and package and use tools/spawner/spawner when executing packaged macOS tests.

Fixes #27138

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 13:48
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner October 29, 2026 13:48

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.

🔵 Needs a closer look

Validation of native macOS TCC attribution and packaged spawner behavior remains pending on the affected Sonoma x64 and Sequoia arm64 CI workers.

No open issues 🎉

What changed in this PR

Addresses the file-deletion hang reported in #27138 by moving test files out of Documents and extending the existing spawner launch approach to packaged macOS tests.

Changes:

  • Use temporary directories and per-process filenames in document and file-coordination tests.
  • Build, package, and use spawner when launching packaged macOS tests.
  • Preserve argument boundaries in the timeout runner with ProcessStartInfo.ArgumentList.
File Description
tests/​packaged-macos-tests.mk Launch timeout-wrapped tests through spawner.
tests/​package-mac-tests.sh Build and include spawner in the test package.
tests/​monotouch-test/​UIKit/​UIDocumentTest.cs Use a temporary, process-specific document path.
tests/​monotouch-test/​Foundation/​FileCoordinatorTest.cs Use a temporary, process-specific coordination path.
scripts/​run-with-timeout/​run-with-timeout.cs Preserve individual command arguments and update launch logging.
scripts/​run-packaged-macos-tests/​run-packaged-macos-tests.cs Validate the packaged spawner path and launch tests through it.

Review effort: Balanced

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

… in monotouch-test.

When monotouch-test is launched via 'spawner' on macOS and Mac Catalyst, the test app is evaluated on its own TCC identity rather than inheriting permissions from the parent process. Unlike iOS/tvOS simulators, the system TCC database cannot be pre-populated, so any test that triggers a TCC prompt (Contacts, Bluetooth, Microphone) can block or pop up modal dialogs:

- Default TestRuntime.IgnoreTestThatRequiresSystemPermissions () to true on macOS and Mac Catalyst (unless ENABLE_SYSTEM_PERMISSION_TESTS is set).
- Remove unnecessary TestRuntime.RequestContactsPermission () calls from ContactFetchRequestTest and ContactVCardSerializationTest (neither test accesses CNContactStore, and calling RequestAccess hung macOS/Mac Catalyst x64 on Sonoma in CI).
- Check Bluetooth permission in RegistrarTest.EventTestOSType before creating CBCentralManager.
- Ignore microphone-dependent tests on macOS in TestRuntime.RequestMicrophonePermission () (just like Mac Catalyst), add missing RequestMicrophonePermission () calls to AVAudioSinkNodeTest, AVAudioSourceNodeTest, AudioToolbox.AudioUnitTest.Callbacks, AVAudioIONodeTests, AudioUnitTests.GetCurrentDevice_Test, and AUGraphTests.DoTest, and use GenericOutput instead of VoiceProcessingIO in AUAudioUnitFactoryTest and AudioUnitTest.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:34

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.

🟡 Changes recommended

The launcher lacks an explicit macOS deployment target, risking startup failures on older bots, while permission changes break harness opt-in and unnecessarily require Bluetooth authorization for a synthetic test.

3 open issues

Review effort: Balanced

Comment thread tests/package-mac-tests.sh Resolved
Comment thread tests/common/TestRuntime.cs Resolved
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…and address review feedback.

- Call TestRuntime.CheckContactsPermission () in ContactFetchRequestTest and ContactVCardSerializationTest: CNContactVCardSerialization.GetDescriptorFromRequiredKeys () reads ~/Library/Preferences/com.apple.AddressBook.plist, which triggers sandboxd to request kTCCServiceAddressBook approval (preflight=no) on macOS 14 Sonoma and blocks when permission is NotDetermined.
- Set -mmacosx-version-min=$(DOTNET_MIN_MACOS_SDK_VERSION) in tools/spawner/Makefile so the packaged spawner binary targets the minimum supported macOS version.
- Pass ENABLE_SYSTEM_PERMISSION_TESTS=1 in MacExecuteTask when Harness.GetIncludeSystemPermissionTests returns true, and only override Harness.IncludeSystemPermissionTests in TestSelector when an explicit system-permission label is provided.
- Use TestRuntime.CheckBluetoothPermission () (assert_granted: false) in RegistrarTest.EventTestOSType.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 07:05

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.

🔵 Needs a closer look

Explicitly disabling system permission tests leaves an inherited ENABLE_SYSTEM_PERMISSION_TESTS=1 intact, so the opt-out is ignored and permission dialogs can still block macOS and Mac Catalyst test runs.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Remove inherited permission-test enable variable when disabled

tests/​xharness/​Jenkins/​TestTasks/​MacExecuteTask.cs:89

🤖 ⚠️ Testing — If xharness inherits ENABLE_SYSTEM_PERMISSION_TESTS=1, selecting skip-system-permission-tests or --include-system-permission-tests=false only adds DISABLE_SYSTEM_PERMISSION_TESTS=1 here. The updated macOS/Mac Catalyst permission helper checks only the enable variable, so the explicit opt-out is ignored and permission dialogs can still block the run. Remove the inherited enable variable in the disabled branch.

[!NOTE]
Generated by GitHub Copilot.

3 resolved since last review

Review effort: Balanced

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Oct 30, 2026
@rolfbjarne

Copy link
Copy Markdown
Member Author

@dalexsoto stamp

dalexsoto
dalexsoto previously approved these changes Oct 30, 2026

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stamping as requested by @rolfbjarne; no code review performed.

@rolfbjarne
rolfbjarne enabled auto-merge (squash) October 30, 2026 08:45
@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne added backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 backport-to-net10.0 Add this to issues or pull requests that should be backported to .NET 10 labels Oct 30, 2026
rolfbjarne added a commit that referenced this pull request Oct 30, 2026
Original PR #27145 was based on #24249, but release/10.0.1xx does not contain that prerequisite. Bring over the remaining functional pieces needed by this backport: avoid Documents-directory TCC prompts, launch direct and local desktop tests through spawner, and build spawner in the test pipeline.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the nullable permission override independent from the selected test labels so simulator introspection keeps its platform default, while run-all still enables permission tests explicitly. Also clear the conflicting inherited permission variable before launching packaged macOS tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:45
@rolfbjarne
rolfbjarne dismissed stale reviews from dalexsoto via 03722df October 30, 2026 11:45

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.

🔵 Needs a closer look

Native packaged validation on Sonoma x64 and Sequoia arm64 is still needed to confirm TCC attribution and absence of permission dialogs, with current CI checks pending.

No open issues 🎉

Review effort: Balanced

@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: 03722df4e10d4301af97e721d8a8370f4c43d19c [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

rolfbjarne added a commit that referenced this pull request Oct 30, 2026
Resolve the overlapping test isolation changes by keeping the newer release-branch implementations, which use unique per-test directories and updated backup-attribute validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
rolfbjarne added a commit that referenced this pull request Oct 30, 2026
…leCoordinatorTest and launch packaged macOS tests with spawner. Fixes #27138 (#27200)

On the Sonoma (`mac_14_x64`) and Sequoia (`mac_15_arm64`) CI bots, `DocumentTest.PerformAsynchronousFileAccess_Null` hung for 600s in `File.Delete ('/Users/builder/Documents/mydocument.txt')`:
- `DocumentTest.GetFileName ()` (and `FileCoordinatorTest.GetUrl ()`) used `Environment.SpecialFolder.MyDocuments`, which resolves to `~/Documents` on Mac Catalyst.
- Packaged macOS test runs did not launch test apps via `tools/spawner/spawner`, so `tccd` attributed TCC checks to the Azure DevOps agent's `node` binary. After an agent update on the bots, the new `node` binary path lacked Full Disk Access and did not match the `com.apple.macl` xattr on the leftover `~/Documents/mydocument.txt` file created before the update, causing `sandboxd`/`tccd` to block `unlink()` on a modal `kTCCServiceSystemPolicyDocumentsFolder` prompt.
- Even with `spawner`, test apps do not have TCC grants for `~/Documents` (which is why `FileManagerTest`, `UrlTest`, and `AudioConverterTest` were moved off `NSSearchPathDirectory.DocumentDirectory` in #24249).

Switch `DocumentTest` and `FileCoordinatorTest` to use `NSFileManager.TemporaryDirectory` with per-process file names, and package and use `tools/spawner/spawner` when executing packaged macOS tests.

Fixes #27138

🤖 Pull request created by Copilot

Backport of #27145.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
dalexsoto pushed a commit that referenced this pull request Oct 30, 2026
…leCoordinatorTest and launch packaged macOS tests with spawner. Fixes #27138 (#27201)

On the Sonoma (`mac_14_x64`) and Sequoia (`mac_15_arm64`) CI bots,
`DocumentTest.PerformAsynchronousFileAccess_Null` hung for 600s in
`File.Delete ('/Users/builder/Documents/mydocument.txt')`:
- `DocumentTest.GetFileName ()` (and `FileCoordinatorTest.GetUrl ()`)
used `Environment.SpecialFolder.MyDocuments`, which resolves to
`~/Documents` on Mac Catalyst.
- Packaged macOS test runs did not launch test apps via
`tools/spawner/spawner`, so `tccd` attributed TCC checks to the Azure
DevOps agent's `node` binary. After an agent update on the bots, the new
`node` binary path lacked Full Disk Access and did not match the
`com.apple.macl` xattr on the leftover `~/Documents/mydocument.txt` file
created before the update, causing `sandboxd`/`tccd` to block `unlink()`
on a modal `kTCCServiceSystemPolicyDocumentsFolder` prompt.
- Even with `spawner`, test apps do not have TCC grants for
`~/Documents` (which is why `FileManagerTest`, `UrlTest`, and
`AudioConverterTest` were moved off
`NSSearchPathDirectory.DocumentDirectory` in #24249).

Switch `DocumentTest` and `FileCoordinatorTest` to use
`NSFileManager.TemporaryDirectory` with per-process file names, and
package and use `tools/spawner/spawner` when executing packaged macOS
tests.

The release branch did not contain the `spawner` tool prerequisite, so
this backport also includes the tool and its normal build integration.
It preserves simulator permission-test defaults while disabling
TCC-prompting tests by default for unattended macOS and Mac Catalyst
runs.

Fixes #27138

Backport of #27145.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #03722df] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 217 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. [attempt 2] 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 1 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 21 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 21 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 20 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 Sonoma (14): All 5 tests passed. [attempt 3] 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
✅ Tests on macOS Golden Gate (27): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 03722df4e10d4301af97e721d8a8370f4c43d19c [PR build]

@rolfbjarne
rolfbjarne merged commit 410dc42 into main Oct 30, 2026
62 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/fix-macos-test-tcc-hangs branch October 30, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-net10.0 Add this to issues or pull requests that should be backported to .NET 10 backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI][MacCatalyst] DocumentTest.PerformAsynchronousFileAccess_Null hangs in File.Delete on x64

4 participants