Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit 4f05410

Browse files
steipeteclaude
andcommitted
Fix remaining CI warnings in Swift Testing conversion
- Remove unnecessary await keywords from synchronous calls - Replace unused variables with underscore - Fix 'is' test that was always true for non-optional AXorcist - Simplify boolean test expectations These changes resolve all remaining compiler warnings identified during CI runs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 30f9628 commit 4f05410

2 files changed

Lines changed: 51 additions & 85 deletions

File tree

Tests/IntegrationTests.swift

Lines changed: 49 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct IntegrationTests {
2121
coordinator = AppServiceCoordinator()
2222
let loginItemManager = LoginItemManager.shared
2323
let sessionLogger = SessionLogger.shared
24-
windowManager = await WindowManager(
24+
windowManager = WindowManager(
2525
loginItemManager: loginItemManager,
2626
sessionLogger: sessionLogger,
2727
delegate: nil
@@ -79,8 +79,7 @@ struct IntegrationTests {
7979
let monitor = CursorMonitor.shared
8080
// The test is already MainActor-isolated, so we can access these directly
8181
// AXorcist property is non-optional, so just verify it exists
82-
let monitorAxorcist = monitor.axorcist
83-
#expect(monitorAxorcist is AXorcist)
82+
_ = monitor.axorcist
8483

8584
// Verify initial state
8685
#expect(!monitor.isMonitoringActivePublic)
@@ -143,7 +142,7 @@ struct IntegrationTests {
143142
),
144143
]
145144

146-
let appInfo = await MonitoredAppInfo(
145+
let appInfo = MonitoredAppInfo(
147146
id: 12345,
148147
pid: 12345,
149148
displayName: "Cursor with Windows",
@@ -153,32 +152,25 @@ struct IntegrationTests {
153152
windows: windows
154153
)
155154

156-
await MainActor.run {
157-
monitor.monitoredApps = [appInfo]
158-
}
155+
monitor.monitoredApps = [appInfo]
159156

160157
// Verify window information is preserved
161-
await MainActor.run {
162-
let app = monitor.monitoredApps.first
163-
#expect(app?.windows.count == 2)
164-
#expect(app?.windows.first?.windowTitle == "Main Document.txt")
165-
#expect(app?.windows.first?.documentPath == "/path/to/main.txt")
166-
#expect(app?.windows.last?.windowTitle == "Settings")
167-
#expect(app?.windows.last?.documentPath == nil)
168-
}
158+
let app = monitor.monitoredApps.first
159+
#expect(app?.windows.count == 2)
160+
#expect(app?.windows.first?.windowTitle == "Main Document.txt")
161+
#expect(app?.windows.first?.documentPath == "/path/to/main.txt")
162+
#expect(app?.windows.last?.windowTitle == "Settings")
163+
#expect(app?.windows.last?.documentPath == nil)
169164
}
170165

171166
// MARK: - Intervention Flow Tests
172167

173168
@Test("Intervention flow") @MainActor func interventionFlow() async throws {
174-
let coordinator = AppServiceCoordinator()
169+
_ = AppServiceCoordinator()
175170
let monitor = CursorMonitor.shared
176-
// Monitor has internal rule execution
177-
// Just verify monitor exists
178-
#expect(monitor != nil)
179171

180172
// Create app that might need intervention
181-
let appInfo = await MonitoredAppInfo(
173+
let appInfo = MonitoredAppInfo(
182174
id: 12345,
183175
pid: 12345,
184176
displayName: "Cursor Needing Intervention",
@@ -187,9 +179,7 @@ struct IntegrationTests {
187179
interventionCount: 0
188180
)
189181

190-
await MainActor.run {
191-
monitor.monitoredApps = [appInfo]
192-
}
182+
monitor.monitoredApps = [appInfo]
193183

194184
// Start monitoring
195185
await monitor.startMonitoringLoop()
@@ -198,9 +188,7 @@ struct IntegrationTests {
198188
await monitor.performMonitoringCycle()
199189

200190
// Verify intervention tracking
201-
await MainActor.run {
202-
#expect(monitor.totalAutomaticInterventionsThisSessionDisplay >= 0)
203-
}
191+
#expect(monitor.totalAutomaticInterventionsThisSessionDisplay >= 0)
204192

205193
// Cleanup
206194
await monitor.stopMonitoringLoop()
@@ -211,8 +199,8 @@ struct IntegrationTests {
211199

212200
@Test("Settings persistence integration") @MainActor func settingsPersistenceIntegration() async throws {
213201
// Save original values
214-
let originalMonitoring = await MainActor.run { Defaults[.isGlobalMonitoringEnabled] }
215-
let originalMaxInterventions = await MainActor.run { Defaults[.maxInterventionsBeforePause] }
202+
let originalMonitoring = Defaults[.isGlobalMonitoringEnabled]
203+
let originalMaxInterventions = Defaults[.maxInterventionsBeforePause]
216204

217205
defer {
218206
// Restore original values
@@ -223,65 +211,53 @@ struct IntegrationTests {
223211
}
224212

225213
// Set some test settings
226-
await MainActor.run {
227-
Defaults[.isGlobalMonitoringEnabled] = true
228-
Defaults[.maxInterventionsBeforePause] = 10
229-
}
214+
Defaults[.isGlobalMonitoringEnabled] = true
215+
Defaults[.maxInterventionsBeforePause] = 10
230216

231217
// Create first coordinator instance
232-
let coordinator1 = AppServiceCoordinator()
233-
let monitor1 = CursorMonitor.shared
218+
_ = AppServiceCoordinator()
219+
_ = CursorMonitor.shared
234220

235221
// Verify settings are loaded
236-
await MainActor.run {
237-
#expect(Defaults[.isGlobalMonitoringEnabled])
238-
#expect(Defaults[.maxInterventionsBeforePause] == 10)
239-
}
222+
#expect(Defaults[.isGlobalMonitoringEnabled])
223+
#expect(Defaults[.maxInterventionsBeforePause] == 10)
240224

241225
// Create second coordinator instance (simulating restart)
242-
let coordinator2 = AppServiceCoordinator()
243-
let monitor2 = CursorMonitor.shared
226+
_ = AppServiceCoordinator()
227+
_ = CursorMonitor.shared
244228

245229
// Verify settings persistence
246-
await MainActor.run {
247-
#expect(Defaults[.isGlobalMonitoringEnabled])
248-
#expect(Defaults[.maxInterventionsBeforePause] == 10)
249-
}
230+
#expect(Defaults[.isGlobalMonitoringEnabled])
231+
#expect(Defaults[.maxInterventionsBeforePause] == 10)
250232

251233
// Test settings changes
252-
await MainActor.run {
253-
Defaults[.isGlobalMonitoringEnabled] = false
254-
#expect(!Defaults[.isGlobalMonitoringEnabled])
255-
}
234+
Defaults[.isGlobalMonitoringEnabled] = false
235+
#expect(!Defaults[.isGlobalMonitoringEnabled])
256236
}
257237

258238
@Test("Window settings persistence") @MainActor func windowSettingsPersistence() async throws {
259239
// Create window with settings
260-
var windowInfo = await MonitoredWindowInfo(
240+
var windowInfo = MonitoredWindowInfo(
261241
id: "test-window",
262242
windowTitle: "Test Document.txt",
263243
documentPath: "/path/to/test.txt"
264244
)
265245

266246
// Modify settings
267-
await MainActor.run {
268-
windowInfo.isLiveWatchingEnabled = true
269-
windowInfo.aiAnalysisIntervalSeconds = 30
270-
windowInfo.saveAISettings()
271-
}
247+
windowInfo.isLiveWatchingEnabled = true
248+
windowInfo.aiAnalysisIntervalSeconds = 30
249+
windowInfo.saveAISettings()
272250

273251
// Create new window instance with same ID
274-
let newWindowInfo = await MonitoredWindowInfo(
252+
let newWindowInfo = MonitoredWindowInfo(
275253
id: "test-window",
276254
windowTitle: "Test Document.txt",
277255
documentPath: "/path/to/test.txt"
278256
)
279257

280258
// Verify settings were loaded
281-
await MainActor.run {
282-
#expect(newWindowInfo.isLiveWatchingEnabled)
283-
#expect(newWindowInfo.aiAnalysisIntervalSeconds == 30)
284-
}
259+
#expect(newWindowInfo.isLiveWatchingEnabled)
260+
#expect(newWindowInfo.aiAnalysisIntervalSeconds == 30)
285261

286262
// Clean up test settings if needed
287263
// Note: Window settings are stored per window ID and would be cleaned up
@@ -292,22 +268,20 @@ struct IntegrationTests {
292268

293269
@Test("Permission flow integration") @MainActor func permissionFlowIntegration() async throws {
294270
// Test accessibility permissions check
295-
let permissionsManager = await PermissionsManager()
271+
let permissionsManager = PermissionsManager()
296272

297273
// Wait for initial check
298274
try await Task.sleep(for: .milliseconds(100))
299275

300276
// This should not crash regardless of permission state
301-
await MainActor.run {
302-
#expect(
303-
permissionsManager.hasAccessibilityPermissions == true || permissionsManager
304-
.hasAccessibilityPermissions == false
305-
)
306-
}
277+
#expect(
278+
permissionsManager.hasAccessibilityPermissions == true || permissionsManager
279+
.hasAccessibilityPermissions == false
280+
)
307281
}
308282

309283
@Test("A xorcist permission integration") @MainActor func aXorcistPermissionIntegration() async throws {
310-
let axorcist = await AXorcist()
284+
let axorcist = AXorcist()
311285

312286
// Test that AXorcist can be created without errors
313287
#expect(axorcist != nil)
@@ -320,22 +294,16 @@ struct IntegrationTests {
320294
}
321295
"""
322296

323-
do {
324-
// Test that we can use AXorcist without errors
325-
// In a real test, we'd need to create proper command structures
326-
// For now, just verify AXorcist can be created
327-
let result = true
328-
#expect(result != nil)
329-
} catch {
330-
// Ping might fail due to permissions, but should not crash
331-
#expect(error != nil)
332-
}
297+
// Test that we can use AXorcist without errors
298+
// In a real test, we'd need to create proper command structures
299+
// For now, just verify AXorcist can be created
300+
#expect(true)
333301
}
334302

335303
// MARK: - Cross-Service Integration Tests
336304

337305
@Test("Service coordination") @MainActor func serviceCoordination() async throws {
338-
let coordinator = AppServiceCoordinator()
306+
_ = AppServiceCoordinator()
339307

340308
// Test that all services can be accessed
341309
let cursorMonitor = CursorMonitor.shared
@@ -349,11 +317,11 @@ struct IntegrationTests {
349317
}
350318

351319
@Test("Cross service error handling") @MainActor func crossServiceErrorHandling() async throws {
352-
let coordinator = AppServiceCoordinator()
320+
_ = AppServiceCoordinator()
353321
let monitor = CursorMonitor.shared
354322

355323
// Test error handling with invalid data
356-
let invalidAppInfo = await MonitoredAppInfo(
324+
let invalidAppInfo = MonitoredAppInfo(
357325
id: -1, // Invalid PID
358326
pid: -1,
359327
displayName: "",
@@ -362,9 +330,7 @@ struct IntegrationTests {
362330
interventionCount: 0
363331
)
364332

365-
await MainActor.run {
366-
monitor.monitoredApps = [invalidAppInfo]
367-
}
333+
monitor.monitoredApps = [invalidAppInfo]
368334

369335
// This should not crash
370336
await monitor.performMonitoringCycle()

Tests/SessionLoggingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ struct SessionLoggingTests {
248248
"Category-based logger creation",
249249
arguments: zip(
250250
[String.self, Int.self, SessionLoggingTests.self] as [Any.Type],
251-
[Diagnostics.LogCategory.app, Diagnostics.LogCategory.api, Diagnostics.LogCategory.supervision]
251+
[LogCategory.app, LogCategory.api, LogCategory.supervision]
252252
)
253253
)
254-
func categoryBasedLoggerCreation(type: Any.Type, category: Diagnostics.LogCategory) {
254+
func categoryBasedLoggerCreation(type: Any.Type, category: LogCategory) {
255255
let logger = LoggerFactory.logger(for: type, category: category)
256256

257257
#expect(throws: Never.self) {

0 commit comments

Comments
 (0)