The test harness sets up the runloop to the current runloop which is not the actual runloop that the test will execute on which results in the test failing. Using the maion loop rather than the current runloop allows the test to pass.
The text was updated successfully, but these errors were encountered:
I think you may be correct that there is an unintentional behavioral difference here compared to the ObjC / Darwin XCTest framework. It was intentional for XCTNSPredicateExpectation to call `RunLoop.current` in order to get its run loop to use, but the timing of when it obtains that run loop looks wrong. In ObjC / Darwin XCTest, it calls `RunLoop.current` while on a private queue which is the analogue of `XCTWaiter.subsystemQueue` here. But in Corelibs XCTest, it gets the current run loop at object initialization, which is not on `XCTWaiter.subsystemQueue`.
So if my reading here is correct, it may indeed be using the wrong run loop. Although if this is the case, the correct run loop may not actually be not `.main` either, but the run loop corresponding to the thread for `XCTWaiter.subsystemQueue`.
Seems like the fix would be for XCTNSPredicateExpectation to lazily populate its `runLoop` property in `didBeginWaiting()` instead of setting it during init.