Joffrey
09/18/2021, 10:09 PMiosTest
(unit tests), but everything is just stuck.
I saw this comment in a very old thread, and I'm thinking maybe it's the same "queue is not run" problem.
Is there anyway for me to run this queue within an iOS unit test? I'm writing a multiplatform library so I don't have an iOS app project.
It looks like I don't have access to NSApplication
there.Joffrey
09/18/2021, 10:49 PMNSRunLoop.mainRunLoop.run()
which seems to execute that main loop, but I don't see how I can use it inside unit tests. The test seems to run in the main loop itself, so how can I yield the main thread to coroutines, but still have the test framework wait for the test to finish?Tijl
09/20/2021, 7:13 AMTijl
09/20/2021, 7:16 AMdefer
in this situation as this will run after the test (quite ugly in my opinion)Joffrey
09/20/2021, 8:29 AMTijl
09/20/2021, 8:40 AMTijl
09/20/2021, 8:41 AMJoffrey
09/20/2021, 8:45 AMif you launch a coroutine on the main thread, and just do everything from there, then all memory is in the same threadYes, that's actually what I do to avoid problems, but if the main thread is busy running your coroutine it cannot run the main loop. So I cannot use things that block indefinitely like
CFRunLoopRun()
(I don't see how that works in your library). Instead I have to progress the main loop little by little (e.g. using NSRunLoop.mainRunLoop.runUntilDate(date)
) like it's done here:
https://github.com/ktorio/ktor/issues/678#issuecomment-433756753Joffrey
09/20/2021, 8:46 AMTijl
09/20/2021, 8:47 AM