fix(ci): remove the three main unit test flakes (#3117)

* fix(test): ProtonMenuAutoTest no longer fetches Proton releases from GitHub

aCachedCheckUpdatesOnlyInstalledFamiliesAndReplacesOlderDroidDeckProton left experimentalRefresh at its default, which downloads the release list with 10 s connect and 15 s read timeouts, so a slow or rate-limited network blew the test's 5 s wait.

* fix(test): a background-thread error no longer halts the unit test JVM

Every Robolectric test runs App.onCreate, which chains CrashHandler onto the default uncaught-exception handler. A plain JVM has none, so the first test's handler halts with exit 2 on any later uncaught error, and the chain grows by one layer per test. A Robolectric lifecycle plugin now resets the default handler to a printing one before each test.
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-23 22:09:28 -05:00
1 parent 95aab3703f
commit f9304f41c7
4 files changed
+39

No files matched your search

@@ -65,6 +65,7 @@ class ProtonMenuAutoTest {
menu.protonProblem = null
menu.protonStage = null
menu.protonPercent = -1
menu.experimentalRefresh = { emptyList() }
menu.installer = { tool, progress ->
progress("Installing ${tool.name}", 50)
install("${tool.prefix}-11-12")
@@ -0,0 +1,16 @@
package com.droiddeck.launcher.session
import org.robolectric.pluginapi.TestEnvironmentLifecyclePlugin
/**
* A plain JVM has no default uncaught-exception handler, so CrashHandler's fallback halts the test JVM (exit 2)
* on any background-thread error. Each test starts from a handler that only prints, like the JVM's own.
*/
class TestJvmUncaughtHandler : TestEnvironmentLifecyclePlugin {
override fun onSetupApplicationState() {
Thread.setDefaultUncaughtExceptionHandler { thread, error ->
System.err.print("Exception in thread \"${thread.name}\" ")
error.printStackTrace(System.err)
}
}
}
@@ -0,0 +1,21 @@
package com.droiddeck.launcher.session
import com.droiddeck.launcher.App
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34])
class UncaughtBackgroundErrorTest {
@Test fun anUncaughtErrorOnABackgroundThreadDoesNotEndTheTestRun() {
assertTrue(RuntimeEnvironment.getApplication() is App)
Thread({ throw IllegalStateException("expected by the test") }, "uncaught-background-error").apply {
start()
join()
}
}
}
@@ -0,0 +1 @@
com.droiddeck.launcher.session.TestJvmUncaughtHandler