mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-09-13 05:37:28 -04:00
fix(test): isolate androidApp unit tests from the production Application (#6644)
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6e0d3c3ae7
commit
b5152d14a0
4 files changed
+13
-5
No files matched your search
@@ -144,9 +144,8 @@ open class MeshUtilApplication :
|
||||
}
|
||||
|
||||
override fun onTerminate() {
|
||||
// Shutdown managers (useful for Robolectric tests).
|
||||
// Non-blocking: cancelAndJoin inside runBlocking on the main thread can deadlock
|
||||
// if any active coroutine is dispatching to Dispatchers.Main.
|
||||
// Robolectric never calls this, so unit tests booting this Application cannot rely on it.
|
||||
// cancel() not cancelAndJoin(): joining under runBlocking on the main thread can deadlock.
|
||||
applicationScope.cancel()
|
||||
try {
|
||||
runBlocking { get<DatabaseManager>().close() }
|
||||
|
||||
@@ -36,9 +36,11 @@ import org.meshtastic.feature.settings.radio.channel.channelsGraph
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
// Graph assembly only builds entry providers, so a bare Application is enough. Booting
|
||||
// MeshUtilApplication here leaks its applicationScope launches into the rest of the fork.
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
@Config(sdk = [34], application = android.app.Application::class)
|
||||
class NavigationAssemblyTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
# Legacy SQLite keeps Robolectric's native SQLite off androidApp's unit-test path. The native
|
||||
# implementation segfaults the whole test fork if its nativeruntime temp dir is torn down while a
|
||||
# background database open is still in flight, which fails the task outright (retry cannot help).
|
||||
# No androidApp unit test asserts database behaviour -- :core:database owns that and stays native.
|
||||
sdk=34
|
||||
sqliteMode=LEGACY
|
||||
@@ -44,9 +44,11 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotSame
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
// A bare Application keeps MeshUtilApplication.onCreate out of this test: its fire-and-forget
|
||||
// applicationScope launches outlive the class and surface here as UncaughtExceptionsBeforeTest.
|
||||
@OptIn(ExperimentalTestApi::class, ExperimentalCoroutinesApi::class)
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
@Config(sdk = [34], application = android.app.Application::class)
|
||||
class MapNodeClusterItemsTest {
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user