Troubleshooting tests: check that REPL process is stopped before continue test
This commit is contained in:
@@ -187,6 +187,8 @@ abstract class SequentialScratchExecutor(file: ScratchFile) : ScratchExecutor(fi
|
||||
stopExecution {
|
||||
lock.release()
|
||||
}
|
||||
lock.tryAcquire(2, TimeUnit.SECONDS)
|
||||
check(lock.tryAcquire(2, TimeUnit.SECONDS)) {
|
||||
"Couldn't stop REPL process in 2 seconds"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,11 +52,15 @@ class KtScratchReplExecutor(file: ScratchFile) : SequentialScratchExecutor(file)
|
||||
}
|
||||
|
||||
override fun stopExecution(callback: (() -> Unit)?) {
|
||||
val osProcessHandler = osProcessHandler ?: return
|
||||
val processHandler = osProcessHandler
|
||||
if (processHandler == null) {
|
||||
callback?.invoke()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
if (callback != null) {
|
||||
osProcessHandler.addProcessListener(object : ProcessAdapter() {
|
||||
processHandler.addProcessListener(object : ProcessAdapter() {
|
||||
override fun processTerminated(event: ProcessEvent) {
|
||||
callback()
|
||||
}
|
||||
@@ -66,7 +70,7 @@ class KtScratchReplExecutor(file: ScratchFile) : SequentialScratchExecutor(file)
|
||||
} catch (e: Exception) {
|
||||
errorOccurs("Couldn't stop REPL process", e, false)
|
||||
|
||||
osProcessHandler.destroyProcess()
|
||||
processHandler.destroyProcess()
|
||||
clearState()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
||||
if (!KotlinHighlightingUtil.shouldHighlight(myFixture.file)) error("Highlighting for scratch file is switched off")
|
||||
|
||||
launchScratch()
|
||||
waitUntilScratchFinishes()
|
||||
waitUntilScratchFinishes(isRepl)
|
||||
}
|
||||
|
||||
private fun getExpectedFile(fileName: String, isRepl: Boolean, suffix: String): File {
|
||||
|
||||
@@ -39,7 +39,7 @@ class CustomScratchRunActionTest : AbstractScratchRunActionTest() {
|
||||
configureScratchByText("scratch_1.kts", fileText)
|
||||
|
||||
launchScratch()
|
||||
waitUntilScratchFinishes()
|
||||
waitUntilScratchFinishes(isRepl)
|
||||
|
||||
return getFileTextWithInlays()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user