From 059dce0feeaa7d8a8ca44362aad66ba442361cbd Mon Sep 17 00:00:00 2001 From: Micah Alpern Date: Mon, 1 Jun 2026 15:07:01 -0700 Subject: [PATCH] test(lint): tighten seam regex + drop reference-only suites (#698) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two cleanups to the TestSeamLintTests ratchet: 1. Anchor the hazard-type regex with a leading word boundary (\b). Without it, the pattern matched a method NAME ending in a type, e.g. `testAppKitSourcesDoNotBypassInstallerEngine()`, flagging FacadeLintTests as a false positive. 2. Drop 4 reference-only suites from the allowlist (they only name the types, never construct them, so the tightened regex no longer flags them): FacadeLintTests, PrivilegedOperationsCoordinatorTests, SystemRequirementsTests, WizardPureLogicTests. Allowlist shrinks 8 → 4. The remaining 4 are the genuinely-hard cases: ErrorHandlingTests, KeyPathTests, RuntimeCoordinatorResetTests (real saveConfiguration/ resetToDefaultConfig I/O — see #698) and VHIDDeviceManagerTests (the seam's own test). Verified: `swift test --filter TestSeamLintTests` passes in 0.08s. Co-Authored-By: Claude Opus 4.8 (1M context) --- Tests/KeyPathTests/Lint/TestSeamLintTests.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Tests/KeyPathTests/Lint/TestSeamLintTests.swift b/Tests/KeyPathTests/Lint/TestSeamLintTests.swift index 8f5643587..dc1be2c5e 100644 --- a/Tests/KeyPathTests/Lint/TestSeamLintTests.swift +++ b/Tests/KeyPathTests/Lint/TestSeamLintTests.swift @@ -17,22 +17,23 @@ final class TestSeamLintTests: XCTestCase { /// Pre-existing suites that use a hazard type but still extend XCTestCase directly. /// Migrate these to KeyPathTestCase and remove them here. Never add new entries. private static let allowList: Set = [ + // Real-I/O suites: the seam fixes their pgrep hang but they also do real + // saveConfiguration/updateStatus/resetToDefaultConfig that needs deeper mocking. "ErrorHandlingTests.swift", - "FacadeLintTests.swift", "KeyPathTests.swift", - "PrivilegedOperationsCoordinatorTests.swift", "RuntimeCoordinatorResetTests.swift", - "SystemRequirementsTests.swift", - "VHIDDeviceManagerTests.swift", - "WizardPureLogicTests.swift" + // The seam's own test (sets testPIDProvider per test, asserts real-pgrep fallthrough). + "VHIDDeviceManagerTests.swift" ] func testCoordinatorSuitesUseKeyPathTestCase() throws { let testsDir = repositoryRoot().appendingPathComponent("Tests/KeyPathTests") - // Type used as a constructor `Type(` or as a type annotation `: Type`. + // Type used as a constructor `Type(` or as a type annotation `: Type`. The + // leading \b avoids matching a method name that merely ends in the type, e.g. + // `testDoNotBypassInstallerEngine()`. let hazard = try NSRegularExpression( - pattern: #"(RuntimeCoordinator|InstallerEngine|SystemValidator|VHIDDeviceManager)\s*\(|:\s*(RuntimeCoordinator|InstallerEngine|SystemValidator|VHIDDeviceManager)\b"# + pattern: #"\b(RuntimeCoordinator|InstallerEngine|SystemValidator|VHIDDeviceManager)\s*\(|:\s*(RuntimeCoordinator|InstallerEngine|SystemValidator|VHIDDeviceManager)\b"# ) guard let enumerator = FileManager.default.enumerator(at: testsDir, includingPropertiesForKeys: nil) else {