Skip to content

Commit 931b252

Browse files
committed
Refactor ThreadSafetyTests to improve clarity and maintain compatibility with Windows. Added type annotations for ComposableCache and AnyCacheable instances, and wrapped tests in conditional compilation to exclude them on Windows.
1 parent d4c6712 commit 931b252

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Tests/CacheTests/ThreadSafetyTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ final class ThreadSafetyTests: XCTestCase {
437437

438438
/// Test ComposableCache thread safety
439439
func testComposableCacheThreadSafety() {
440+
#if !os(Windows)
440441
let cache1 = Cache<String, Any>()
441442
let cache2 = Cache<String, Any>()
442-
let composableCache = ComposableCache<String>(caches: [cache1, cache2])
443+
let composableCache: ComposableCache<String> = ComposableCache<String>(caches: [cache1, cache2])
443444

444445
let iterations = 2000
445446
let expectation = XCTestExpectation(description: "ComposableCache thread safety test")
@@ -465,12 +466,14 @@ final class ThreadSafetyTests: XCTestCase {
465466
}
466467

467468
wait(for: [expectation], timeout: 5.0)
469+
#endif
468470
}
469471

470472
/// Test AnyCacheable thread safety
471473
func testAnyCacheableThreadSafety() {
474+
#if !os(Windows)
472475
let cache = Cache<String, Any>()
473-
let anyCacheable = AnyCacheable(cache)
476+
let anyCacheable: AnyCacheable = AnyCacheable(cache)
474477

475478
let iterations = 2000
476479
let expectation = XCTestExpectation(description: "AnyCacheable thread safety test")
@@ -495,6 +498,7 @@ final class ThreadSafetyTests: XCTestCase {
495498
}
496499

497500
wait(for: [expectation], timeout: 5.0)
501+
#endif
498502
}
499503

500504
/// Test mixed operations that could cause deadlocks

0 commit comments

Comments
 (0)