Skip to content

Commit 795df77

Browse files
Attempt to fix TSan issues in Swift unit tests.
The only reason we are messing with the delegate's fields is because we had no remove API, but we have that now. And maybe this will fix the claimed thread race between us setting its fields and it being destroyed.
1 parent 8750c55 commit 795df77

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift

+2-6
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,8 @@ class MTRSwiftDeviceTests : XCTestCase {
414414

415415
wait(for: [ resubscriptionReachableExpectation, resubscriptionGotReportsExpectation ], timeout:60)
416416

417-
// Now make sure we ignore later tests. Ideally we would just unsubscribe
418-
// or remove the delegate, but there's no good way to do that.
419-
delegate.onReachable = { () -> Void in }
420-
delegate.onNotReachable = nil
421-
delegate.onAttributeDataReceived = nil
422-
delegate.onEventDataReceived = nil
417+
// Now make sure we ignore later tests.
418+
device.remove(_: delegate)
423419

424420
// Make sure we got no updated reports (because we had a cluster state cache
425421
// with data versions) during the resubscribe.

0 commit comments

Comments
 (0)