Sync source edition with VCC Plus 3.7.0 build 63

This commit is contained in:
Brian Holman committed 2026-11-14 01:43:46 -07:00
1 parent c652a5276d
commit b2ecec4d87
86 files changed
+10519 -472

No files matched your search

+40 -1
View File
@@ -18,9 +18,40 @@ final class InterfaceValidation {
private let controller = VCCMachineController()
private var measurement: Task<Void, Never>?
private let suite: String
private let retainsRelaunchFixture: Bool
init() throws {
#if VCC_UI_TESTING
if let path = ProcessInfo.processInfo.environment["VCC_CONTINUITY_TEST_ROOT"] {
let candidate = URL(fileURLWithPath: path).standardizedFileURL
let temporary = FileManager.default.temporaryDirectory.standardizedFileURL.resolvingSymlinksInPath()
// XCTest's runner is sandboxed and owns a different temporary root
// from the tested app. Permit precisely that runner's tmp directory,
// never its Documents directory or an arbitrary supplied parent.
let userHome = URL(fileURLWithPath: NSHomeDirectoryForUser(NSUserName()) ?? NSHomeDirectory())
let runnerTemporary = userHome.appendingPathComponent("Library/Containers/com.brianholman.vccplus.mac.uitests.xctrunner/Data/tmp")
.standardizedFileURL.resolvingSymlinksInPath()
let prefix = "VCCContinuityRelaunch-"
let token = String(candidate.lastPathComponent.dropFirst(prefix.count))
let values = try candidate.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey])
guard candidate.lastPathComponent.hasPrefix(prefix), UUID(uuidString: token) != nil,
[temporary.path, runnerTemporary.path].contains(candidate.deletingLastPathComponent().resolvingSymlinksInPath().path),
values.isDirectory == true, values.isSymbolicLink != true,
try String(contentsOf: candidate.appendingPathComponent("fixture-owner"), encoding: .utf8) == token else {
throw CocoaError(.fileReadNoPermission)
}
directory = candidate
suite = prefix + token
retainsRelaunchFixture = true
} else {
directory = FileManager.default.temporaryDirectory.appendingPathComponent("vcc-interface-ui-" + UUID().uuidString)
suite = "VCCInterfaceUI-" + UUID().uuidString
retainsRelaunchFixture = false
}
#else
directory = FileManager.default.temporaryDirectory.appendingPathComponent("vcc-interface-ui-" + UUID().uuidString)
suite = "VCCInterfaceUI-" + UUID().uuidString
retainsRelaunchFixture = false
#endif
defaults = UserDefaults(suiteName: suite)!
// Ordinary interaction tests represent a returning user; the dedicated
// first-use test exercises a fresh guide history through real commands.
@@ -51,7 +82,12 @@ final class InterfaceValidation {
try Data(repeating: 0,count:161280).write(to:kit.appendingPathComponent(name))
}
if let resource = Bundle.main.url(forResource: "Blank OS9 Header", withExtension: "bin") {
try FileManager.default.copyItem(at: resource, to: kit.appendingPathComponent("Blank OS9 Header.bin"))
let destination = kit.appendingPathComponent("Blank OS9 Header.bin")
if retainsRelaunchFixture && FileManager.default.fileExists(atPath: destination.path) {
guard try Data(contentsOf: destination) == Data(contentsOf: resource) else { throw CocoaError(.fileReadCorruptFile) }
} else {
try FileManager.default.copyItem(at: resource, to: destination)
}
}
try Data([0x55,0x55,0x3c]).write(to:kit.appendingPathComponent("Hello World.cas"))
}
@@ -398,6 +434,9 @@ final class InterfaceValidation {
}
func cleanUp() {
measurement?.cancel()
// Only the UI runner that owns the explicit one-test fixture removes it.
// A second app process must be able to read the first process's state.
guard !retainsRelaunchFixture else { return }
defaults.removePersistentDomain(forName: suite)
try? FileManager.default.removeItem(at: directory)
}