mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test framework [driver]: Fix BackgroundRun.useDriver error handling
GitOrigin-RevId: 02d2c64c6296be03b6ff6f728412d2a8c23779f6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9761812196
commit
ed82295049
+19
-5
@@ -59,11 +59,25 @@ open class BackgroundRun(override val startResult: Deferred<IDEStartResult>, dri
|
||||
* The IDE is closed on any exception, or if it doesn't close automatically after the block execution completes.
|
||||
*/
|
||||
open fun <R> useDriver(closeIdeTimeout: Duration = 1.minutes, block: Driver.() -> R): IDEStartResult {
|
||||
val ideStartResult: IDEStartResult
|
||||
try {
|
||||
driver.withContext { block(this) }
|
||||
}
|
||||
finally {
|
||||
lateinit var ideStartResult: IDEStartResult
|
||||
runCatching {
|
||||
driver.withContext {
|
||||
block(this)
|
||||
if (isConnected) takeScreenshot("beforeIdeClosed")
|
||||
}
|
||||
}.onFailure { e ->
|
||||
runCatching {
|
||||
driver.exitApplication()
|
||||
waitFor(
|
||||
timeout = 15.seconds,
|
||||
errorMessage = {
|
||||
forceKill()
|
||||
"Error on exit application via Driver"
|
||||
},
|
||||
) { !driver.isConnected }
|
||||
}
|
||||
throw e
|
||||
}.onSuccess {
|
||||
ideStartResult = driver.waitToClose(closeIdeTimeout)
|
||||
}
|
||||
return ideStartResult
|
||||
|
||||
Reference in New Issue
Block a user