Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix execution cancellation #358

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ class TestCasePanelBuilder(
}
}

fun removeTask() {
finishProcess()
update()
}

private fun runTest(indicator: CustomProgressIndicator) {
indicator.setText("Executing ${testCase.testName}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,35 @@ class TopButtonsPanelBuilder {
testCasePanelFactory.addTask(tasks)
}
// run tasks one after each other
executeTasks(project, tasks)
executeTasks(project, tasks, generatedTestsTabData)
}

private fun executeTasks(project: Project, tasks: Queue<(CustomProgressIndicator) -> Unit>) {
private fun executeTasks(project: Project, tasks: Queue<(CustomProgressIndicator) -> Unit>, generatedTestsTabData: GeneratedTestsTabData) {
val nextTask = tasks.poll()

nextTask?.let { task ->
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Test execution") {
var globalIndicator: ProgressIndicator? = null

override fun run(indicator: ProgressIndicator) {
globalIndicator = indicator
task(IJProgressIndicator(indicator))
}

override fun onFinished() {
super.onFinished()
executeTasks(project, tasks)
if (globalIndicator != null && !globalIndicator!!.isCanceled) {
executeTasks(project, tasks, generatedTestsTabData)
} else {
if (tasks.isNotEmpty()) {
runAllButton.isEnabled = true
val firstTestPanelFactoryIndex = generatedTestsTabData.testCasePanelFactories.size - tasks.size - 1
val lastTestPanelFactoryIndex = generatedTestsTabData.testCasePanelFactories.size
for (index in firstTestPanelFactoryIndex until lastTestPanelFactoryIndex) {
generatedTestsTabData.testCasePanelFactories[index].removeTask()
}
}
}
}
})
}
Expand Down
Loading