Some test is flaky and hangs
See https://github.com/cashapp/molecule/actions/runs/14384606655/attempts/1, for example.
Not the first time I've seen it, either.
Pretty confident it's MoleculeConcurrentTest ☹
I'm fairly certain it is the MoleculeConcurrentTest class that is causing the hanging builds. You can reproduce it locally by placing the test in a loop:
@Test fun coroutineContextHonoredByImmediateClock() = repeat(2) { /* ... existing test ... */ }
I believe the problem is that the original test relies on recomposition occurring naturally, but the implicit StandardTestDispatcher used by runTest doesn't drive Dispatchers.Default—which is where the recomposition is scheduled. Since nothing is forcing recomposition to occur, the cancelLatch.await() hangs indefinitely.
Compose runtime has a similar test in their RecomposerTests.jvm.kt class. You could modify your coroutineContextHonoredByImmediateClock test to do something similar:
@Test fun coroutineContextHonoredByImmediateClock() = runTest(UnconfinedTestDispatcher()) {
val testThread = Thread.currentThread()
val job = Job()
val threadChannel = Channel<Thread>(Channel.UNLIMITED)
lateinit var recomposeScope: RecomposeScope
backgroundScope.launchMolecule(Immediate, job + Dispatchers.Default) {
threadChannel.trySend(Thread.currentThread())
val scope = currentRecomposeScope
SideEffect { recomposeScope = scope }
}
val firstThread = threadChannel.receive()
assertThat(firstThread).isSameInstanceAs(testThread)
recomposeScope.invalidate()
val secondThread = threadChannel.receive()
assertThat(secondThread).isNotSameInstanceAs(testThread)
assertThat(secondThread.name).contains("DefaultDispatcher")
job.cancelAndJoin()
}
I can reopen #617 since it looks like there are still hanging builds.
It's definitely still problematic, but I haven't had time to look at anything.