Skip to content

Commit ccc70fb

Browse files
rolfbjarneCopilot
andcommitted
[tests] Avoid writing to the Documents directory in FileManagerTest.GetSkipBackupAttribute.
Across every one of the 12 monotouch-test macOS configurations in CI run 15213209 (PR #24249), the test suite hung 100% reproducibly right after NSFileManagerTest.GetHomeDirectoryTest, which is exactly where GetSkipBackupAttribute runs next (alphabetically). lldb backtraces of the hung process show the main thread stuck in a getxattr syscall, which is how macOS's sandbox/TCC subsystem checks extended attributes (e.g. com.apple.macl) when a process is granted or denied access to a protected user folder. GetSkipBackupAttribute writes a scratch file into the user's Documents directory (NSSearchPathDirectory.DocumentDirectory), which is one of the folders macOS protects behind a 'Files and Folders' TCC prompt. Now that tests are launched through the new spawner tool (which disclaims process responsibility so the test app is evaluated on its own TCC status instead of inheriting an already-approved ancestor's), the ephemeral test app has no existing grant for this folder, so the write triggers a fresh authorization prompt that hangs forever with no interactive session available to answer it, exactly matching the observed CI hangs. Use NSFileManager.TemporaryDirectory instead, which isn't behind a TCC prompt (and is already the established convention for scratch files elsewhere in this test suite, e.g. AudioConverterTest.cs and FSEventStreamTest.cs). The test only needs a writable file to exercise GetSkipBackupAttribute/SetSkipBackupAttribute, not specifically a file in the Documents directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e09f46f commit ccc70fb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/monotouch-test/Foundation/FileManagerTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ public void GetSkipBackupAttribute ()
8787
{
8888
Assert.That (NSFileManager.GetSkipBackupAttribute (NSBundle.MainBundle.ExecutableUrl.ToString ()), Is.False, "MainBundle");
8989

90-
var paths = NSSearchPath.GetDirectories (NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);
91-
var filename = Path.Combine (paths [0], $"DoNotBackupMe-NSFileManager-{Process.GetCurrentProcess ().Id}");
90+
// Use the temporary directory instead of the Documents directory: writing to the Documents
91+
// directory can trigger a TCC ("Files and Folders") permission prompt on macOS, which hangs
92+
// forever in CI (there's no user around to answer the prompt).
93+
var filename = Path.Combine (NSFileManager.TemporaryDirectory, $"DoNotBackupMe-NSFileManager-{Process.GetCurrentProcess ().Id}");
9294
try {
9395
File.WriteAllText (filename, "not worth a bit");
9496

0 commit comments

Comments
 (0)