Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Intermittent test failure - Dispatchers.Main is used concurrently with setting it #12230

Closed
jonalmeida opened this issue May 25, 2022 · 5 comments
Labels
🎲 intermittent-test Evil test failures that only happen now-and-then and are a productivity killer

Comments

@jonalmeida
Copy link
Contributor

jonalmeida commented May 25, 2022

I saw this while debugging #12143 locally:

Dispatchers.Main is used concurrently with setting it
java.lang.IllegalStateException: Dispatchers.Main is used concurrently with setting it
	at kotlinx.coroutines.test.internal.TestMainDispatcher$NonConcurrentlyModifiable.concurrentRW(TestMainDispatcher.kt:70)
	at kotlinx.coroutines.test.internal.TestMainDispatcher$NonConcurrentlyModifiable.setValue(TestMainDispatcher.kt:86)
	at kotlinx.coroutines.test.internal.TestMainDispatcher.resetDispatcher(TestMainDispatcher.kt:40)
	at kotlinx.coroutines.test.TestDispatchers.resetMain(TestDispatchers.kt:37)
	at mozilla.components.support.test.rule.MainCoroutineRule.finished(MainCoroutineRule.kt:54)
	at org.junit.rules.TestWatcher.finishedQuietly(TestWatcher.java:117)
	at org.junit.rules.TestWatcher.access$400(TestWatcher.java:46)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:64)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:591)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:274)

@Mugurell do you have any hints about this since you worked on upgrading our coroutine testing recently?

┆Issue is synchronized with this Jira Task

@jonalmeida jonalmeida added the 🎲 intermittent-test Evil test failures that only happen now-and-then and are a productivity killer label May 25, 2022
@Mugurell
Copy link
Contributor

Not sure how a concurrent read-write may happen since we rely on JUnit callback which I expect will ensure the calls about when a test is finished and another one starts are somehow synchronized.
Thinking specifically about this maybe we should first call setMain and resetMain in MainCoroutineRule before calling super.

@jonalmeida
Copy link
Contributor Author

Similar failures in CI too: #12227

@jonalmeida
Copy link
Contributor Author

Similar failures in CI (PromptFeature again): #12321

@YuraLaguta
Copy link

Facing the same issue looks like the order of call won't help because the super implementations are empty
Screen Shot 2022-07-11 at 4 28 28 pm

@csadilek
Copy link
Contributor

Moved to bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1794861

Change performed by the Move to Bugzilla add-on.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🎲 intermittent-test Evil test failures that only happen now-and-then and are a productivity killer
Projects
None yet
Development

No branches or pull requests

4 participants