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 {
|
stopExecution {
|
||||||
lock.release()
|
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)?) {
|
override fun stopExecution(callback: (() -> Unit)?) {
|
||||||
val osProcessHandler = osProcessHandler ?: return
|
val processHandler = osProcessHandler
|
||||||
|
if (processHandler == null) {
|
||||||
|
callback?.invoke()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
osProcessHandler.addProcessListener(object : ProcessAdapter() {
|
processHandler.addProcessListener(object : ProcessAdapter() {
|
||||||
override fun processTerminated(event: ProcessEvent) {
|
override fun processTerminated(event: ProcessEvent) {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
@@ -66,7 +70,7 @@ class KtScratchReplExecutor(file: ScratchFile) : SequentialScratchExecutor(file)
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
errorOccurs("Couldn't stop REPL process", e, false)
|
errorOccurs("Couldn't stop REPL process", e, false)
|
||||||
|
|
||||||
osProcessHandler.destroyProcess()
|
processHandler.destroyProcess()
|
||||||
clearState()
|
clearState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
|||||||
if (!KotlinHighlightingUtil.shouldHighlight(myFixture.file)) error("Highlighting for scratch file is switched off")
|
if (!KotlinHighlightingUtil.shouldHighlight(myFixture.file)) error("Highlighting for scratch file is switched off")
|
||||||
|
|
||||||
launchScratch()
|
launchScratch()
|
||||||
waitUntilScratchFinishes()
|
waitUntilScratchFinishes(isRepl)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getExpectedFile(fileName: String, isRepl: Boolean, suffix: String): File {
|
private fun getExpectedFile(fileName: String, isRepl: Boolean, suffix: String): File {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class CustomScratchRunActionTest : AbstractScratchRunActionTest() {
|
|||||||
configureScratchByText("scratch_1.kts", fileText)
|
configureScratchByText("scratch_1.kts", fileText)
|
||||||
|
|
||||||
launchScratch()
|
launchScratch()
|
||||||
waitUntilScratchFinishes()
|
waitUntilScratchFinishes(isRepl)
|
||||||
|
|
||||||
return getFileTextWithInlays()
|
return getFileTextWithInlays()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user