Files
VirtualBuddy/Packages/MacDebugHost/Tests/MacDebugHostTests/DebugSymbolCacheTests.swift
Guilherme Rambo aabca5342d Xcode app provisioning (#823)
* Automatic provisioning of Mac apps launched via Xcode

* Improve Xcode integration sheet UI

* Security: harden local debugging socket and Xcode tool usage

* Soften rule around Xcode MCP use and xcodebuild prohibition

* Security: harden App Store Connect API key storage and access

* Fix debugged app incorrectly detected as not provisioned due to wildcard matching in provisioning profile

* Add previews for provisioning and debugging UI elements

* Disambiguate virtual machine vs. host Mac in provisioning and signing team management UIs

* Make Xcode debugging setup accessible from the Guest menu

* Completely disable debugging socket when developer features disabled, fix socket dying on accept failure

* Add versioning to scheme bindings, refer to VirtualBuddy components by a stable symlinked location, store scheme URLs so that app can potentially migrate schemes in the future

* Delay showing provisioning sheet so that an app that's already provisioned for the VM doesn't trigger it
2026-11-24 17:46:23 -03:00

37 lines
1.9 KiB
Swift

import Foundation
import Testing
@testable import MacDebugHost
struct DebugSymbolCacheTests {
@Test @MainActor func interruptedDeletionCanBeRetriedFromSettings() async throws {
let fm = FileManager.default
let root = fm.temporaryDirectory.appendingPathComponent(UUID().uuidString)
defer { try? fm.removeItem(at: root) }
let entry = DebugSymbolCache.Entry(id: "test-build", system: "Test macOS", bytes: 64)
let directory = root.appendingPathComponent(entry.id)
let retired = directory.appendingPathComponent(".deleting")
try fm.createDirectory(at: retired, withIntermediateDirectories: true)
try Data(count: 64).write(to: retired.appendingPathComponent("library"))
try JSONEncoder().encode(entry).write(to: directory.appendingPathComponent("complete.json"))
let cache = DebugSymbolCache(root: root, helperURL: root.appendingPathComponent("helper"))
let listed = try #require(cache.entries.first)
try await cache.remove(listed)
#expect(cache.entries.isEmpty)
#expect(!fm.fileExists(atPath: directory.path))
}
@Test func extractedSymbolsMustBePlainFilesAndDirectories() throws {
let fm = FileManager.default
let root = fm.temporaryDirectory.appendingPathComponent(UUID().uuidString)
defer { try? fm.removeItem(at: root) }
let lib = root.appendingPathComponent("usr/lib")
try fm.createDirectory(at: lib, withIntermediateDirectories: true)
try Data(count: 8).write(to: lib.appendingPathComponent("libSystem.B.dylib"))
#expect(throws: Never.self) { try DebugSymbolCache.requirePlainTree(root) }
try fm.createSymbolicLink(at: lib.appendingPathComponent("libexample.dylib"), withDestinationURL: URL(fileURLWithPath: "/usr/lib/dyld"))
#expect(throws: (any Error).self) { try DebugSymbolCache.requirePlainTree(root) }
}
}