From 5ec958b6348572731374f20967153a18ad01aa60 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Mon, 2 Nov 2026 16:12:27 -0500 Subject: [PATCH 1/5] Require opt-in for hosted tests Signed-off-by: Vincent Taverna --- .../NoticeLocalizationRegressionTests.swift | 184 +++++++++--------- .../Input/InputPermissionIdleTests.swift | 4 +- .../Input/InputServiceTests.swift | 169 ++++++++-------- Tests/ParcelTestSupport/AppKitTestSuite.swift | 6 +- .../NativeHostAvailability.swift | 50 +++++ .../WorkspaceMemorySettingsTests.swift | 60 +++--- 6 files changed, 276 insertions(+), 197 deletions(-) create mode 100644 Tests/ParcelTestSupport/NativeHostAvailability.swift diff --git a/Tests/ParcelAppTests/NoticeLocalizationRegressionTests.swift b/Tests/ParcelAppTests/NoticeLocalizationRegressionTests.swift index 1fe86ab3..04a3c72d 100644 --- a/Tests/ParcelAppTests/NoticeLocalizationRegressionTests.swift +++ b/Tests/ParcelAppTests/NoticeLocalizationRegressionTests.swift @@ -6,6 +6,7 @@ import ParcelCore import ParcelEngine import ParcelIPC import ParcelPlatform +import ParcelTestSupport import ParcelUI import Testing @@ -137,100 +138,107 @@ struct NoticeLocalizationRegressionTests { == nil) } - @Test(.enabled(if: Self.captureEnabled(environment: ProcessInfo.processInfo.environment))) - func capturesLocalizedAppNotices() throws { - let environment = ProcessInfo.processInfo.environment - let language = try #require(environment["PARCEL_LOCALIZATION_LANGUAGE"]) - let path = try #require(environment["PARCEL_LOCALIZATION_SCREENSHOTS"]) - try #require(path.hasPrefix("/"), "Screenshot output must be an absolute private directory.") - try requireUnlockedConsole() - - let manager = FileManager.default - if !manager.fileExists(atPath: path) { - try manager.createDirectory( - at: URL(fileURLWithPath: path, isDirectory: true), withIntermediateDirectories: true, - attributes: [.posixPermissions: 0o700]) - } - let attributes = try manager.attributesOfItem(atPath: path) - let permissions = try #require(attributes[.posixPermissions] as? NSNumber) - try #require(permissions.intValue & 0o077 == 0, "Screenshot directory must not be accessible to others.") - - let notices = [ - ("startup", AppNotices.Kind.startup.message, "Parcel could not start tiling. Try again."), - ( - "permission", AppNotices.Kind.permission.message, - "Accessibility access was lost. Enable Parcel in System Settings." - ), - ( - "voiceover", AppNotices.Kind.voiceOver.message, - "VoiceOver is on. Parcel leaves Control Option shortcuts to VoiceOver. Use Option Command instead." - ), - ( - "input-timeout", AppNotices.Kind.tapStalls.message, - "Keyboard monitoring repeatedly timed out. Some shortcuts may have reached the active app. Restart Parcel if shortcuts remain unreliable." - ), - ] - let originalAppearance = NSApplication.shared.appearance - defer { NSApplication.shared.appearance = originalAppearance } - for (name, message, english) in notices { - #expect(message != english, "The \(language) notice lookup returned its English source: \(name)") - let controller = FeedbackController( - model: FeedbackModel(), announce: { _ in }, dismissDelay: .seconds(30), - onFailure: { Issue.record($0) }) - defer { controller.stop() } - controller.update( - state: ParcelCore.State(), configuration: MotionConfiguration(enabled: false, sound: false), - active: true) - controller.showTransientNotice(message) - let panel = try #require( - NSApplication.shared.windows.first { $0 is NSPanel && $0.isVisible && $0.title == message } as? NSPanel) - let content = try #require(panel.contentView) - try #require(content.bounds.height < 600, "Notice grew beyond a practical panel height: \(name)") - for (scheme, appearanceName) in [(NSAppearance.Name.aqua, "light"), (.darkAqua, "dark")] { - let appearance = try #require(NSAppearance(named: scheme)) - NSApplication.shared.appearance = appearance - panel.appearance = appearance - content.layoutSubtreeIfNeeded() - panel.displayIfNeeded() - let image = try #require(content.bitmapImageRepForCachingDisplay(in: content.bounds)) - content.cacheDisplay(in: content.bounds, to: image) - try #require(image.pixelsWide > 100 && image.pixelsHigh > 100) - let data = try #require(image.representation(using: .png, properties: [:])) - let destination = URL(fileURLWithPath: path, isDirectory: true) - .appendingPathComponent("notice-\(name)-\(appearanceName).png") - try #require( - !manager.fileExists(atPath: destination.path), "Refusing to overwrite an existing capture.") - try data.write(to: destination, options: .atomic) - try manager.setAttributes([.posixPermissions: 0o600], ofItemAtPath: destination.path) +} + +extension AppKitTestSuite { + @Suite @MainActor + struct NoticeLocalizationCaptureTests { + @Test(.enabled(if: Self.captureEnabled(environment: ProcessInfo.processInfo.environment))) + func capturesLocalizedAppNotices() throws { + let environment = ProcessInfo.processInfo.environment + let language = try #require(environment["PARCEL_LOCALIZATION_LANGUAGE"]) + let path = try #require(environment["PARCEL_LOCALIZATION_SCREENSHOTS"]) + try #require(path.hasPrefix("/"), "Screenshot output must be an absolute private directory.") + try requireUnlockedConsole() + + let manager = FileManager.default + if !manager.fileExists(atPath: path) { + try manager.createDirectory( + at: URL(fileURLWithPath: path, isDirectory: true), withIntermediateDirectories: true, + attributes: [.posixPermissions: 0o700]) + } + let attributes = try manager.attributesOfItem(atPath: path) + let permissions = try #require(attributes[.posixPermissions] as? NSNumber) + try #require(permissions.intValue & 0o077 == 0, "Screenshot directory must not be accessible to others.") + + let notices = [ + ("startup", AppNotices.Kind.startup.message, "Parcel could not start tiling. Try again."), + ( + "permission", AppNotices.Kind.permission.message, + "Accessibility access was lost. Enable Parcel in System Settings." + ), + ( + "voiceover", AppNotices.Kind.voiceOver.message, + "VoiceOver is on. Parcel leaves Control Option shortcuts to VoiceOver. Use Option Command instead." + ), + ( + "input-timeout", AppNotices.Kind.tapStalls.message, + "Keyboard monitoring repeatedly timed out. Some shortcuts may have reached the active app. Restart Parcel if shortcuts remain unreliable." + ), + ] + let originalAppearance = NSApplication.shared.appearance + defer { NSApplication.shared.appearance = originalAppearance } + for (name, message, english) in notices { + #expect(message != english, "The \(language) notice lookup returned its English source: \(name)") + let controller = FeedbackController( + model: FeedbackModel(), announce: { _ in }, dismissDelay: .seconds(30), + onFailure: { Issue.record($0) }) + defer { controller.stop() } + controller.update( + state: ParcelCore.State(), configuration: MotionConfiguration(enabled: false, sound: false), + active: true) + controller.showTransientNotice(message) + let panel = try #require( + NSApplication.shared.windows.first { $0 is NSPanel && $0.isVisible && $0.title == message } + as? NSPanel) + let content = try #require(panel.contentView) + try #require(content.bounds.height < 600, "Notice grew beyond a practical panel height: \(name)") + for (scheme, appearanceName) in [(NSAppearance.Name.aqua, "light"), (.darkAqua, "dark")] { + let appearance = try #require(NSAppearance(named: scheme)) + NSApplication.shared.appearance = appearance + panel.appearance = appearance + content.layoutSubtreeIfNeeded() + panel.displayIfNeeded() + let image = try #require(content.bitmapImageRepForCachingDisplay(in: content.bounds)) + content.cacheDisplay(in: content.bounds, to: image) + try #require(image.pixelsWide > 100 && image.pixelsHigh > 100) + let data = try #require(image.representation(using: .png, properties: [:])) + let destination = URL(fileURLWithPath: path, isDirectory: true) + .appendingPathComponent("notice-\(name)-\(appearanceName).png") + try #require( + !manager.fileExists(atPath: destination.path), "Refusing to overwrite an existing capture.") + try data.write(to: destination, options: .atomic) + try manager.setAttributes([.posixPermissions: 0o600], ofItemAtPath: destination.path) + } } } - } - nonisolated private static func captureEnabled(environment: [String: String]) -> Bool { - let supported = Set(["es", "fr", "de", "ja", "zh-Hans", "ko", "pt-BR"]) - guard let language = environment["PARCEL_LOCALIZATION_LANGUAGE"], supported.contains(language), - let path = environment["PARCEL_LOCALIZATION_SCREENSHOTS"], !path.isEmpty - else { return false } - return true - } + nonisolated private static func captureEnabled(environment: [String: String]) -> Bool { + let supported = Set(["es", "fr", "de", "ja", "zh-Hans", "ko", "pt-BR"]) + guard let language = environment["PARCEL_LOCALIZATION_LANGUAGE"], supported.contains(language), + let path = environment["PARCEL_LOCALIZATION_SCREENSHOTS"], !path.isEmpty + else { return false } + return true + } - private struct ConsoleState: Decodable { - let onConsole: Bool - let loginDone: Bool - let screenLocked: Bool? + private struct ConsoleState: Decodable { + let onConsole: Bool + let loginDone: Bool + let screenLocked: Bool? - private enum CodingKeys: String, CodingKey { - case onConsole = "kCGSSessionOnConsoleKey" - case loginDone = "kCGSessionLoginDoneKey" - case screenLocked = "CGSSessionScreenIsLocked" + private enum CodingKeys: String, CodingKey { + case onConsole = "kCGSSessionOnConsoleKey" + case loginDone = "kCGSessionLoginDoneKey" + case screenLocked = "CGSSessionScreenIsLocked" + } } - } - private func requireUnlockedConsole() throws { - try #require(FileManager.default.fileExists(atPath: "/tmp/parcel-m3-free")) - let session = try #require(CGSessionCopyCurrentDictionary()) - let data = try PropertyListSerialization.data(fromPropertyList: session, format: .binary, options: 0) - let state = try PropertyListDecoder().decode(ConsoleState.self, from: data) - try #require(state.onConsole && state.loginDone && state.screenLocked != true) + private func requireUnlockedConsole() throws { + try #require(FileManager.default.fileExists(atPath: "/tmp/parcel-m3-free")) + let session = try #require(CGSessionCopyCurrentDictionary()) + let data = try PropertyListSerialization.data(fromPropertyList: session, format: .binary, options: 0) + let state = try PropertyListDecoder().decode(ConsoleState.self, from: data) + try #require(state.onConsole && state.loginDone && state.screenLocked != true) + } } } diff --git a/Tests/ParcelPlatformTests/Input/InputPermissionIdleTests.swift b/Tests/ParcelPlatformTests/Input/InputPermissionIdleTests.swift index 310b4036..a6c2cdef 100644 --- a/Tests/ParcelPlatformTests/Input/InputPermissionIdleTests.swift +++ b/Tests/ParcelPlatformTests/Input/InputPermissionIdleTests.swift @@ -180,9 +180,9 @@ extension AppKitTestSuite { } @Test( - .enabled(if: InputPermissionTests.canRun, "Accessibility is not granted; set PARCEL_E2E=1 to require it.")) + .enabled(if: InputPermissionTests.canRun, "Native input skipped: Accessibility is not granted.")) func liveTapUsesCachedTrustAndNotificationInvalidatesPort() throws { - try #require(AXIsProcessTrusted(), "Accessibility is required when PARCEL_E2E=1") + try #require(AXIsProcessTrusted(), "Native input requires Accessibility.") let notifications = InputTrustNotifications() let observer = AccessibilityTrustObserver(source: notifications) let trust = InputTrustState() diff --git a/Tests/ParcelPlatformTests/Input/InputServiceTests.swift b/Tests/ParcelPlatformTests/Input/InputServiceTests.swift index b531b333..90e930c3 100644 --- a/Tests/ParcelPlatformTests/Input/InputServiceTests.swift +++ b/Tests/ParcelPlatformTests/Input/InputServiceTests.swift @@ -1,6 +1,7 @@ import ApplicationServices import Carbon import Foundation +import ParcelTestSupport import Testing @testable import ParcelPlatform @@ -362,97 +363,105 @@ struct InputConstructionTests { } } -@Suite(.serialized) -@MainActor -struct InputPermissionTests { - nonisolated static let canRun = AXIsProcessTrusted() || ProcessInfo.processInfo.environment["PARCEL_E2E"] == "1" +extension AppKitTestSuite { + @Suite(.serialized) + @MainActor + struct InputPermissionTests { + nonisolated static let canRun = AXIsProcessTrusted() - @Test(.enabled(if: canRun, "Accessibility is not granted; set PARCEL_E2E=1 to require it.")) - func liveTapLifecycle() throws { - try #require(AXIsProcessTrusted(), "Accessibility is required when PARCEL_E2E=1") - var failures: [InputError] = [] - var center: HotKeyCenter? = HotKeyCenter(onPress: { _ in }, onFailure: { failures.append($0) }) - let key = HotKey(keyCode: 99, modifiers: .hyper) - #expect(try center?.register(key).route == .eventTap) - try center?.stop() - try center?.register(key) - center = nil - let replacement = HotKeyCenter(onPress: { _ in }, onFailure: { failures.append($0) }) - try replacement.register(key) - try replacement.stop() - #expect(failures.isEmpty) - } + @Test(.enabled(if: canRun, "Native input skipped: Accessibility is not granted.")) + func liveTapLifecycle() throws { + try #require(AXIsProcessTrusted(), "Native input requires Accessibility.") + var failures: [InputError] = [] + var center: HotKeyCenter? = HotKeyCenter(onPress: { _ in }, onFailure: { failures.append($0) }) + let key = HotKey(keyCode: 99, modifiers: .hyper) + #expect(try center?.register(key).route == .eventTap) + try center?.stop() + try center?.register(key) + center = nil + let replacement = HotKeyCenter(onPress: { _ in }, onFailure: { failures.append($0) }) + try replacement.register(key) + try replacement.stop() + #expect(failures.isEmpty) + } - @Test(.enabled(if: canRun, "Accessibility is not granted; set PARCEL_E2E=1 to require it.")) - func liveMouseMonitorLifecycle() throws { - try #require(AXIsProcessTrusted(), "Accessibility is required when PARCEL_E2E=1") - var failures = 0 - let monitor = DragMonitor(onSample: { _, _ in }, onFailure: { _ in failures += 1 }) - try monitor.start() - try monitor.start() - #expect(monitor.isRunning) - monitor.stop() - #expect(!monitor.isRunning) - try monitor.start() - monitor.stop() - #expect(failures == 0) - } + @Test(.enabled(if: canRun, "Native input skipped: Accessibility is not granted.")) + func liveMouseMonitorLifecycle() throws { + try #require(AXIsProcessTrusted(), "Native input requires Accessibility.") + var failures = 0 + let monitor = DragMonitor(onSample: { _, _ in }, onFailure: { _ in failures += 1 }) + try monitor.start() + try monitor.start() + #expect(monitor.isRunning) + monitor.stop() + #expect(!monitor.isRunning) + try monitor.start() + monitor.stop() + #expect(failures == 0) + } - @Test func untrustedInputFailsWithoutPrompting() throws { - guard !AXIsProcessTrusted() else { return } - let center = HotKeyCenter(onPress: { _ in }, onFailure: { _ in }) - #expect(throws: InputError.accessibilityRequired) { - try center.register(HotKey(keyCode: 99, modifiers: .hyper)) + @Test(.enabled(if: !AXIsProcessTrusted(), "Denied-permission check requires an untrusted process.")) + func untrustedInputFailsWithoutPrompting() throws { + try #require(!AXIsProcessTrusted(), "Permission changed before the denied-permission check.") + let center = HotKeyCenter(onPress: { _ in }, onFailure: { _ in }) + #expect(throws: InputError.accessibilityRequired) { + try center.register(HotKey(keyCode: 99, modifiers: .hyper)) + } + let monitor = DragMonitor(onSample: { _, _ in }, onFailure: { _ in }) + #expect(throws: InputError.accessibilityRequired) { try monitor.start() } + #expect(throws: InputError.accessibilityRequired) { try HotKeyPoster.post(HotKey(keyCode: 0)) } } - let monitor = DragMonitor(onSample: { _, _ in }, onFailure: { _ in }) - #expect(throws: InputError.accessibilityRequired) { try monitor.start() } - #expect(throws: InputError.accessibilityRequired) { try HotKeyPoster.post(HotKey(keyCode: 0)) } - } - @Test(.enabled(if: canRun, "Accessibility is not granted; set PARCEL_E2E=1 to require it.")) - func liveTapRecoversBothDisableNotifications() throws { - try #require(AXIsProcessTrusted(), "Accessibility is required when PARCEL_E2E=1") - var types: [CGEventType] = [] - let tap = try InputEventTap( - mask: 1 << CGEventType.keyDown.rawValue, - handler: { type, _ in - types.append(type) - return false - }, - onFailure: { Issue.record("Unexpected tap failure: \($0)") }) - defer { tap.stop() } - let port = try #require(tap.port) - let event = try #require(CGEvent(source: nil)) - for type: CGEventType in [.tapDisabledByTimeout, .tapDisabledByUserInput] { - CGEvent.tapEnable(tap: port, enable: false) - #expect(tap.receive(type, event) == false) - #expect(CGEvent.tapIsEnabled(tap: port)) + @Test(.enabled(if: canRun, "Native input skipped: Accessibility is not granted.")) + func liveTapRecoversBothDisableNotifications() throws { + try #require(AXIsProcessTrusted(), "Native input requires Accessibility.") + var types: [CGEventType] = [] + let tap = try InputEventTap( + mask: 1 << CGEventType.keyDown.rawValue, + handler: { type, _ in + types.append(type) + return false + }, + onFailure: { Issue.record("Unexpected tap failure: \($0)") }) + defer { tap.stop() } + let port = try #require(tap.port) + let event = try #require(CGEvent(source: nil)) + for type: CGEventType in [.tapDisabledByTimeout, .tapDisabledByUserInput] { + CGEvent.tapEnable(tap: port, enable: false) + #expect(tap.receive(type, event) == false) + #expect(CGEvent.tapIsEnabled(tap: port)) + } + #expect(types == [.tapDisabledByTimeout, .tapDisabledByUserInput]) + tap.stop() + #expect(!CFMachPortIsValid(port)) + #expect(tap.receive(.keyDown, event) == false) } - #expect(types == [.tapDisabledByTimeout, .tapDisabledByUserInput]) - tap.stop() - #expect(!CFMachPortIsValid(port)) - #expect(tap.receive(.keyDown, event) == false) - } - @Test(.enabled(if: canRun, "Accessibility is not granted; set PARCEL_E2E=1 to require it.")) - func liveCarbonRegistrationAndRemoval() throws { - try #require(AXIsProcessTrusted(), "Accessibility is required when PARCEL_E2E=1") - let center = HotKeyCenter(onPress: { _ in }, onFailure: { Issue.record("Unexpected failure: \($0)") }) - let key = HotKey(keyCode: 113, modifiers: [.command, .control, .option]) - #expect(try center.register(key).route == .carbon) - try center.stop() - #expect(try center.register(key).route == .carbon) - try center.stop() + @Test(.enabled(if: canRun, "Native input skipped: Accessibility is not granted.")) + func liveCarbonRegistrationAndRemoval() throws { + try #require(AXIsProcessTrusted(), "Native input requires Accessibility.") + let center = HotKeyCenter(onPress: { _ in }, onFailure: { Issue.record("Unexpected failure: \($0)") }) + let key = HotKey(keyCode: 113, modifiers: [.command, .control, .option]) + #expect(try center.register(key).route == .carbon) + try center.stop() + #expect(try center.register(key).route == .carbon) + try center.stop() + } + + @Test(.enabled(if: !AXIsProcessTrusted(), "Denied-permission check requires an untrusted process.")) + func untrustedMenuReadFailsWithoutPrompting() async throws { + try #require(!AXIsProcessTrusted(), "Permission changed before the denied-permission check.") + await #expect(throws: InputError.accessibilityRequired) { + try await MenuShortcutReader.read(pid: ProcessInfo.processInfo.processIdentifier) + } + } } +} +@MainActor +struct InputPermissionValidationTests { @Test(arguments: [Int32(0), -1]) func invalidMenuPIDFails(pid: Int32) async { await #expect(throws: InputError.invalidProcess(pid)) { try await MenuShortcutReader.read(pid: pid) } } - @Test func untrustedMenuReadFailsWithoutPrompting() async { - guard !AXIsProcessTrusted() else { return } - await #expect(throws: InputError.accessibilityRequired) { - try await MenuShortcutReader.read(pid: ProcessInfo.processInfo.processIdentifier) - } - } } diff --git a/Tests/ParcelTestSupport/AppKitTestSuite.swift b/Tests/ParcelTestSupport/AppKitTestSuite.swift index 9fcadd6f..f593f50c 100644 --- a/Tests/ParcelTestSupport/AppKitTestSuite.swift +++ b/Tests/ParcelTestSupport/AppKitTestSuite.swift @@ -2,5 +2,9 @@ public import Testing // NSApp, brightness recovery, and main-thread notifications share process-global // resources. One ancestor serializes participating targets, including across awaits. -@Suite(.serialized, .tags(.appKit)) +@Suite( + .serialized, .tags(.appKit), + .enabled( + if: NativeHostAvailability.unavailableReason == nil, + Comment(rawValue: NativeHostAvailability.unavailableReason ?? "Native host is available."))) public struct AppKitTestSuite {} diff --git a/Tests/ParcelTestSupport/NativeHostAvailability.swift b/Tests/ParcelTestSupport/NativeHostAvailability.swift new file mode 100644 index 00000000..1809e802 --- /dev/null +++ b/Tests/ParcelTestSupport/NativeHostAvailability.swift @@ -0,0 +1,50 @@ +import CoreGraphics +import Darwin +import Foundation + +public enum NativeHostPolicy { + public static func isOptedIn(environment: [String: String]) -> Bool { + guard environment["PARCEL_E2E_PREFLIGHT_ONLY"] != "1" else { return false } + return ["PARCEL_NATIVE_HOST", "PARCEL_E2E", "PARCEL_BENCH", "PARCEL_BENCH_SMOKE"].contains { + environment[$0] == "1" + } + } + + public static func ownsLock(owner: String, ancestors: [Int32]) -> Bool { + let fields = owner.trimmingCharacters(in: .newlines).split(separator: " ") + guard fields.count == 2, let pid = Int32(fields[1]), pid > 1 else { return false } + return ancestors.contains(pid) + } +} + +public enum NativeHostAvailability { + public static let unavailableReason: String? = { + let environment = ProcessInfo.processInfo.environment + guard NativeHostPolicy.isOptedIn(environment: environment) else { + return + "Native-host tests require PARCEL_NATIVE_HOST=1 and Scripts/screen-lock.sh. No windows or input hooks were opened." + } + do { + let lock = environment["PARCEL_SCREEN_LOCK_PATH"] ?? "/tmp/parcel-screen.lock" + let owner = try String(contentsOfFile: "\(lock)/owner", encoding: .utf8) + var ancestors: [Int32] = [] + var pid = getppid() + while pid > 1, !ancestors.contains(pid) { + ancestors.append(pid) + var info = proc_bsdinfo() + let size = Int32(MemoryLayout.size) + guard proc_pidinfo(pid, PROC_PIDTBSDINFO, 0, &info, size) == size else { + return "Native-host tests could not verify the screen-lock process ancestry." + } + pid = Int32(info.pbi_ppid) + } + guard NativeHostPolicy.ownsLock(owner: owner, ancestors: ancestors) else { + return "Native-host tests must run under Scripts/screen-lock.sh; its owner is not an ancestor." + } + try E2EConsoleSession.requireUnlockedConsole() + return nil + } catch { + return "Native-host tests are blocked: \(error)." + } + }() +} diff --git a/Tests/ParcelUITests/WorkspaceMemorySettingsTests.swift b/Tests/ParcelUITests/WorkspaceMemorySettingsTests.swift index c2d887e8..1a78af3b 100644 --- a/Tests/ParcelUITests/WorkspaceMemorySettingsTests.swift +++ b/Tests/ParcelUITests/WorkspaceMemorySettingsTests.swift @@ -2,6 +2,7 @@ import AppKit import Foundation import ParcelConfig import ParcelCore +import ParcelTestSupport import SwiftUI import Testing @@ -113,32 +114,6 @@ struct WorkspaceMemorySettingsTests { #expect(model.recoveryURL == nil) } - @Test func failureAccessibilityIncludesTheActualError() async throws { - let model = WorkspaceMemorySettingsModel( - fileURL: URL(fileURLWithPath: "/tmp/workspace-state.json"), - inspect: { throw MemorySettingsFailure.unreadable }, reset: { nil }) - await model.refresh() - try await withMemoryAccessibilityHost(WorkspaceMemorySettings(model: model)) { elements in - let failure = try #require( - elements.first { $0.accessibilityIdentifier() == "settings.memory.failure" }) - #expect(failure.accessibilityLabel() == "Layout memory needs attention") - #expect(failure.accessibilityValue() as? String == model.failure) - } - } - - @Test func inspectionAccessibilityIncludesTheStoredTitleHashes() async throws { - let contents = "{\"titleDigest\":\"" + String(repeating: "a", count: 64) + "\"}" - let model = WorkspaceMemorySettingsModel( - fileURL: URL(fileURLWithPath: "/tmp/workspace-state.json"), inspect: { contents }, reset: { nil }) - await model.refresh() - try await withMemoryAccessibilityHost(WorkspaceMemorySettings(model: model).inspectionContents) { elements in - let data = try #require( - elements.first { $0.accessibilityIdentifier() == "settings.memory.contents" }) - #expect(data.accessibilityLabel() == "Stored layout data") - #expect(data.accessibilityValue() as? String == contents) - } - } - @Test func undoFailuresMapToAccessibleFeedback() { let state = State() let empty = FeedbackNotice.map(.noUndoHistory, state: state) @@ -151,6 +126,39 @@ struct WorkspaceMemorySettingsTests { } } +extension AppKitTestSuite { + @Suite @MainActor + struct WorkspaceMemoryAccessibilityTests { + @Test func failureAccessibilityIncludesTheActualError() async throws { + let model = WorkspaceMemorySettingsModel( + fileURL: URL(fileURLWithPath: "/tmp/workspace-state.json"), + inspect: { throw MemorySettingsFailure.unreadable }, reset: { nil }) + await model.refresh() + try await withMemoryAccessibilityHost(WorkspaceMemorySettings(model: model)) { elements in + let failure = try #require( + elements.first { $0.accessibilityIdentifier() == "settings.memory.failure" }) + #expect(failure.accessibilityLabel() == "Layout memory needs attention") + #expect(failure.accessibilityValue() as? String == model.failure) + } + } + + @Test func inspectionAccessibilityIncludesTheStoredTitleHashes() async throws { + let contents = "{\"titleDigest\":\"" + String(repeating: "a", count: 64) + "\"}" + let model = WorkspaceMemorySettingsModel( + fileURL: URL(fileURLWithPath: "/tmp/workspace-state.json"), inspect: { contents }, reset: { nil }) + await model.refresh() + try await withMemoryAccessibilityHost(WorkspaceMemorySettings(model: model).inspectionContents) { + elements in + let data = try #require( + elements.first { $0.accessibilityIdentifier() == "settings.memory.contents" }) + #expect(data.accessibilityLabel() == "Stored layout data") + #expect(data.accessibilityValue() as? String == contents) + } + } + + } +} + @MainActor private func withMemoryAccessibilityHost( _ view: Content, body: ([any NSAccessibilityProtocol]) throws -> Void ) async throws { -- knotmirror 0.0.1 From e5406571223da11947e3e471daa258cdf3bc79d3 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Mon, 2 Nov 2026 16:28:49 -0500 Subject: [PATCH 2/5] Enforce test lane manifests Signed-off-by: Vincent Taverna --- CONTRIBUTING.md | 28 +- Package.swift | 7 + Scripts/test-lane.sh | 47 +++ Scripts/test-native-host.sh | 9 + Scripts/test-unit.sh | 6 +- Scripts/tests/task-dispatch.sh | 10 +- Scripts/tests/test-runner.sh | 205 +++++++---- Tests/Lanes/native-host.txt | 76 ++++ Tests/Lanes/unit.txt | 336 ++++++++++++++++++ .../TestLaneTests.swift | 108 ++++++ Tests/TestLaneSupport/TestLaneSelection.swift | 55 +++ Tests/TestSelection/main.swift | 99 ++++++ 12 files changed, 899 insertions(+), 87 deletions(-) create mode 100755 Scripts/test-lane.sh create mode 100755 Scripts/test-native-host.sh create mode 100644 Tests/Lanes/native-host.txt create mode 100644 Tests/Lanes/unit.txt create mode 100644 Tests/ParcelTestSupportTests/TestLaneTests.swift create mode 100644 Tests/TestLaneSupport/TestLaneSelection.swift create mode 100644 Tests/TestSelection/main.swift diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d71f0052..6da40364 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,10 +72,30 @@ mise run test:scripts Scripts/check-doc-links.sh ``` -`mise run test` includes non-live app composition and excludes live scenarios, -performance budgets, and name-guard fixtures. Plain `swift test` discovers every -target and skips live scenarios unless opted in. Suites carry `.e2e`, `.benchmark`, -and `.appKit` tags for test plans; command-line lanes use target filters. +`mise run test` positively selects the screen-free suites in +[unit manifest](Tests/Lanes/unit.txt). It clears live opt-ins, checks discovered +suite IDs before running, and rejects empty runs or missing executed suites. +`PARCEL_TEST_SKIP_BUILD=1` reuses a prior `swift build --build-tests`; +`PARCEL_TEST_XUNIT_OUTPUT` changes the JUnit destination (default `build/junit.xml`). +A `--filter` narrows the manifest; it cannot enable another lane. + +Hosted AppKit and native input coverage stays in the +[native-host manifest](Tests/Lanes/native-host.txt). Run it deliberately: + +```sh +PARCEL_NATIVE_HOST=1 Scripts/test-native-host.sh +``` + +The wrapper takes `Scripts/screen-lock.sh`; tests also verify lock ancestry and +an unlocked console. Native input needs an existing Accessibility grant for the +test process, never a consent prompt. Missing permission is a visible skip, not +an early-return pass; skips do not certify that capability. Both manifests must +be kept current when adding suites: unclassified or overlapping suites fail the +inventory check. JUnit uses Swift Testing directly, not an empty XCTest report. +Plain `swift test` remains screen-free by +default: the shared AppKit ancestor and native input tests require explicit +opt-in and the mutex, even when the test process already has Accessibility. +Suites retain `.e2e`, `.benchmark`, and `.appKit` tags for test plans. `mise run bench` runs the complete performance suite in release, serially; record a baseline with `make bench-record` on a quiet machine first. diff --git a/Package.swift b/Package.swift index 0447d2e7..e5f232ac 100644 --- a/Package.swift +++ b/Package.swift @@ -107,6 +107,13 @@ let package = Package( .target( name: "ParcelTestSupport", dependencies: ["ParcelCore"], path: "Tests/ParcelTestSupport", swiftSettings: strict), + .target(name: "ParcelTestLaneSupport", path: "Tests/TestLaneSupport", swiftSettings: strict), + .executableTarget( + name: "ParcelTestSelection", dependencies: ["ParcelTestLaneSupport"], path: "Tests/TestSelection", + swiftSettings: strict), + .testTarget( + name: "ParcelTestSupportTests", dependencies: ["ParcelTestSupport", "ParcelTestLaneSupport"], + swiftSettings: strict), .testTarget( name: "NameGuardTests", dependencies: ["parcel-dev"], path: "Scripts/tests/NameGuardTests", swiftSettings: strict), diff --git a/Scripts/test-lane.sh b/Scripts/test-lane.sh new file mode 100755 index 00000000..880ded56 --- /dev/null +++ b/Scripts/test-lane.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -euo pipefail +cd "$(dirname "$0")/.." +lane=${1:?Choose unit or native-host.} +shift +case "$lane" in + unit) + unset PARCEL_NATIVE_HOST PARCEL_LOCALIZATION_LANGUAGE PARCEL_LOCALIZATION_SCREENSHOTS + parallel=--parallel; check='check-unit' ;; + native-host) + [[ ${PARCEL_NATIVE_HOST:-0} == 1 ]] || { printf 'Native-host tests require PARCEL_NATIVE_HOST=1.\n' >&2; exit 2; } + parallel=--no-parallel; check='check-native' ;; + *) printf 'Unknown test lane: %s\n' "$lane" >&2; exit 2 ;; +esac +unset PARCEL_E2E PARCEL_E2E_PREFLIGHT_ONLY PARCEL_BENCH PARCEL_BENCH_SMOKE PARCEL_REALITY +skip_build=${PARCEL_TEST_SKIP_BUILD:-0} +report=${PARCEL_TEST_XUNIT_OUTPUT:-build/junit.xml} +if [[ $lane == native-host ]]; then report=${PARCEL_TEST_XUNIT_OUTPUT:-build/junit-native-host.xml}; fi +filter= +while (( $# )); do + case "$1" in + --skip-build) skip_build=1; shift ;; + --parallel|--no-parallel) parallel=$1; shift ;; + --filter|--xunit-output) + [[ $# -ge 2 && -n $2 ]] || { printf 'Missing value for %s\n' "$1" >&2; exit 2; } + if [[ $1 == --filter ]]; then filter=$2; else report=$2; fi + shift 2 ;; + *) printf 'Unsupported lane argument: %s\n' "$1" >&2; exit 2 ;; + esac +done +if [[ $lane == native-host && $parallel != --no-parallel ]]; then + printf 'Native-host tests must run serially.\n' >&2 + exit 2 +fi +mkdir -p "$(dirname "$report")" +work=$(mktemp -d "${TMPDIR:-/tmp}/parcel-test-lane.XXXXXX") +trap 'rm -rf "$work"' EXIT +if [[ $skip_build != 1 ]]; then swift build --build-tests; fi +bin=$(swift build --show-bin-path) +swift test list --skip-build > "$work/discovered" +manifest="Tests/Lanes/$lane.txt" +selection=$("$bin/ParcelTestSelection" select "$manifest" "$work/discovered" "$filter" "$report") +status=0 +swift test --skip-build --disable-xctest "$parallel" --filter "$selection" --xunit-output "$work/results.xml" || status=$? +if [[ -f $work/results.xml ]]; then cp "$work/results.xml" "$report"; fi +(( status == 0 )) || exit "$status" +"$bin/ParcelTestSelection" "$check" "$manifest" "$work/discovered" "$filter" "$work/results.xml" diff --git a/Scripts/test-native-host.sh b/Scripts/test-native-host.sh new file mode 100755 index 00000000..ea2ad144 --- /dev/null +++ b/Scripts/test-native-host.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -euo pipefail +cd "$(dirname "$0")/.." +if [[ ${PARCEL_NATIVE_HOST:-0} != 1 ]]; then + printf 'Native-host tests require PARCEL_NATIVE_HOST=1. No windows or input hooks were opened.\n' >&2 + exit 2 +fi +export PARCEL_SCREEN_OWNER=native-host +exec Scripts/screen-lock.sh caffeinate -dimsu bash Scripts/test-lane.sh native-host "$@" diff --git a/Scripts/test-unit.sh b/Scripts/test-unit.sh index d2db32b1..d97f39c7 100755 --- a/Scripts/test-unit.sh +++ b/Scripts/test-unit.sh @@ -1,7 +1,3 @@ #!/bin/bash set -euo pipefail -cd "$(dirname "$0")/.." -mkdir -p build -unset PARCEL_E2E PARCEL_E2E_PREFLIGHT_ONLY PARCEL_BENCH -swift test --parallel --skip '^ParcelE2ETests\.|^ParcelPerformanceTests\.|^NameGuardTests\.|^ParcelDevTests\.|InputPermissionTests/live|InputPermissionIdleTests/live' \ - --xunit-output build/junit.xml "$@" +exec bash "$(dirname "$0")/test-lane.sh" unit "$@" diff --git a/Scripts/tests/task-dispatch.sh b/Scripts/tests/task-dispatch.sh index 0add764e..a76a2183 100755 --- a/Scripts/tests/task-dispatch.sh +++ b/Scripts/tests/task-dispatch.sh @@ -5,7 +5,12 @@ work=$(mktemp -d "${TMPDIR:-/tmp}/task-dispatch.XXXXXX") trap 'rm -rf "$work"' EXIT mkdir -p "$work/Scripts" "$work/bin" cp mise.toml "$work/" -cp Scripts/app-task.sh Scripts/test-unit.sh "$work/Scripts/" +cp Scripts/app-task.sh "$work/Scripts/" +cat > "$work/Scripts/test-unit.sh" <<'MOCK' +#!/bin/bash +set -euo pipefail +printf '%s\n' test "$@" >> "$TASK_LOG" +MOCK for command in bundle check-bundle lint; do # shellcheck disable=SC2016 printf '#!/bin/bash\nset -euo pipefail\nprintf "%%s\\n" "%s" "$@" >> "$TASK_LOG"\n' "$command" > "$work/Scripts/$command.sh" @@ -30,8 +35,7 @@ printf '%s\n' bundle debug open build/Parcel.app > "$work/expected" cmp "$work/expected" "$TASK_LOG" printf '' > "$TASK_LOG" mise run test -- --filter 'One suite' -grep -Fxq -- '--parallel' "$TASK_LOG" -grep -Fxq -- 'build/junit.xml' "$TASK_LOG" +grep -Fxq -- '--filter' "$TASK_LOG" grep -Fxq -- 'One suite' "$TASK_LOG" printf '' > "$TASK_LOG" mise run test:serial diff --git a/Scripts/tests/test-runner.sh b/Scripts/tests/test-runner.sh index c52449d2..01c8616d 100755 --- a/Scripts/tests/test-runner.sh +++ b/Scripts/tests/test-runner.sh @@ -1,99 +1,154 @@ #!/bin/bash set -euo pipefail - cd "$(dirname "$0")/../.." work=$(mktemp -d "${TMPDIR:-/tmp}/test-runner.XXXXXX") trap 'rm -rf "$work"' EXIT -mkdir -p "$work/Scripts/tests" "$work/bin" -cp Scripts/test.sh Scripts/test-unit.sh Scripts/test-scripts.sh "$work/Scripts/" +mkdir -p "$work/project/Scripts" "$work/project/Tests/Lanes" "$work/bin" +cp Scripts/test.sh Scripts/test-unit.sh Scripts/test-lane.sh Scripts/test-native-host.sh "$work/project/Scripts/" +cp Tests/Lanes/*.txt "$work/project/Tests/Lanes/" +bin=$(swift build --show-bin-path) +cp "$bin/ParcelTestSelection" "$work/bin/" +export TEST_BIN="$work/bin" TEST_EVENTS="$work/events" TEST_ENVIRONMENT="$work/environment" +export TEST_DISCOVERY="$work/discovered" TEST_REPORT="$work/report.xml" +python3 -I - "$work/project/Tests/Lanes/unit.txt" "$TEST_DISCOVERY" "$TEST_REPORT" <<'PY' +import sys +from pathlib import Path +from xml.etree.ElementTree import Element, SubElement, ElementTree +suites = [s for s in Path(sys.argv[1]).read_text().splitlines() if s and not s.startswith('#')] +native = [s for s in Path(sys.argv[1]).with_name('native-host.txt').read_text().splitlines() if s and not s.startswith('#')] +Path(sys.argv[2]).write_text('\n'.join(s + '/example()' for s in suites + native) + '\n') +root = Element('testsuites') +for suite in suites: + SubElement(root, 'testcase', classname=suite.replace('/', '.'), name='example()') +ElementTree(root).write(sys.argv[3]) +PY cat > "$work/bin/swift" <<'MOCK' #!/bin/bash set -euo pipefail -printf '%s\n' "$@" > "${TEST_ARGUMENTS:?}" -printf '%s|%s|%s\n' "${PARCEL_E2E:-unset}" "${PARCEL_E2E_PREFLIGHT_ONLY:-unset}" "${PARCEL_BENCH:-unset}" > "$TEST_ENVIRONMENT" +printf '%s\n' "$*" >> "$TEST_EVENTS" +if [[ $* == 'build --show-bin-path' ]]; then printf '%s\n' "$TEST_BIN"; exit; fi +if [[ $* == 'build --build-tests' ]]; then exit "${TEST_BUILD_STATUS:-0}"; fi +if [[ $* == 'test list --skip-build' ]]; then + printf '%s\n' "$(< "$TEST_DISCOVERY")" + exit "${TEST_LIST_STATUS:-0}" +fi +printf '%s|%s|%s|%s|%s\n' "${PARCEL_NATIVE_HOST:-unset}" "${PARCEL_E2E:-unset}" "${PARCEL_BENCH:-unset}" "${PARCEL_BENCH_SMOKE:-unset}" "${PARCEL_LOCALIZATION_SCREENSHOTS:-unset}" > "$TEST_ENVIRONMENT" previous= -for argument in "$@"; do - if [[ $previous == --skip ]]; then printf '%s\n' "$argument" > "$TEST_PATTERN"; fi - previous=$argument +for arg in "$@"; do + if [[ $previous == --xunit-output && ${TEST_NO_REPORT:-0} != 1 ]]; then cp "$TEST_REPORT" "$arg"; fi + previous=$arg done exit "${TEST_SWIFT_STATUS:-0}" MOCK chmod +x "$work/bin/swift" -for script in alpha beta 'new fixture'; do - cat > "$work/Scripts/tests/$script.sh" <<'MOCK' -#!/bin/bash -set -euo pipefail -printf '%s\n' "${0##*/}" >> "${TEST_SCRIPTS:?}" -exit "${TEST_SHELL_STATUS:-0}" -MOCK -done -export PATH="$work/bin:$PATH" TEST_ARGUMENTS="$work/actual" TEST_PATTERN="$work/pattern" -export TEST_ENVIRONMENT="$work/environment" TEST_SCRIPTS="$work/script-events.log" +export PATH="$work/bin:$PATH" count=0 -check() { - "$@" || { printf 'Test runner check failed: %s\n' "$*" >&2; exit 1; } - count=$((count + 1)) -} +check() { "$@" || { printf 'Test runner check failed: %s\n' "$*" >&2; exit 1; }; count=$((count + 1)); } fails_with() { local expected=$1 status=0 shift "$@" > "$work/failure.log" 2>&1 || status=$? [[ $status == "$expected" ]] } -check_arguments() { - printf '%s\n' test --parallel --skip '^ParcelE2ETests\.|^ParcelPerformanceTests\.|^NameGuardTests\.|^ParcelDevTests\.|InputPermissionTests/live|InputPermissionIdleTests/live' --xunit-output build/junit.xml "$@" > "$work/expected" - env PARCEL_E2E=1 PARCEL_E2E_PREFLIGHT_ONLY=1 PARCEL_BENCH=1 bash "$work/Scripts/test.sh" "$@" - cmp "$work/expected" "$work/actual" -} -check check_arguments -check check_arguments --no-parallel -check check_arguments --filter 'One suite' -IFS= read -r pattern < "$TEST_PATTERN" -matching() { [[ $1 =~ $pattern ]]; } -not_matching() { [[ ! $1 =~ $pattern ]]; } -for identifier in \ - 'ParcelE2ETests.RealAppEndToEndTests/windowMoves()' \ - 'ParcelPerformanceTests.PerformanceBudgetTests/layoutAndDiffBudget()' \ - 'ParcelPerformanceTests.PerformanceTestSuite/FocusMotionBenchmarks/observedWritesVersusSharedPlan()' \ - 'ParcelPerformanceTests.PerformanceTestSuite/MenuRenderingBenchmarks/renderingBenchmarks()' \ - 'ParcelPerformanceTests.PerformanceTestSuite/OverlayRenderingBenchmarks/renderingBenchmarks()' \ - 'ParcelPerformanceTests.PerformanceTestSuite/PrivacyRenderingBenchmarks/privacyBackdropEightCutouts()' \ - 'ParcelPerformanceTests.EngineCorePerformanceTests/EngineCoreBenchmarks/workload(_:)' \ - 'ParcelPerformanceTests.AXWriteBenchmarks/fastPathOptimized()' \ - 'ParcelPerformanceTests.WriteMotionBenchmarks/coalescerProMotionJitter()' \ - 'ParcelPerformanceTests.WriteSchedulingBenchmarks/motionBatchMainActorOverhead()' \ - 'NameGuardTests.NameGuardTests/policyRejectsNames()' \ - 'ParcelDevTests.DevSupportTests/unknownCommandsFail()' \ - 'ParcelPlatformTests.InputPermissionTests/liveTapLifecycle()' \ - 'ParcelPlatformTests.InputPermissionTests/liveMouseMonitorLifecycle()' \ - 'ParcelPlatformTests.InputPermissionTests/liveTapRecoversBothDisableNotifications()' \ - 'ParcelPlatformTests.InputPermissionTests/liveCarbonRegistrationAndRemoval()' \ - 'ParcelTestSupport.AppKitTestSuite/InputPermissionIdleTests/liveTapUsesCachedTrustAndNotificationInvalidatesPort()'; do - check matching "$identifier" -done -for identifier in \ - 'ParcelAppTests.AppDiagnosticsTests/notices()' \ - 'ParcelTestSupport.AppKitTestSuite/ParcelAppTests/CompositionTests/composes()' \ - 'ParcelTestSupport.AppKitTestSuite/InputPermissionIdleTests/idleAndCachedEventChecksDoNotQueryTrust()'; do - check not_matching "$identifier" -done -check test ! -e "$TEST_SCRIPTS" -printf 'unset|unset|unset\n' > "$work/expected" +runner="$work/project/Scripts/test.sh" +check env PARCEL_NATIVE_HOST=1 PARCEL_E2E=1 PARCEL_BENCH=1 PARCEL_BENCH_SMOKE=1 PARCEL_LOCALIZATION_SCREENSHOTS=/private/captures bash "$runner" +printf 'unset|unset|unset|unset|unset\n' > "$work/expected" check cmp "$work/expected" "$TEST_ENVIRONMENT" -check fails_with 7 env TEST_SWIFT_STATUS=7 bash "$work/Scripts/test.sh" - -check bash "$work/Scripts/test-scripts.sh" -printf '%s\n' test --quiet --filter '^NameGuardTests\.|^ParcelDevTests\.' --xunit-output build/junit-scripts.xml > "$work/expected" -check cmp "$work/expected" "$work/actual" -printf '%s\n' alpha.sh beta.sh 'new fixture.sh' > "$work/expected" -check cmp "$work/expected" "$TEST_SCRIPTS" -rm "$TEST_SCRIPTS" -check fails_with 9 env TEST_SWIFT_STATUS=9 bash "$work/Scripts/test-scripts.sh" -check test ! -e "$TEST_SCRIPTS" -check fails_with 23 env TEST_SHELL_STATUS=23 bash "$work/Scripts/test-scripts.sh" -printf 'alpha.sh\n' > "$work/expected" -check cmp "$work/expected" "$TEST_SCRIPTS" - +check test -f "$work/project/build/junit.xml" +check grep -q '^build --build-tests$' "$TEST_EVENTS" +check grep -q '^test list --skip-build$' "$TEST_EVENTS" +check grep -q '^test --skip-build --disable-xctest --parallel --filter \^' "$TEST_EVENTS" +: > "$TEST_EVENTS" +check env PARCEL_TEST_SKIP_BUILD=1 PARCEL_TEST_XUNIT_OUTPUT="$work/custom.xml" bash "$runner" --no-parallel +check test -f "$work/custom.xml" +check test "$(grep -c '^build --build-tests$' "$TEST_EVENTS" || true)" == 0 +check grep -q '^test --skip-build --disable-xctest --no-parallel --filter ' "$TEST_EVENTS" +check bash "$runner" --skip-build --xunit-output "$work/argument.xml" +check test -f "$work/argument.xml" +check fails_with 2 bash "$runner" --package-path /other +check fails_with 2 bash "$runner" --filter +check fails_with 2 bash "$runner" --skip unsafe +check fails_with 1 bash "$runner" --filter 'NoSuchTest' +check fails_with 1 bash "$runner" --filter 'AppKitTestSuite|ParcelE2ETests|ParcelPerformanceTests' +check fails_with 17 env TEST_BUILD_STATUS=17 bash "$runner" +check fails_with 19 env TEST_LIST_STATUS=19 bash "$runner" --skip-build +check fails_with 7 env TEST_SWIFT_STATUS=7 bash "$runner" --skip-build --xunit-output "$work/failed.xml" +check test -f "$work/failed.xml" +check fails_with 1 env TEST_NO_REPORT=1 bash "$runner" --skip-build +cp "$TEST_DISCOVERY" "$work/saved-discovery" +: > "$TEST_DISCOVERY" +check fails_with 1 bash "$runner" --skip-build +cp "$work/saved-discovery" "$TEST_DISCOVERY" +python3 -I - "$TEST_DISCOVERY" <<'PY' +import sys +from pathlib import Path +p = Path(sys.argv[1]); p.write_text('\n'.join(p.read_text().splitlines()[1:]) + '\n') +PY +check fails_with 1 bash "$runner" --skip-build +cp "$work/saved-discovery" "$TEST_DISCOVERY" +cp "$TEST_REPORT" "$work/saved-report" +printf '\n' > "$TEST_REPORT" +check fails_with 1 bash "$runner" --skip-build +python3 -I - "$work/saved-report" "$TEST_REPORT" <<'PY' +import sys +from xml.etree.ElementTree import parse, SubElement +report = parse(sys.argv[1]) +report.getroot().remove(report.getroot()[0]) +report.write(sys.argv[2]) +PY +check fails_with 1 bash "$runner" --skip-build +python3 -I - "$work/saved-report" "$TEST_REPORT" <<'PY' +import sys +from xml.etree.ElementTree import parse, SubElement +report = parse(sys.argv[1]) +SubElement(report.getroot()[0], 'skipped') +report.write(sys.argv[2]) +PY +check fails_with 1 bash "$runner" --skip-build +cp "$work/saved-report" "$TEST_REPORT" +printf 'UnexpectedTests.NewSuite/escape()\n' >> "$TEST_DISCOVERY" +check fails_with 1 bash "$runner" --skip-build +cp "$work/saved-discovery" "$TEST_DISCOVERY" +python3 -I - "$work/saved-report" "$TEST_REPORT" <<'PY' +import sys +from xml.etree.ElementTree import parse, SubElement +report = parse(sys.argv[1]) +SubElement(report.getroot(), 'testcase', classname='UnexpectedTests.NewSuite', name='escape()') +report.write(sys.argv[2]) +PY +check fails_with 1 bash "$runner" --skip-build +printf '\n' > "$TEST_REPORT" +check fails_with 1 bash "$runner" --skip-build +for mode in all-skipped permission-skipped; do + python3 -I - "$work/project/Tests/Lanes/native-host.txt" "$TEST_REPORT" "$mode" <<'PY' +import sys +from pathlib import Path +from xml.etree.ElementTree import Element, SubElement, ElementTree +suites = [s for s in Path(sys.argv[1]).read_text().splitlines() if s and not s.startswith('#')] +root = Element('testsuites') +for suite in suites: + case = SubElement(root, 'testcase', classname=suite.replace('/', '.'), name='example()') + if sys.argv[3] == 'all-skipped' or suite.endswith('/InputPermissionTests'): + SubElement(case, 'skipped', message='Accessibility is not granted') +ElementTree(root).write(sys.argv[2]) +PY + if [[ $mode == all-skipped ]]; then + check fails_with 1 "$TEST_BIN/ParcelTestSelection" check-native "$work/project/Tests/Lanes/native-host.txt" "$TEST_DISCOVERY" '' "$TEST_REPORT" + else + check "$TEST_BIN/ParcelTestSelection" check-native "$work/project/Tests/Lanes/native-host.txt" "$TEST_DISCOVERY" '' "$TEST_REPORT" + fi +done +check fails_with 2 env PARCEL_NATIVE_HOST=0 bash "$work/project/Scripts/test-native-host.sh" +cat > "$work/project/Scripts/screen-lock.sh" <<'MOCK' +#!/bin/bash +set -euo pipefail +printf '%s\n' "${PARCEL_SCREEN_OWNER:-}" > "$TEST_LOCK_OWNER" +exit 29 +MOCK +chmod +x "$work/project/Scripts/screen-lock.sh" +check fails_with 29 env PARCEL_NATIVE_HOST=1 TEST_LOCK_OWNER="$work/owner" bash "$work/project/Scripts/test-native-host.sh" +printf 'native-host\n' > "$work/expected" +check cmp "$work/expected" "$work/owner" for target in test test-serial test-scripts; do make --no-print-directory --dry-run "$target" > "$work/actual" case "$target" in diff --git a/Tests/Lanes/native-host.txt b/Tests/Lanes/native-host.txt new file mode 100644 index 00000000..e0b967ed --- /dev/null +++ b/Tests/Lanes/native-host.txt @@ -0,0 +1,76 @@ +# Suite IDs from swift test list; every entry is required. +ParcelTestSupport.AppKitTestSuite/ActivityAccessibilityTests +ParcelTestSupport.AppKitTestSuite/ActivitySettingsTests +ParcelTestSupport.AppKitTestSuite/AppIconPickerTests +ParcelTestSupport.AppKitTestSuite/AppearancePreviewTests +ParcelTestSupport.AppKitTestSuite/CommandMenuParityTests +ParcelTestSupport.AppKitTestSuite/CommandReviewMenuTests +ParcelTestSupport.AppKitTestSuite/DisplayIdleSchedulingTests +ParcelTestSupport.AppKitTestSuite/DisplayNotificationTests +ParcelTestSupport.AppKitTestSuite/DisplayReconfigurationTests +ParcelTestSupport.AppKitTestSuite/EngineNativeDisplayConversionTests +ParcelTestSupport.AppKitTestSuite/FeedbackControllerTests +ParcelTestSupport.AppKitTestSuite/FloatingInspectorMenuTests +ParcelTestSupport.AppKitTestSuite/FocusModeMenuTests +ParcelTestSupport.AppKitTestSuite/FocusModeRenderingTests +ParcelTestSupport.AppKitTestSuite/FocusMotionTests +ParcelTestSupport.AppKitTestSuite/GeneralSearchCoverageTests +ParcelTestSupport.AppKitTestSuite/HighlightPreferencesRenderingTests +ParcelTestSupport.AppKitTestSuite/HighlightTests +ParcelTestSupport.AppKitTestSuite/HoverBarPanelTests +ParcelTestSupport.AppKitTestSuite/HoverBarPresentationTests +ParcelTestSupport.AppKitTestSuite/InputPermissionIdleTests +ParcelTestSupport.AppKitTestSuite/InputPermissionTests +ParcelTestSupport.AppKitTestSuite/MenuBarControllerTests +ParcelTestSupport.AppKitTestSuite/MenuIconRenderingTests +ParcelTestSupport.AppKitTestSuite/MenuTests +ParcelTestSupport.AppKitTestSuite/MenuWorkspaceTests +ParcelTestSupport.AppKitTestSuite/MouseOverlayMergeTests +ParcelTestSupport.AppKitTestSuite/NativeMouseDisplayTests +ParcelTestSupport.AppKitTestSuite/NativeSecureInputTests +ParcelTestSupport.AppKitTestSuite/OverlayDimmingTests +ParcelTestSupport.AppKitTestSuite/OverlaySnapshotTests +ParcelTestSupport.AppKitTestSuite/OverlayTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AdaptiveFeedbackPresentationTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AppBrightnessTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AppFeedbackControllerTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AppHoverPreferencesTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AppKitRuntimeRegressionTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AppMouseControlTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AppRecoveryTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/AppRuleControlsTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/EngineShellMenuTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/FeedbackDropTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/FixtureChipInputTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/LayoutFeedbackCompositionTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/LearningRuntimeTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/NoticeLocalizationCaptureTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/NoticeMenuTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/PermissionIdleRegressionTests +ParcelTestSupport.AppKitTestSuite/ParcelAppTests/RuntimeMenuAppTests +ParcelTestSupport.AppKitTestSuite/PrivacyOverlayTests +ParcelTestSupport.AppKitTestSuite/PseudoLocalizationScreenshotTests +ParcelTestSupport.AppKitTestSuite/RuleConfirmationControllerTests +ParcelTestSupport.AppKitTestSuite/SecureInputActivityTests +ParcelTestSupport.AppKitTestSuite/SettingsAccessibilityTests +ParcelTestSupport.AppKitTestSuite/SettingsControllerTests +ParcelTestSupport.AppKitTestSuite/SettingsSearchKeyboardTests +ParcelTestSupport.AppKitTestSuite/SettingsSearchPaneCoverageTests +ParcelTestSupport.AppKitTestSuite/SetupAccessibilityTests +ParcelTestSupport.AppKitTestSuite/SetupMenuTests +ParcelTestSupport.AppKitTestSuite/ShellRegressionTests +ParcelTestSupport.AppKitTestSuite/StackChipViewTests +ParcelTestSupport.AppKitTestSuite/StackControlsViewTests +ParcelTestSupport.AppKitTestSuite/SupportMenuTests +ParcelTestSupport.AppKitTestSuite/SystemWindowPreferencesTests +ParcelTestSupport.AppKitTestSuite/TabViewKeyboardFocusTests +ParcelTestSupport.AppKitTestSuite/TabViewPanelTests +ParcelTestSupport.AppKitTestSuite/TourSetupRenderingTests +ParcelTestSupport.AppKitTestSuite/UpdateAvailabilityMenuTests +ParcelTestSupport.AppKitTestSuite/UpdateControllerMenuTests +ParcelTestSupport.AppKitTestSuite/UpdateMenuIntegrationTests +ParcelTestSupport.AppKitTestSuite/WindowControlsTests +ParcelTestSupport.AppKitTestSuite/WindowLearningControllerTests +ParcelTestSupport.AppKitTestSuite/WindowRuleMenuTests +ParcelTestSupport.AppKitTestSuite/WorkspaceMemoryAccessibilityTests +ParcelTestSupport.AppKitTestSuite/WorkspaceObserverIdleTests diff --git a/Tests/Lanes/unit.txt b/Tests/Lanes/unit.txt new file mode 100644 index 00000000..878bbb47 --- /dev/null +++ b/Tests/Lanes/unit.txt @@ -0,0 +1,336 @@ +# Suite IDs from swift test list; every entry is required. +ParcelAnimationTests.AnimatorTests +ParcelAnimationTests.AppWriteMetricsDistributionTests +ParcelAnimationTests.AppWriteMetricsTests +ParcelAnimationTests.DisplayLinkDriverTests +ParcelAnimationTests.DisplayLinkIdleRegressionTests +ParcelAnimationTests.DriverIntegrationTests +ParcelAnimationTests.FrameCoalescerTests +ParcelAnimationTests.FramePlannerTests +ParcelAnimationTests.MotionPolicyTests +ParcelAnimationTests.MotionRegressionTests +ParcelAnimationTests.MotionTokenTests +ParcelAnimationTests.OrderedMotionTests +ParcelAnimationTests.SpringTests +ParcelAppTests.AdaptiveE2EInvariantTests +ParcelAppTests.AppActivityTests +ParcelAppTests.AppCallbackTests +ParcelAppTests.AppCommandReviewPresentationTests +ParcelAppTests.AppDeliveryTests +ParcelAppTests.AppDiagnosticsTests +ParcelAppTests.AppFeedbackTests +ParcelAppTests.AppFixtureMouseTests +ParcelAppTests.AppFixtureTimestampTests +ParcelAppTests.AppFloatingInspectorTests +ParcelAppTests.AppLanguageLaunchTests +ParcelAppTests.AppRestorationTests +ParcelAppTests.AppRuntimeRegressionTests +ParcelAppTests.AppSetupApplicationsTests +ParcelAppTests.AppSetupIPCTests +ParcelAppTests.AppSetupShortcutsTests +ParcelAppTests.AppShortcutCaptureTests +ParcelAppTests.AppSmokeTests +ParcelAppTests.AppStandardStreamsTests +ParcelAppTests.AppTabViewFocusTests +ParcelAppTests.AppTabViewLayoutTests +ParcelAppTests.AppWorkspaceMemoryTests +ParcelAppTests.CompositionBoundaryTests +ParcelAppTests.CompositionTests +ParcelAppTests.ConfigStartupTests +ParcelAppTests.CoreCommandFixtureInputTests +ParcelAppTests.E2EApplicationLaunchTests +ParcelAppTests.E2EConsoleSessionTests +ParcelAppTests.E2EHarnessRegressionTests +ParcelAppTests.E2EHarnessTests +ParcelAppTests.EngineShellAdapterTests +ParcelAppTests.FixtureAppTests +ParcelAppTests.FixtureBundleTests +ParcelAppTests.FixtureFrameRecorderTests +ParcelAppTests.FocusModesAppTests +ParcelAppTests.HighlightNoticeTests +ParcelAppTests.HotkeyRecoveryTests +ParcelAppTests.InspectorCommandParserTests +ParcelAppTests.MediaCaptureScriptTests +ParcelAppTests.MenuAppTests +ParcelAppTests.NoticeLocalizationRegressionTests +ParcelAppTests.PerformanceMeasurementTests +ParcelAppTests.PermissionRecoveryTests +ParcelAppTests.ProcessExitWaiterTests +ParcelAppTests.RealAppVerificationGateTests +ParcelAppTests.RemoteRunnerTests +ParcelAppTests.RuleFailureNoticeTests +ParcelAppTests.SmoothnessMetricsTests +ParcelAppTests.TestEventsTests +ParcelAppTests.TourLifecycleTests +ParcelAppTests.TourLoginTests +ParcelAppTests.TourTidyTransactionTests +ParcelConfigTests.ActivityConfigurationTests +ParcelConfigTests.AppearanceConfigurationTests +ParcelConfigTests.BindingModeTests +ParcelConfigTests.CallbackConfigurationTests +ParcelConfigTests.ClassificationRulesAcceptanceTests +ParcelConfigTests.ConfigCommandReviewRegressionTests +ParcelConfigTests.ConfigDefaultFileTests +ParcelConfigTests.ConfigJSONSchemaTests +ParcelConfigTests.ConfigResourceTests +ParcelConfigTests.ConfigStoreTests +ParcelConfigTests.ConfigValidationTests +ParcelConfigTests.DashedConfigurationKeysTests +ParcelConfigTests.DefaultKeybindingsTests +ParcelConfigTests.DocumentationExamplesTests +ParcelConfigTests.FocusModeConfigurationTests +ParcelConfigTests.HighlightConfigurationTests +ParcelConfigTests.HoverBarConfigurationTests +ParcelConfigTests.KeyChordTests +ParcelConfigTests.LocalizationSourceTests +ParcelConfigTests.MemoryConfigurationTests +ParcelConfigTests.MouseConfigurationTests +ParcelConfigTests.MouseControlConfigurationTests +ParcelConfigTests.MouseModifiersTests +ParcelConfigTests.RulesTests +ParcelConfigTests.TOMLDocumentTests +ParcelConfigTests.TOMLParserTests +ParcelConfigTests.TranslationRegressionTests +ParcelCoreTests.AdaptiveCommandIntegrationTests +ParcelCoreTests.AdaptiveLayoutRecoveryTests +ParcelCoreTests.AdaptiveLayoutTests +ParcelCoreTests.AdaptiveUndoHistoryTests +ParcelCoreTests.AdaptiveWorkspaceMemoryTests +ParcelCoreTests.ClassifierDefaultsAcceptanceTests +ParcelCoreTests.CommandParityTests +ParcelCoreTests.CommandReviewRegressionTests +ParcelCoreTests.FocusModeTests +ParcelCoreTests.LayoutTraversalEquivalenceTests +ParcelCoreTests.MinimizedPlacementTests +ParcelCoreTests.MinimumSizeLearningTests +ParcelCoreTests.NativeTabTests +ParcelCoreTests.RetileOrderRegressionTests +ParcelCoreTests.RoomFeedbackTests +ParcelCoreTests.SetupCatalogTests +ParcelCoreTests.SetupOpeningTests +ParcelCoreTests.TabViewCardGeometryTests +ParcelCoreTests.TabViewTests +ParcelCoreTests.TileEdgeTests +ParcelCoreTests.TileWindowCommandTests +ParcelCoreTests.TraversalRegressionTests +ParcelCoreTests.TreeTransformsTests +ParcelCoreTests.UndoHistoryTests +ParcelCoreTests.WindowControlTests +ParcelCoreTests.WindowGestureTests +ParcelCoreTests.WorkspaceCommandTests +ParcelCoreTests.WorkspaceMemoryTests +ParcelEngineTests.ActivityBaselineRegressionTests +ParcelEngineTests.ActivityCollectorTests +ParcelEngineTests.ActivityPlacementTests +ParcelEngineTests.AdaptiveReloadIntegrationTests +ParcelEngineTests.AutomaticTilingTests +ParcelEngineTests.CategorizedTraceTests +ParcelEngineTests.ConfigurationMergeRegressionTests +ParcelEngineTests.DragAndFeedbackTests +ParcelEngineTests.EngineAdaptiveLayoutRecoveryTests +ParcelEngineTests.EngineCallbackTests +ParcelEngineTests.EngineCommandReviewRegressionTests +ParcelEngineTests.EngineDiagnosticsCapabilityTests +ParcelEngineTests.EngineDiagnosticsTests +ParcelEngineTests.EngineRoomFeedbackTests +ParcelEngineTests.FocusModeEngineTests +ParcelEngineTests.GlideContinuityTests +ParcelEngineTests.HotPathTracingRegressionTests +ParcelEngineTests.HoverFocusModelTests +ParcelEngineTests.IdleSchedulingRegressionTests +ParcelEngineTests.MinimumIPCTests +ParcelEngineTests.MinimumPersistenceTests +ParcelEngineTests.MinimumResetTests +ParcelEngineTests.MonotonicTimeTests +ParcelEngineTests.MouseClaimDecisionTests +ParcelEngineTests.MouseGesturePipelineTests +ParcelEngineTests.MouseInputSnapshotTests +ParcelEngineTests.MouseIntegrationTests +ParcelEngineTests.MouseModelTests +ParcelEngineTests.MouseReviewRegressionTests +ParcelEngineTests.MouseSafetyRegressionTests +ParcelEngineTests.NativeClassificationTests +ParcelEngineTests.NativeCloseTests +ParcelEngineTests.NativeFailureTests +ParcelEngineTests.NativeFocusFreshnessTests +ParcelEngineTests.NativeFullscreenTransitionTests +ParcelEngineTests.NativeLateEventTests +ParcelEngineTests.NativeMenuShortcutTests +ParcelEngineTests.NativeMinimizedWindowTests +ParcelEngineTests.NativePrivacyObservationTests +ParcelEngineTests.NativeRoutingTests +ParcelEngineTests.NativeSpaceGateTests +ParcelEngineTests.NativeSpaceLayoutRetentionTests +ParcelEngineTests.NativeVisibilityTests +ParcelEngineTests.ParcelEngineAdaptiveConfigurationTests +ParcelEngineTests.ParcelEngineCommandTests +ParcelEngineTests.ParcelEngineConfigurationSourceTests +ParcelEngineTests.ParcelEngineConfigurationTests +ParcelEngineTests.ParcelEngineDisplayTests +ParcelEngineTests.ParcelEngineEchoTests +ParcelEngineTests.ParcelEngineIPCTests +ParcelEngineTests.ParcelEngineLifecycleTests +ParcelEngineTests.ParcelEngineMetricsTests +ParcelEngineTests.ParcelEngineMotionTests +ParcelEngineTests.ParcelEngineParserTests +ParcelEngineTests.ParcelEngineReplayTests +ParcelEngineTests.ParcelEngineTests +ParcelEngineTests.PausedCommandTests +ParcelEngineTests.PositionReadbackTests +ParcelEngineTests.RealityCommandTests +ParcelEngineTests.ReconciledFocusEchoTests +ParcelEngineTests.RecordingAndTracingTests +ParcelEngineTests.ReportDeliveryTests +ParcelEngineTests.RuleActionTests +ParcelEngineTests.RuleLayoutAcceptanceTests +ParcelEngineTests.RuleSpaceAssignmentRegressionTests +ParcelEngineTests.RuleSpaceMoveStoreTests +ParcelEngineTests.RulesEngineTests +ParcelEngineTests.SetupCoordinatorTests +ParcelEngineTests.SnapMotionTests +ParcelEngineTests.SpaceCommandRoutingTests +ParcelEngineTests.SuspendedCommandTests +ParcelEngineTests.TypedFailureAndIdleTests +ParcelEngineTests.WindowControlEngineTests +ParcelEngineTests.WorkspaceCommandEngineTests +ParcelEngineTests.WorkspaceMemoryReviewTests +ParcelEngineTests.WorkspaceStoreTests +ParcelEngineTests.WorkspaceTransactionTests +ParcelEngineTests.WritePipelineTests +ParcelIPCTests.CLIEngineReachabilityTests +ParcelIPCTests.CLIExecutionTests +ParcelIPCTests.CLIOutputTests +ParcelIPCTests.CLIParsingTests +ParcelIPCTests.ClientTests +ParcelIPCTests.ConfigCheckCommandTests +ParcelIPCTests.DiagnosticsTests +ParcelIPCTests.FramingTests +ParcelIPCTests.IPCResourceTests +ParcelIPCTests.MemoryCLITests +ParcelIPCTests.MinimumsCLIParsingTests +ParcelIPCTests.PathTests +ParcelIPCTests.ProtocolTests +ParcelIPCTests.ResponseDeliveryTests +ParcelIPCTests.SchemaCommandTests +ParcelIPCTests.ServerLifecycleTests +ParcelIPCTests.ServerTests +ParcelIPCTests.SetupCLIParsingTests +ParcelIPCTests.SetupCLISocketTests +ParcelIPCTests.SetupIPCContractTests +ParcelIPCTests.SpacesCLITests +ParcelIPCTests.WhyServerTests +ParcelPlatformTests.AXAttributeBatchTests +ParcelPlatformTests.AXWatchdogIdleSchedulingTests +ParcelPlatformTests.AccessibilityTrustObserverTests +ParcelPlatformTests.ActivityTests +ParcelPlatformTests.AppThreadFocusFastPathTests +ParcelPlatformTests.AppThreadMotionMailboxTests +ParcelPlatformTests.AppThreadOperationValidityTests +ParcelPlatformTests.AppThreadRetainedWindowTests +ParcelPlatformTests.AppThreadSpeculativeTargetTests +ParcelPlatformTests.AppThreadStartupRegistrationTests +ParcelPlatformTests.DirectionalHotKeyTests +ParcelPlatformTests.HotKeyCenterTests +ParcelPlatformTests.InputConstructionTests +ParcelPlatformTests.InputPermissionValidationTests +ParcelPlatformTests.InputRegressionTests +ParcelPlatformTests.InputValueTests +ParcelPlatformTests.MenuShortcutTests +ParcelPlatformTests.MinimumSizeStoreTests +ParcelPlatformTests.MouseInputSafetyTests +ParcelPlatformTests.MouseSampleTests +ParcelPlatformTests.NativeSpaceReaderTests +ParcelPlatformTests.NativeTabFactsTests +ParcelPlatformTests.PostWriteEchoTests +ParcelPlatformTests.SecureInputGateTests +ParcelPlatformTests.SecureInputTests +ParcelPlatformTests.SetupStoreTests +ParcelPlatformTests.SpaceControllerTests +ParcelPlatformTests.SymbolicHotKeyTests +ParcelPlatformTests.TabViewInputIntegrationTests +ParcelPlatformTests.TabViewInputTests +ParcelPlatformTests.TabViewPresentationTests +ParcelPlatformTests.VoiceOverStatusTests +ParcelPlatformTests.WindowFactsReaderTests +ParcelPlatformTests.WindowFrameReadbackTests +ParcelPlatformTests.WorkspaceStateStoreTests +ParcelRealitySupportTests.BrowserOwnershipTests +ParcelRealitySupportTests.DriverFrameWritesTests +ParcelRealitySupportTests.DriverInputBarrierTests +ParcelRealitySupportTests.DriverInputSafetyTests +ParcelRealitySupportTests.DriverKeyLedgerTests +ParcelRealitySupportTests.DriverModifierTests +ParcelRealitySupportTests.DriverMouseEventTests +ParcelRealitySupportTests.DriverNativeKeyboardFlagsTests +ParcelRealitySupportTests.DriverPickupIdentityTests +ParcelRealitySupportTests.DriverReadbackTests +ParcelRealitySupportTests.DriverSocketTests +ParcelRealitySupportTests.DriverTaggedEventsTests +ParcelRealitySupportTests.DriverVoiceOverDeliveryTests +ParcelRealitySupportTests.DriverWindowSelectionTests +ParcelRealitySupportTests.FrameOracleTests +ParcelRealitySupportTests.InputAuditTests +ParcelRealitySupportTests.LayoutSizeOracleTests +ParcelRealitySupportTests.OwnedAppArtifactTests +ParcelRealitySupportTests.OwnedAppTeardownTests +ParcelRealitySupportTests.PermissionAndShapeTests +ParcelRealitySupportTests.PreferenceSnapshotTests +ParcelRealitySupportTests.ProcessLifecycleTests +ParcelRealitySupportTests.ProtectionTests +ParcelRealitySupportTests.RealityConfigurationTests +ParcelRealitySupportTests.RealityDragGeometryTests +ParcelRealitySupportTests.RealityDriverTests +ParcelRealitySupportTests.RealityFixtureTests +ParcelRealitySupportTests.RealityOracleTests +ParcelRealitySupportTests.RealityRecoveryTests +ParcelRealitySupportTests.RealityShortcutSafetyTests +ParcelRealitySupportTests.RetileOrderOracleTests +ParcelRealitySupportTests.SetupRealityTests +ParcelRealitySupportTests.TabViewConsoleSessionTests +ParcelRealitySupportTests.TabViewLatencyTests +ParcelRealitySupportTests.VoiceOverPreferenceTests +ParcelTestSupportTests.TestLaneTests +ParcelUITests.ActivitySuggestionTests +ParcelUITests.AppIconPreferencesTests +ParcelUITests.CommandReviewPresentationTests +ParcelUITests.ConfigLayoutSettingsTests +ParcelUITests.FeedbackTests +ParcelUITests.FloatingWindowInspectorTests +ParcelUITests.FocusModeSettingsTests +ParcelUITests.FocusMotionKeyframeTests +ParcelUITests.GuidedTourTests +ParcelUITests.HighlightGeometryTests +ParcelUITests.HighlightSettingsTests +ParcelUITests.HoverBarTests +ParcelUITests.LanguagePreferencesTests +ParcelUITests.LearningLocalizationTests +ParcelUITests.MenuModelTests +ParcelUITests.MenuWorkspaceModelTests +ParcelUITests.MiniMapTests +ParcelUITests.MouseControlSettingsTests +ParcelUITests.OnboardingTests +ParcelUITests.OverlayModelTests +ParcelUITests.RuleConfirmationTimingTests +ParcelUITests.SettingsMinimumsTests +ParcelUITests.SettingsSearchModelTests +ParcelUITests.SettingsSearchTests +ParcelUITests.SettingsShortcutConflictTests +ParcelUITests.SettingsTests +ParcelUITests.SetupActionTests +ParcelUITests.SetupEditorTests +ParcelUITests.SetupLoadingTests +ParcelUITests.ShellModelRegressionTests +ParcelUITests.ShortcutDisplayTests +ParcelUITests.StackChipTests +ParcelUITests.StackControlsTests +ParcelUITests.SupportTests +ParcelUITests.TourDemoTests +ParcelUITests.TourSetupTests +ParcelUITests.WhatsNewAccessibilityTests +ParcelUITests.WindowControlsPreferencesTests +ParcelUITests.WindowLearningPreferencesTests +ParcelUITests.WindowRuleEditingTests +ParcelUITests.WorkspaceMemorySettingsTests +ParcelUpdateTests.UpdateAvailabilityTests +ParcelUpdateTests.UpdateConfigurationTests +ParcelUpdateTests.UpdateControllerTests diff --git a/Tests/ParcelTestSupportTests/TestLaneTests.swift b/Tests/ParcelTestSupportTests/TestLaneTests.swift new file mode 100644 index 00000000..5263f259 --- /dev/null +++ b/Tests/ParcelTestSupportTests/TestLaneTests.swift @@ -0,0 +1,108 @@ +import Foundation +import ParcelTestLaneSupport +import ParcelTestSupport +import Testing + +struct TestLaneTests { + @Test(arguments: ["PARCEL_NATIVE_HOST", "PARCEL_E2E", "PARCEL_BENCH", "PARCEL_BENCH_SMOKE"]) + func explicitOptInIsRequired(key: String) { + #expect(!NativeHostPolicy.isOptedIn(environment: [:])) + #expect(!NativeHostPolicy.isOptedIn(environment: [key: "0"])) + #expect(!NativeHostPolicy.isOptedIn(environment: [key: "true"])) + #expect(NativeHostPolicy.isOptedIn(environment: [key: "1"])) + #expect(!NativeHostPolicy.isOptedIn(environment: [key: "1", "PARCEL_E2E_PREFLIGHT_ONLY": "1"])) + #expect(!NativeHostPolicy.isOptedIn(environment: ["AX_TRUSTED": "1"])) + } + + @Test(arguments: ["native-host 42", "native-host 42\n"]) + func lockRequiresAnAncestor(owner: String) { + #expect(NativeHostPolicy.ownsLock(owner: owner, ancestors: [100, 42, 2])) + #expect(!NativeHostPolicy.ownsLock(owner: owner, ancestors: [100, 2])) + #expect(!NativeHostPolicy.ownsLock(owner: owner, ancestors: [])) + } + + @Test(arguments: ["", "42", "host nope", "host 0", "host -1", "host 1", "host 42 extra", "host 42\nother 99"]) + func malformedLockCannotEnableNativeTests(owner: String) { + #expect(!NativeHostPolicy.ownsLock(owner: owner, ancestors: [42])) + } + + private let discovery = """ + SafeTests.Geometry/fits() + SafeTests.Geometry/count(_:) + SafeTests.Parser/reads() + ParcelTestSupport.AppKitTestSuite/Windows/orders() + """ + + @Test func manifestPositivelySelectsOnlyRequiredSuites() throws { + let selection = try TestLaneSelection(manifest: "SafeTests.Geometry\nSafeTests.Parser", discovered: discovery) + #expect(selection.identifiers.count == 3) + #expect(selection.suites == ["SafeTests.Geometry", "SafeTests.Parser"]) + let expression = try NSRegularExpression(pattern: selection.filter) + for id in discovery.split(separator: "\n").map(String.init) { + let matched = expression.firstMatch(in: id, range: NSRange(id.startIndex..., in: id)) != nil + #expect(matched == selection.identifiers.contains(id)) + } + } + + @Test(arguments: [ + "", "# no suites", "SafeTests.Missing", "SafeTests.Geometry\nSafeTests.Missing", + "SafeTests.Geometry\nSafeTests.Geometry", + ]) + func emptyDuplicateOrMissingSuitesFail(manifest: String) { + #expect(throws: TestLaneSelection.SelectionFailure.self) { + try TestLaneSelection(manifest: manifest, discovered: discovery) + } + } + + @Test func emptyDiscoveryFails() { + #expect(throws: TestLaneSelection.SelectionFailure.self) { + try TestLaneSelection(manifest: "SafeTests.Geometry", discovered: "") + } + } + + @Test(arguments: ["no such test", "Windows/orders", "^SafeTests.GeometryExtra"]) + func focusedFilterCannotBroadenOrSelectZero(pattern: String) { + #expect(throws: TestLaneSelection.SelectionFailure.self) { + try TestLaneSelection(manifest: "SafeTests.Geometry", discovered: discovery, matching: pattern) + } + } + + @Test func focusedSelectionStillRequiresTheCompleteManifest() { + #expect(throws: TestLaneSelection.SelectionFailure.self) { + try TestLaneSelection( + manifest: "SafeTests.Geometry\nSafeTests.Missing", discovered: discovery, matching: "fits") + } + } + + @Test func focusedFilterNarrowsTheWhitelist() throws { + let selection = try TestLaneSelection( + manifest: "SafeTests.Geometry\nSafeTests.Parser", discovered: discovery, matching: "fits|Windows") + #expect(selection.identifiers == ["SafeTests.Geometry/fits()"]) + #expect(selection.suites == ["SafeTests.Geometry"]) + let expression = try NSRegularExpression(pattern: selection.filter) + for id in discovery.split(separator: "\n").map(String.init) { + let matched = expression.firstMatch(in: id, range: NSRange(id.startIndex..., in: id)) != nil + #expect(matched == selection.identifiers.contains(id)) + } + } + + @Test func everyDiscoveredTestNeedsExactlyOneLane() throws { + let unit = try TestLaneSelection(manifest: "SafeTests.Geometry\nSafeTests.Parser", discovered: discovery) + let native = try TestLaneSelection(manifest: "ParcelTestSupport.AppKitTestSuite/Windows", discovered: discovery) + try TestLaneSelection.validatePartition([unit, native], discovered: discovery, excluding: []) + #expect(throws: TestLaneSelection.SelectionFailure.self) { + try TestLaneSelection.validatePartition([unit], discovered: discovery, excluding: []) + } + #expect(throws: TestLaneSelection.SelectionFailure.self) { + try TestLaneSelection.validatePartition([unit, native, unit], discovered: discovery, excluding: []) + } + try TestLaneSelection.validatePartition( + [unit], discovered: discovery, excluding: ["ParcelTestSupport.AppKitTestSuite/"]) + } + + @Test func invalidFilterFailsRatherThanFallingBack() { + #expect(throws: (any Error).self) { + try TestLaneSelection(manifest: "SafeTests.Geometry", discovered: discovery, matching: "[") + } + } +} diff --git a/Tests/TestLaneSupport/TestLaneSelection.swift b/Tests/TestLaneSupport/TestLaneSelection.swift new file mode 100644 index 00000000..f09f62bb --- /dev/null +++ b/Tests/TestLaneSupport/TestLaneSelection.swift @@ -0,0 +1,55 @@ +import Foundation + +public struct TestLaneSelection: Sendable { + public let suites: [String] + public let identifiers: [String] + public let filter: String + + public init(manifest: String, discovered: String, matching pattern: String? = nil) throws { + let suites = manifest.split(whereSeparator: \.isNewline).map(String.init) + .filter { !$0.hasPrefix("#") && !$0.isEmpty } + guard !suites.isEmpty, Set(suites).count == suites.count else { + throw SelectionFailure("Lane manifest is empty or contains duplicate suites.") + } + let identifiers = discovered.split(whereSeparator: \.isNewline).map(String.init) + .filter { $0.contains("/") && $0.hasSuffix(")") } + for suite in suites { + guard identifiers.contains(where: { $0.hasPrefix(suite + "/") }) else { + throw SelectionFailure("Required suite is missing: \(suite)") + } + } + let expression = try pattern.map { try NSRegularExpression(pattern: $0) } + let selected = identifiers.filter { identifier in + suites.contains { identifier.hasPrefix($0 + "/") } + && (expression.map { + $0.firstMatch(in: identifier, range: NSRange(identifier.startIndex..., in: identifier)) != nil + } ?? true) + } + guard !selected.isEmpty else { throw SelectionFailure("No tests selected for this lane.") } + self.suites = suites.filter { suite in selected.contains { $0.hasPrefix(suite + "/") } } + self.identifiers = selected + let allowed = self.suites.map { NSRegularExpression.escapedPattern(for: $0 + "/") }.joined(separator: "|") + filter = "^" + (pattern.map { "(?=.*(?:\($0)))" } ?? "") + "(?:\(allowed))" + } + + public static func validatePartition( + _ lanes: [Self], discovered: String, excluding prefixes: [String] + ) throws { + let identifiers = discovered.split(whereSeparator: \.isNewline).map(String.init) + .filter { $0.contains("/") && $0.hasSuffix(")") } + var owners: [String: Int] = [:] + for lane in lanes { + for identifier in lane.identifiers { owners[identifier, default: 0] += 1 } + } + for identifier in identifiers where !prefixes.contains(where: { identifier.hasPrefix($0) }) { + guard owners[identifier] == 1 else { + throw SelectionFailure("Test must belong to exactly one lane: \(identifier)") + } + } + } + + public struct SelectionFailure: Error, CustomStringConvertible { + public let description: String + public init(_ description: String) { self.description = description } + } +} diff --git a/Tests/TestSelection/main.swift b/Tests/TestSelection/main.swift new file mode 100644 index 00000000..86f4342f --- /dev/null +++ b/Tests/TestSelection/main.swift @@ -0,0 +1,99 @@ +import Darwin +import Foundation +import ParcelTestLaneSupport + +private final class Results: NSObject, XMLParserDelegate { + var root: String? + var currentSuite: String? + var skipped = false + var failed = false + var reported: Set = [] + var executed: Set = [] + var count = 0 + + func parser( + _ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, + qualifiedName qName: String?, attributes: [String: String] + ) { + if root == nil { root = elementName } + switch elementName { + case "testcase": + currentSuite = attributes["classname"] + skipped = false + case "skipped": skipped = true + case "failure", "error": failed = true + default: break + } + } + + func parser( + _ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String? + ) { + guard elementName == "testcase", let suite = currentSuite else { return } + reported.insert(suite) + if !skipped { + executed.insert(suite) + count += 1 + } + currentSuite = nil + } +} + +private func run() throws { + let args = Array(CommandLine.arguments.dropFirst()) + guard args.count == 5, ["select", "check-unit", "check-native"].contains(args[0]) else { + throw TestLaneSelection.SelectionFailure( + "Usage: ParcelTestSelection select|check-unit|check-native manifest discovered filter report") + } + let discovered = try String(contentsOfFile: args[2], encoding: .utf8) + let directory = URL(fileURLWithPath: args[1]).deletingLastPathComponent() + let lanes = try ["unit", "native-host"].map { lane in + try TestLaneSelection( + manifest: String(contentsOf: directory.appendingPathComponent("\(lane).txt"), encoding: .utf8), + discovered: discovered) + } + try TestLaneSelection.validatePartition( + lanes, discovered: discovered, + excluding: [ + "ParcelE2ETests.", "ParcelPerformanceTests.", "NameGuardTests.", "ParcelDevTests.", + "ParcelTestSupport.AppKitTestSuite/DisplayEventBenchmarkTests/", + ]) + let selection = try TestLaneSelection( + manifest: String(contentsOfFile: args[1], encoding: .utf8), + discovered: discovered, matching: args[3].isEmpty ? nil : args[3]) + if args[0] == "select" { + print(selection.filter) + return + } + let parser = XMLParser(data: try Data(contentsOf: URL(fileURLWithPath: args[4]))) + let results = Results() + parser.delegate = results + parser.shouldResolveExternalEntities = false + guard parser.parse(), ["testsuite", "testsuites"].contains(results.root), !results.failed else { + throw TestLaneSelection.SelectionFailure("Lane results are malformed or contain failures.") + } + for suite in selection.suites { + let className = suite.replacingOccurrences(of: "/", with: ".") + let found = args[0] == "check-unit" ? results.executed : results.reported + guard found.contains(className) else { + throw TestLaneSelection.SelectionFailure( + "Required suite did not \(args[0] == "check-unit" ? "execute" : "report"): \(suite)") + } + } + let allowed = Set(selection.suites.map { $0.replacingOccurrences(of: "/", with: ".") }) + guard results.executed.isSubset(of: allowed) else { + throw TestLaneSelection.SelectionFailure( + "Tests outside the lane executed: \(results.executed.subtracting(allowed).sorted())") + } + guard results.count > 0 else { + throw TestLaneSelection.SelectionFailure("No tests executed; skipped suites do not certify a lane.") + } + print("Lane verified: \(results.count) executed tests, \(selection.suites.count) required suites.") +} + +do { + try run() +} catch { + try FileHandle.standardError.write(contentsOf: Data("\(error)\n".utf8)) + exit(1) +} -- knotmirror 0.0.1 From 52f79e7f8b50be9917a144f464ed1e02527caf29 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Mon, 2 Nov 2026 16:55:26 -0500 Subject: [PATCH 3/5] Isolate test runner fixture settings Signed-off-by: Vincent Taverna --- Scripts/tests/test-runner.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/tests/test-runner.sh b/Scripts/tests/test-runner.sh index 01c8616d..83989782 100755 --- a/Scripts/tests/test-runner.sh +++ b/Scripts/tests/test-runner.sh @@ -1,6 +1,7 @@ #!/bin/bash set -euo pipefail cd "$(dirname "$0")/../.." +unset PARCEL_TEST_SKIP_BUILD PARCEL_TEST_XUNIT_OUTPUT work=$(mktemp -d "${TMPDIR:-/tmp}/test-runner.XXXXXX") trap 'rm -rf "$work"' EXIT mkdir -p "$work/project/Scripts" "$work/project/Tests/Lanes" "$work/bin" -- knotmirror 0.0.1 From c10946945b922d0b5825e31f68e2a1412063f82e Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Mon, 2 Nov 2026 17:09:02 -0500 Subject: [PATCH 4/5] Stop ancestry checks at the lock owner Signed-off-by: Vincent Taverna --- Tests/ParcelTestSupport/NativeHostAvailability.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/ParcelTestSupport/NativeHostAvailability.swift b/Tests/ParcelTestSupport/NativeHostAvailability.swift index 1809e802..da1be851 100644 --- a/Tests/ParcelTestSupport/NativeHostAvailability.swift +++ b/Tests/ParcelTestSupport/NativeHostAvailability.swift @@ -31,6 +31,8 @@ public enum NativeHostAvailability { var pid = getppid() while pid > 1, !ancestors.contains(pid) { ancestors.append(pid) + // Higher ancestors may be protected system processes; the lock owner is sufficient. + if NativeHostPolicy.ownsLock(owner: owner, ancestors: ancestors) { break } var info = proc_bsdinfo() let size = Int32(MemoryLayout.size) guard proc_pidinfo(pid, PROC_PIDTBSDINFO, 0, &info, size) == size else { -- knotmirror 0.0.1 From 82cd51eca8ad4a181f89f5bc8a0250de909a0891 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Mon, 2 Nov 2026 17:27:22 -0500 Subject: [PATCH 5/5] Select new localization suites Signed-off-by: Vincent Taverna --- Tests/Lanes/unit.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/Lanes/unit.txt b/Tests/Lanes/unit.txt index 878bbb47..2fd62774 100644 --- a/Tests/Lanes/unit.txt +++ b/Tests/Lanes/unit.txt @@ -208,6 +208,7 @@ ParcelIPCTests.FramingTests ParcelIPCTests.IPCResourceTests ParcelIPCTests.MemoryCLITests ParcelIPCTests.MinimumsCLIParsingTests +ParcelIPCTests.PackagedCLILocalizationTests ParcelIPCTests.PathTests ParcelIPCTests.ProtocolTests ParcelIPCTests.ResponseDeliveryTests @@ -304,6 +305,7 @@ ParcelUITests.HighlightSettingsTests ParcelUITests.HoverBarTests ParcelUITests.LanguagePreferencesTests ParcelUITests.LearningLocalizationTests +ParcelUITests.LocalizationPluralTests ParcelUITests.MenuModelTests ParcelUITests.MenuWorkspaceModelTests ParcelUITests.MiniMapTests -- knotmirror 0.0.1