Skip to content

Commit edd6ad2

Browse files
IDEA hangs during test generation #1207
1 parent 12ad92c commit edd6ad2

File tree

7 files changed

+161
-166
lines changed

7 files changed

+161
-166
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt

+16-16
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ object CodeGenerationController {
140140
}
141141
}
142142

143-
run(THREAD_POOL, indicator) {
143+
run(THREAD_POOL, indicator, "Waiting for per-class Sarif reports") {
144144
waitForCountDown(latch, indicator = indicator) {
145-
run(EDT_LATER, indicator) {
146-
run(WRITE_ACTION, indicator) {
145+
run(EDT_LATER, indicator,"Go to EDT for utility class creation") {
146+
run(WRITE_ACTION, indicator, "Need write action for utility class creation") {
147147
createUtilityClassIfNeed(utilClassListener, model, baseTestDirectory, indicator)
148-
run(EDT_LATER, indicator) {
148+
run(EDT_LATER, indicator, "Proceed test report") {
149149
proceedTestReport(proc, model)
150-
run(THREAD_POOL, indicator) {
150+
run(THREAD_POOL, indicator, "Generate summary Sarif report") {
151151
val sarifReportsPath =
152152
model.testModule.getOrCreateSarifReportsPath(model.testSourceRoot)
153153
UtTestsDialogProcessor.updateIndicator(indicator, UtTestsDialogProcessor.ProgressRange.SARIF, "Merge Sarif reports", 0.75)
@@ -157,9 +157,9 @@ object CodeGenerationController {
157157
RunConfigurationHelper.runTestsWithCoverage(model, testFilesPointers)
158158
}
159159
proc.forceTermination()
160-
UtTestsDialogProcessor.updateIndicator(indicator, UtTestsDialogProcessor.ProgressRange.SARIF, "Start tests with coverage", 1.0)
160+
UtTestsDialogProcessor.updateIndicator(indicator, UtTestsDialogProcessor.ProgressRange.SARIF, "Generation finished", 1.0)
161161

162-
invokeLater {
162+
run(EDT_LATER, null, "Run sarif-based inspections") {
163163
runInspectionsIfNeeded(model, srcClassPathToSarifReport)
164164
}
165165
}
@@ -339,8 +339,8 @@ object CodeGenerationController {
339339

340340
val utUtilsText = utilClassKind.getUtilClassText(model.codegenLanguage)
341341

342-
run(EDT_LATER, indicator) {
343-
run(WRITE_ACTION, indicator) {
342+
run(EDT_LATER, indicator, "Overwrite utility class") {
343+
run(WRITE_ACTION, indicator, "Overwrite utility class") {
344344
unblockDocument(model.project, utilsClassDocument)
345345
executeCommand {
346346
utilsClassDocument.setText(utUtilsText.replace("jdk.internal.misc", "sun.misc"))
@@ -510,7 +510,7 @@ object CodeGenerationController {
510510
private fun waitForCountDown(latch: CountDownLatch, timeout: Long = 5, timeUnit: TimeUnit = TimeUnit.SECONDS, indicator : ProgressIndicator, action: Runnable) {
511511
try {
512512
if (!latch.await(timeout, timeUnit)) {
513-
run(THREAD_POOL, indicator) { waitForCountDown(latch, timeout, timeUnit, indicator, action) }
513+
run(THREAD_POOL, indicator, "Waiting for ${latch.count} sarif report(s) in a loop") { waitForCountDown(latch, timeout, timeUnit, indicator, action) }
514514
} else {
515515
action.run()
516516
}
@@ -633,7 +633,7 @@ object CodeGenerationController {
633633
val editor = CodeInsightUtil.positionCursorAtLBrace(testClass.project, filePointer.containingFile, testClass)
634634
//TODO: Use PsiDocumentManager.getInstance(model.project).getDocument(file)
635635
// if we don't want to open _all_ new files with tests in editor one-by-one
636-
run(THREAD_POOL, indicator) {
636+
run(THREAD_POOL, indicator, "Rendering test code") {
637637
val (generatedTestsCode, utilClassKind) = try {
638638
proc.render(
639639
testSetsId,
@@ -658,8 +658,8 @@ object CodeGenerationController {
658658
return@run
659659
}
660660
utilClassListener.onTestClassGenerated(utilClassKind)
661-
run(EDT_LATER, indicator) {
662-
run(WRITE_ACTION, indicator) {
661+
run(EDT_LATER, indicator, "Writing generation text to documents") {
662+
run(WRITE_ACTION, indicator, "Writing generation text to documents") {
663663
try {
664664
unblockDocument(testClass.project, editor.document)
665665
// TODO: JIRA:1246 - display warnings if we rewrite the file
@@ -679,9 +679,9 @@ object CodeGenerationController {
679679

680680
// reformatting before creating reports due to
681681
// SarifReport requires the final version of the generated tests code
682-
run(THREAD_POOL, indicator) {
682+
// run(THREAD_POOL, indicator, "Intention helper") {
683683
// IntentionHelper(model.project, editor, filePointer).applyIntentions()
684-
run(EDT_LATER, indicator) {
684+
run(EDT_LATER, indicator, "Tests reformatting") {
685685
try {
686686
runWriteCommandAction(filePointer.project, "UtBot tests reformatting", null, {
687687
reformat(model, filePointer, testClassUpdated)
@@ -709,7 +709,7 @@ object CodeGenerationController {
709709

710710
unblockDocument(testClassUpdated.project, editor.document)
711711
}
712-
}
712+
// }
713713
}
714714
}
715715
}

0 commit comments

Comments
 (0)