From 3c201ebea5d7420e8b6cfc46f25a449de0eda039 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Mon, 11 Sep 2023 18:03:41 +0300 Subject: [PATCH 01/43] Refactor utbot-intellij-python package names --- settings.gradle.kts | 6 ++--- utbot-intellij-python/build.gradle.kts | 24 +++++++------------ .../python/table/UtPyClassItem.java | 2 +- .../python/table/UtPyFunctionItem.java | 2 +- .../table/UtPyMemberSelectionTable.java | 2 +- .../python/table/UtPyTableItem.java | 2 +- .../{language => }/python/table/Utils.java | 2 +- .../python/IntellijRequirementsInstaller.kt | 2 +- .../python/PythonDialogProcessor.kt | 2 +- .../python/PythonDialogWindow.kt | 19 +++++++-------- .../python/PythonIntellijProcessor.kt | 3 ++- .../{language => }/python/PythonTestsModel.kt | 4 ++-- .../plugin/{language => }/python/Utils.kt | 8 +++---- .../language}/PythonLanguageAssistant.kt | 3 ++- .../settings/PythonTestFrameworkMapper.kt | 2 +- .../python/settings/Settings.kt | 4 ++-- utbot-ui-commons/build.gradle.kts | 1 - .../language/agnostic/LanguageAssistant.kt | 6 ++--- 18 files changed, 43 insertions(+), 51 deletions(-) rename utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/{language => }/python/table/UtPyClassItem.java (93%) rename utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/{language => }/python/table/UtPyFunctionItem.java (93%) rename utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/{language => }/python/table/UtPyMemberSelectionTable.java (99%) rename utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/{language => }/python/table/UtPyTableItem.java (82%) rename utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/{language => }/python/table/Utils.java (92%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/IntellijRequirementsInstaller.kt (98%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/PythonDialogProcessor.kt (99%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/PythonDialogWindow.kt (90%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/PythonIntellijProcessor.kt (96%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/PythonTestsModel.kt (93%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/Utils.kt (91%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language/python => python/language}/PythonLanguageAssistant.kt (98%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/settings/PythonTestFrameworkMapper.kt (95%) rename utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/{language => }/python/settings/Settings.kt (84%) diff --git a/settings.gradle.kts b/settings.gradle.kts index 3a54a76c59..61438d6336 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -60,6 +60,8 @@ include("utbot-spring-framework") include("utbot-spring-commons-api") include("utbot-spring-commons") include("utbot-spring-analyzer") +include("utbot-spring-sample") +include("utbot-spring-test") if (pythonIde.split(",").contains(ideType)) { include("utbot-python") @@ -70,9 +72,6 @@ if (pythonIde.split(",").contains(ideType)) { include("utbot-python-executor") } -include("utbot-spring-sample") -include("utbot-spring-test") - if (projectType == ultimateEdition) { if (jsBuild == buildType || jsIde.split(",").contains(ideType)) { include("utbot-js") @@ -88,3 +87,4 @@ if (projectType == ultimateEdition) { } include("utbot-light") +include("utbot-intellij-java") diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index bf7d404342..fd68099af8 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -43,13 +43,14 @@ dependencies { } intellij { - - val androidPlugins = listOf("org.jetbrains.android") - val jvmPlugins = listOf( "java" ) + val kotlinPlugins = mutableListOf( + "org.jetbrains.kotlin" + ) + val pythonCommunityPlugins = listOf( "PythonCore:${pythonCommunityPluginVersion}" ) @@ -58,24 +59,17 @@ intellij { "Pythonid:${pythonUltimatePluginVersion}" ) - val jsPlugins = listOf( - "JavaScript" - ) - - val goPlugins = listOf( - "org.jetbrains.plugins.go:${goPluginVersion}" - ) - plugins.set( when (ideType) { - "IC" -> jvmPlugins + pythonCommunityPlugins + androidPlugins - "IU" -> jvmPlugins + pythonUltimatePlugins + jsPlugins + goPlugins + androidPlugins - "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? + "IC" -> jvmPlugins + kotlinPlugins + pythonCommunityPlugins + "IU" -> jvmPlugins + kotlinPlugins + pythonUltimatePlugins + "PC" -> jvmPlugins + kotlinPlugins + pythonCommunityPlugins + "PY" -> jvmPlugins + kotlinPlugins + pythonUltimatePlugins // something else, JS? else -> jvmPlugins } ) version.set(ideVersion) type.set(ideType) + SettingsTemplateHelper.proceed(project) } \ No newline at end of file diff --git a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyClassItem.java b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyClassItem.java similarity index 93% rename from utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyClassItem.java rename to utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyClassItem.java index 5752c563f0..f49036a20a 100644 --- a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyClassItem.java +++ b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyClassItem.java @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python.table; +package org.utbot.intellij.plugin.python.table; import com.intellij.icons.AllIcons; import com.jetbrains.python.psi.PyClass; diff --git a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyFunctionItem.java b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyFunctionItem.java similarity index 93% rename from utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyFunctionItem.java rename to utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyFunctionItem.java index d3c9fdf512..b5564512e7 100644 --- a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyFunctionItem.java +++ b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyFunctionItem.java @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python.table; +package org.utbot.intellij.plugin.python.table; import com.intellij.icons.AllIcons; import com.jetbrains.python.psi.PyElement; diff --git a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyMemberSelectionTable.java b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyMemberSelectionTable.java similarity index 99% rename from utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyMemberSelectionTable.java rename to utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyMemberSelectionTable.java index f11d7a606a..26233b9dfe 100644 --- a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyMemberSelectionTable.java +++ b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyMemberSelectionTable.java @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python.table; +package org.utbot.intellij.plugin.python.table; import com.intellij.openapi.actionSystem.BackgroundableDataProvider; import com.intellij.openapi.actionSystem.CommonDataKeys; diff --git a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyTableItem.java b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyTableItem.java similarity index 82% rename from utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyTableItem.java rename to utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyTableItem.java index 9d3da4e6f1..c1e413016a 100644 --- a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/UtPyTableItem.java +++ b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/UtPyTableItem.java @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python.table; +package org.utbot.intellij.plugin.python.table; import com.jetbrains.python.psi.PyElement; diff --git a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/Utils.java b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/Utils.java similarity index 92% rename from utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/Utils.java rename to utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/Utils.java index 7667a77c50..0f23b1ba4c 100644 --- a/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/language/python/table/Utils.java +++ b/utbot-intellij-python/src/main/java/org/utbot/intellij/plugin/python/table/Utils.java @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python.table; +package org.utbot.intellij.plugin.python.table; import java.util.HashSet; import java.util.List; diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/IntellijRequirementsInstaller.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/IntellijRequirementsInstaller.kt similarity index 98% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/IntellijRequirementsInstaller.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/IntellijRequirementsInstaller.kt index 2bea00fc73..08aa8110db 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/IntellijRequirementsInstaller.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/IntellijRequirementsInstaller.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python +package org.utbot.intellij.plugin.python import com.intellij.notification.NotificationType import com.intellij.openapi.application.invokeLater diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt similarity index 99% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt index b94ac87779..c1474a9ef8 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python +package org.utbot.intellij.plugin.python import com.intellij.openapi.application.ReadAction import com.intellij.openapi.application.invokeLater diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogWindow.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogWindow.kt similarity index 90% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogWindow.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogWindow.kt index e675499ac7..550ab70748 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogWindow.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogWindow.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python +package org.utbot.intellij.plugin.python import com.intellij.openapi.components.service import com.intellij.openapi.ui.ComboBox @@ -16,19 +16,16 @@ import com.jetbrains.python.psi.PyClass import com.jetbrains.python.psi.PyFunction import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.codegen.domain.TestFramework -import org.utbot.intellij.plugin.language.python.settings.PythonTestFrameworkMapper -import org.utbot.intellij.plugin.language.python.settings.loadStateFromModel -import org.utbot.intellij.plugin.language.python.table.UtPyClassItem -import org.utbot.intellij.plugin.language.python.table.UtPyFunctionItem -import org.utbot.intellij.plugin.language.python.table.UtPyMemberSelectionTable -import org.utbot.intellij.plugin.language.python.table.UtPyTableItem +import org.utbot.intellij.plugin.python.settings.PythonTestFrameworkMapper +import org.utbot.intellij.plugin.python.settings.loadStateFromModel +import org.utbot.intellij.plugin.python.table.UtPyClassItem +import org.utbot.intellij.plugin.python.table.UtPyFunctionItem +import org.utbot.intellij.plugin.python.table.UtPyMemberSelectionTable +import org.utbot.intellij.plugin.python.table.UtPyTableItem import org.utbot.intellij.plugin.settings.Settings import org.utbot.intellij.plugin.ui.components.TestSourceDirectoryChooser import org.utbot.intellij.plugin.ui.utils.createTestFrameworksRenderer -import java.awt.event.ActionEvent import java.util.concurrent.TimeUnit -import javax.swing.AbstractAction -import javax.swing.Action import javax.swing.DefaultComboBoxModel import javax.swing.JComponent @@ -113,7 +110,7 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj val functionItems = functions .groupBy { it.containingClass } .flatMap { (_, pyFuncs) -> - pyFuncs.map {UtPyFunctionItem(it)} + pyFuncs.map { UtPyFunctionItem(it) } } val classItems = classes.map { UtPyClassItem(it) diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonIntellijProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt similarity index 96% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonIntellijProcessor.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt index 89f2c498ec..29a8c20e65 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonIntellijProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python +package org.utbot.intellij.plugin.python import com.intellij.codeInsight.CodeInsightUtil import com.intellij.openapi.application.invokeLater @@ -7,6 +7,7 @@ import com.intellij.openapi.project.Project import com.intellij.psi.PsiDirectory import com.intellij.psi.PsiFileFactory import com.jetbrains.python.psi.PyClass +import org.utbot.intellij.plugin.python.language.PythonLanguageAssistant import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater import org.utbot.python.PythonTestGenerationConfig import org.utbot.python.PythonTestGenerationProcessor diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonTestsModel.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonTestsModel.kt similarity index 93% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonTestsModel.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonTestsModel.kt index f0d4ff007f..1153ee7e08 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonTestsModel.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonTestsModel.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python +package org.utbot.intellij.plugin.python import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project @@ -8,7 +8,7 @@ import com.jetbrains.python.psi.PyFile import org.utbot.framework.codegen.domain.RuntimeExceptionTestsBehaviour import org.utbot.framework.codegen.domain.TestFramework import org.utbot.framework.codegen.services.language.CgLanguageAssistant -import org.utbot.intellij.plugin.language.python.table.UtPyTableItem +import org.utbot.intellij.plugin.python.table.UtPyTableItem import org.utbot.intellij.plugin.models.BaseTestsModel class PythonTestsModel( diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/Utils.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/Utils.kt similarity index 91% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/Utils.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/Utils.kt index e8b285afc6..783126ffcc 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/Utils.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/Utils.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python +package org.utbot.intellij.plugin.python import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ProjectFileIndex @@ -9,9 +9,9 @@ import com.intellij.psi.PsiElement import com.jetbrains.python.psi.PyClass import com.jetbrains.python.psi.PyElement import com.jetbrains.python.psi.PyFunction -import org.utbot.intellij.plugin.language.python.table.UtPyClassItem -import org.utbot.intellij.plugin.language.python.table.UtPyFunctionItem -import org.utbot.intellij.plugin.language.python.table.UtPyTableItem +import org.utbot.intellij.plugin.python.table.UtPyClassItem +import org.utbot.intellij.plugin.python.table.UtPyFunctionItem +import org.utbot.intellij.plugin.python.table.UtPyTableItem import org.utbot.python.utils.RequirementsUtils import kotlin.random.Random diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonLanguageAssistant.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt similarity index 98% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonLanguageAssistant.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt index 84d304a8f4..4edaf85e23 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonLanguageAssistant.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python +package org.utbot.intellij.plugin.python.language import com.intellij.lang.Language import com.intellij.openapi.actionSystem.AnActionEvent @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.idea.core.util.toPsiDirectory import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.utbot.framework.plugin.api.util.LockFile import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant +import org.utbot.intellij.plugin.python.* object PythonLanguageAssistant : LanguageAssistant() { diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/settings/PythonTestFrameworkMapper.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/settings/PythonTestFrameworkMapper.kt similarity index 95% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/settings/PythonTestFrameworkMapper.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/settings/PythonTestFrameworkMapper.kt index 57d8383441..0e2b60ac75 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/settings/PythonTestFrameworkMapper.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/settings/PythonTestFrameworkMapper.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.python.settings +package org.utbot.intellij.plugin.python.settings import org.utbot.framework.codegen.domain.TestFramework import org.utbot.intellij.plugin.settings.TestFrameworkMapper diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/settings/Settings.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/settings/Settings.kt similarity index 84% rename from utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/settings/Settings.kt rename to utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/settings/Settings.kt index 5c46f4d53b..a61dfcb5f7 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/settings/Settings.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/settings/Settings.kt @@ -1,7 +1,7 @@ -package org.utbot.intellij.plugin.language.python.settings +package org.utbot.intellij.plugin.python.settings import org.utbot.framework.codegen.domain.HangingTestsTimeout -import org.utbot.intellij.plugin.language.python.PythonTestsModel +import org.utbot.intellij.plugin.python.PythonTestsModel import org.utbot.intellij.plugin.settings.Settings fun loadStateFromModel(settings: Settings, model: PythonTestsModel) { diff --git a/utbot-ui-commons/build.gradle.kts b/utbot-ui-commons/build.gradle.kts index 76e484069e..608d02e918 100644 --- a/utbot-ui-commons/build.gradle.kts +++ b/utbot-ui-commons/build.gradle.kts @@ -37,7 +37,6 @@ tasks { runIde { jvmArgs("-Xmx2048m") jvmArgs("--add-exports", "java.desktop/sun.awt.windows=ALL-UNNAMED") - androidStudioPath?.let { ideDir.set(file(it)) } } patchPluginXml { diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt index 87d7314ee4..2e383a36c7 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt @@ -97,9 +97,9 @@ abstract class LanguageAssistant { private fun loadWithException(language: Language): Class<*>? { try { return when (language.id) { - "Python" -> Class.forName("org.utbot.intellij.plugin.language.python.PythonLanguageAssistant") - "ECMAScript 6" -> Class.forName("org.utbot.intellij.plugin.language.js.JsLanguageAssistant") - "go" -> Class.forName("org.utbot.intellij.plugin.language.go.GoLanguageAssistant") + "Python" -> Class.forName("org.utbot.intellij.plugin.python.language.PythonLanguageAssistant") + "ECMAScript 6" -> Class.forName("org.utbot.intellij.plugin.js.language.JsLanguageAssistant") + "go" -> Class.forName("org.utbot.intellij.plugin.go.language.GoLanguageAssistant") "JAVA", "kotlin" -> Class.forName("org.utbot.intellij.plugin.language.JvmLanguageAssistant") else -> error("Unknown language id: ${language.id}") } From 8119ae3aff793954d092aeab1c8ed6548d26c04d Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 13 Sep 2023 14:54:51 +0300 Subject: [PATCH 02/43] First version for pycharm --- gradle.properties | 5 +- settings.gradle.kts | 6 +- utbot-intellij-main/build.gradle.kts | 210 ++++++ .../plugin/ui/actions/GenerateTestsAction.kt | 0 .../src/main/resources/META-INF/plugin.xml | 99 +++ .../main/resources/META-INF/pluginIcon.svg | 4 + .../main/resources/META-INF/withAndroid.xml | 3 + .../src/main/resources/META-INF/withGo.xml | 3 + .../main/resources/META-INF/withIdeaMaven.xml | 3 + .../src/main/resources/META-INF/withJS.xml | 4 + .../src/main/resources/META-INF/withJava.xml | 3 + .../main/resources/META-INF/withKotlin.xml | 3 + .../src/main/resources/META-INF/withLang.xml | 3 + .../main/resources/META-INF/withPython.xml | 4 + .../src/main/resources/application.properties | 5 + .../resources/bundles/UtbotBundle.properties | 10 + .../UnitTestBotInspectionTool.html | 11 + .../src/main/resources/log4j2.xml | 34 + .../src/main/resources/settings.properties | 596 ++++++++++++++++++ utbot-intellij-python/build.gradle.kts | 4 +- .../plugin/python/PythonDialogProcessor.kt | 19 +- .../plugin/python/PythonIntellijProcessor.kt | 4 +- .../plugin/python/PythonTestsModel.kt | 5 - .../language/PythonLanguageAssistant.kt | 8 +- utbot-intellij/build.gradle.kts | 2 + .../generator/CodeGenerationController.kt | 4 - .../plugin/models/GenerateTestsModel.kt | 173 ++++- .../TestFolderComboWithBrowseButton.kt | 15 +- .../intellij/plugin/ui/utils/ModuleUtils.kt | 2 +- .../intellij/plugin/ui/utils/RootUtils.kt | 0 .../intellij/plugin/util/PsiClassHelper.kt | 0 .../kotlin/org/utbot/tests}/RootUtilsTest.kt | 6 +- utbot-python/samples/my_cov.json | 1 + utbot-ui-commons/build.gradle.kts | 4 +- .../language/agnostic/LanguageAssistant.kt | 21 +- .../intellij/plugin/models/BaseTestModel.kt | 180 ------ .../intellij/plugin/settings/Configurable.kt | 0 .../plugin/settings/MockAlwaysClassesTable.kt | 13 +- .../plugin/settings/SettingsWindow.kt | 0 39 files changed, 1227 insertions(+), 240 deletions(-) create mode 100644 utbot-intellij-main/build.gradle.kts rename {utbot-intellij => utbot-intellij-main}/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt (100%) create mode 100644 utbot-intellij-main/src/main/resources/META-INF/plugin.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/pluginIcon.svg create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withAndroid.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withGo.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withIdeaMaven.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withJS.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withJava.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withKotlin.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withLang.xml create mode 100644 utbot-intellij-main/src/main/resources/META-INF/withPython.xml create mode 100644 utbot-intellij-main/src/main/resources/application.properties create mode 100644 utbot-intellij-main/src/main/resources/bundles/UtbotBundle.properties create mode 100644 utbot-intellij-main/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html create mode 100644 utbot-intellij-main/src/main/resources/log4j2.xml create mode 100644 utbot-intellij-main/src/main/resources/settings.properties rename {utbot-ui-commons => utbot-intellij}/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt (94%) rename {utbot-ui-commons => utbot-intellij}/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt (99%) rename {utbot-ui-commons => utbot-intellij}/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtils.kt (100%) rename {utbot-ui-commons => utbot-intellij}/src/main/kotlin/org/utbot/intellij/plugin/util/PsiClassHelper.kt (100%) rename {utbot-ui-commons/src/test/kotlin/org/utbot/intellij/plugin/ui/utils => utbot-intellij/src/test/kotlin/org/utbot/tests}/RootUtilsTest.kt (93%) create mode 100644 utbot-python/samples/my_cov.json rename {utbot-intellij => utbot-ui-commons}/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt (100%) rename {utbot-intellij => utbot-ui-commons}/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt (91%) rename {utbot-intellij => utbot-ui-commons}/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt (100%) diff --git a/gradle.properties b/gradle.properties index 00719b83c7..8dbfdc04be 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,8 +10,9 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio -ideType=IC -ideVersion=232.8660.185 +ideType=PC +#ideVersion=232.8660.185 +ideVersion=2023.2 # ALL, NOJS buildType=NOJS diff --git a/settings.gradle.kts b/settings.gradle.kts index 61438d6336..d53c4450ea 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,7 +27,9 @@ include("utbot-core") include("utbot-framework") include("utbot-framework-api") include("utbot-modificators-analyzer") -include("utbot-intellij") +if (ideType != "PC") { + include("utbot-intellij") +} include("utbot-sample") include("utbot-java-fuzzing") include("utbot-fuzzing") @@ -87,4 +89,4 @@ if (projectType == ultimateEdition) { } include("utbot-light") -include("utbot-intellij-java") +include("utbot-intellij-main") diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts new file mode 100644 index 0000000000..a6141ac019 --- /dev/null +++ b/utbot-intellij-main/build.gradle.kts @@ -0,0 +1,210 @@ +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject + +val intellijPluginVersion: String? by rootProject +val kotlinLoggingVersion: String? by rootProject +val apacheCommonsTextVersion: String? by rootProject +val jacksonVersion: String? by rootProject + +val ideType: String? by rootProject +val ideVersion: String? by rootProject +val pythonCommunityPluginVersion: String? by rootProject +val pythonUltimatePluginVersion: String? by rootProject +val goPluginVersion: String? by rootProject + +val pythonIde: String? by rootProject +val jsIde: String? by rootProject +val goIde: String? by rootProject + +val sootVersion: String? by rootProject +val kryoVersion: String? by rootProject +val rdVersion: String? by rootProject +val semVer: String? by rootProject +val androidStudioPath: String? by rootProject + +val junit5Version: String by rootProject +val junit4PlatformVersion: String by rootProject + +// https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file +val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" + +//project.tasks.asMap["runIde"]?.enabled = false + +plugins { + id("org.jetbrains.intellij") version "1.13.1" +} + +intellij { + + val androidPlugins = listOf("org.jetbrains.android") + + val jvmPlugins = mutableListOf( + "java" + ) + + val kotlinPlugins = mutableListOf( + "org.jetbrains.kotlin" + ) + + androidStudioPath?.let { jvmPlugins += androidPlugins } + + val pythonCommunityPlugins = listOf( + "PythonCore:${pythonCommunityPluginVersion}" + ) + + val pythonUltimatePlugins = listOf( + "Pythonid:${pythonUltimatePluginVersion}" + ) + + val jsPlugins = listOf( + "JavaScript" + ) + + val goPlugins = listOf( + "org.jetbrains.plugins.go:${goPluginVersion}" + ) + + val mavenUtilsPlugins = listOf( + "org.jetbrains.idea.maven" + ) + + val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins + + plugins.set( + when (projectType) { + communityEdition -> basePluginSet + pythonCommunityPlugins + ultimateEdition -> when (ideType) { + "IC" -> basePluginSet + pythonCommunityPlugins + "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins // something else, JS? + else -> basePluginSet + } + else -> basePluginSet + } + ) + + version.set(ideVersion) + type.set(ideTypeOrAndroidStudio) + SettingsTemplateHelper.proceed(project) +} + +val remoteRobotVersion = "0.11.16" + +tasks { + compileKotlin { + kotlinOptions { + jvmTarget = "17" + freeCompilerArgs = freeCompilerArgs + listOf("-Xallow-result-return-type", "-Xsam-conversions=class") + allWarningsAsErrors = false + } + } + + java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + runIde { + jvmArgs("-Xmx2048m") + jvmArgs("--add-exports", "java.desktop/sun.awt.windows=ALL-UNNAMED") + androidStudioPath?.let { ideDir.set(file(it)) } + } + + patchPluginXml { + sinceBuild.set("223") + untilBuild.set("232.*") + version.set(semVer) + } + + runIdeForUiTests { + jvmArgs("-Xmx2048m", "-Didea.is.internal=true", "-Didea.ui.debug.mode=true") + + systemProperty("robot-server.port", "8082") // default port 8580 + systemProperty("ide.mac.message.dialogs.as.sheets", "false") + systemProperty("jb.privacy.policy.text", "") + systemProperty("jb.consents.confirmation.enabled", "false") + systemProperty("idea.trust.all.projects", "true") + systemProperty("ide.mac.file.chooser.native", "false") + systemProperty("jbScreenMenuBar.enabled", "false") + systemProperty("apple.laf.useScreenMenuBar", "false") + systemProperty("ide.show.tips.on.startup.default.value", "false") + } + + downloadRobotServerPlugin { + version.set(remoteRobotVersion) + } + + test { + description = "Runs UI integration tests." + useJUnitPlatform { + exclude("/org/utbot/**") //Comment this line to run the tests locally + } + } +} + +repositories { + maven("https://jitpack.io") + maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") +} + +dependencies { + implementation(group ="com.jetbrains.rd", name = "rd-framework", version = rdVersion) + implementation(group ="com.jetbrains.rd", name = "rd-core", version = rdVersion) + implementation(group ="com.esotericsoftware.kryo", name = "kryo5", version = kryoVersion) + implementation(group = "io.github.microutils", name = "kotlin-logging", version = kotlinLoggingVersion) + implementation(group = "org.apache.commons", name = "commons-text", version = apacheCommonsTextVersion) + implementation("org.apache.httpcomponents.client5:httpclient5:5.1") + implementation(group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin", version = jacksonVersion) + + implementation(project(":utbot-framework")) { exclude(group = "org.slf4j", module = "slf4j-api") } + implementation(project(":utbot-spring-framework")) { exclude(group = "org.slf4j", module = "slf4j-api") } + implementation(project(":utbot-java-fuzzing")) + //api(project(":utbot-analytics")) + testImplementation("org.mock-server:mockserver-netty:5.4.1") + testApi(project(":utbot-framework")) + + implementation(project(":utbot-ui-commons")) + + //Family + + if (ideType != "PC") { + implementation(project(":utbot-intellij")) + } + + if (pythonIde?.split(',')?.contains(ideType) == true) { + api(project(":utbot-python")) + api(project(":utbot-intellij-python")) + } + + if (projectType == ultimateEdition) { + if (jsIde?.split(',')?.contains(ideType) == true) { + implementation(project(":utbot-js")) + implementation(project(":utbot-intellij-js")) + } + + if (goIde?.split(',')?.contains(ideType) == true) { + implementation(project(":utbot-go")) + implementation(project(":utbot-intellij-go")) + } + } + + implementation(project(":utbot-android-studio")) + + testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion") + testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion") + + testImplementation("org.assertj:assertj-core:3.11.1") + + // Logging Network Calls + testImplementation("com.squareup.okhttp3:logging-interceptor:4.10.0") + + // Video Recording + implementation("com.automation-remarks:video-recorder-junit5:2.0") + + testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version") + testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junit4PlatformVersion") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit5Version") + testRuntimeOnly("org.junit.vintage:junit-vintage-engine:$junit5Version") +} diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt b/utbot-intellij-main/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt similarity index 100% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt rename to utbot-intellij-main/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt diff --git a/utbot-intellij-main/src/main/resources/META-INF/plugin.xml b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml new file mode 100644 index 0000000000..1b3bbf6242 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml @@ -0,0 +1,99 @@ + + + + org.utbot.intellij.plugin.id + UnitTestBot + utbot.org + com.intellij.modules.platform + + com.intellij.modules.java + org.jetbrains.kotlin + com.intellij.modules.python + org.jetbrains.plugins.go + org.jetbrains.android + org.jetbrains.idea.maven + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Discover UnitTestBot key features in our latest release: +
    +
  • generating ready-to-use test cases — with valid inputs, method bodies, assertions, and comments
  • +
  • maximizing branch coverage in regression suite while keeping the number of tests minimized
  • +
  • finding deeply hidden code defects and expressing them as tests
  • +
  • fine-tuned mocking, including mocking static methods
  • +
  • representing all the test descriptions in a human-readable format
  • +
  • generating SARIF reports
  • +
  • innovative symbolic execution engine combined with a smart fuzzing platform
  • +
+ UnitTestBot supports the latest JDKs, JUnit 4, JUnit 5, TestNG, Mockito and is suitable for all popular operational systems. +
+ Try UnitTestBot online demo to see how it generates tests for your code in real time. +
+ Contribute to UnitTestBot via GitHub. +
+ Found a bug? File an issue. +
+ Have an idea? Start a discussion. + ]]> +
+ + +
  • Generating tests for Python and JavaScript
  • +
  • New fuzzing platform providing support for multiple languages
  • +
  • Improved test generation for Kotlin code
  • +
  • Multiprocess architecture based on the Reactive Distributed communication framework with advanced logging and debugging options
  • +
  • Symbolic execution engine with higher priority and fewer false UNSAT verdicts
  • +
  • UI/UX improvements for test sources root, setting.properties file, cancellation, timeout settings, notifications
  • +
  • Summaries with fine-grained settings
  • +
  • SARIF reports enabled by default, displaying sandbox-related and timeout test failures, properly addressing source files
  • +
  • Improved monitoring visualized with Grafana
  • +
  • Test generation bug fixes
  • +
  • Detailed documentation on UnitTestBot components including UnitTestBot architecture overview
  • + + ]]> +
    + + + + + + + + + + + +
    diff --git a/utbot-intellij-main/src/main/resources/META-INF/pluginIcon.svg b/utbot-intellij-main/src/main/resources/META-INF/pluginIcon.svg new file mode 100644 index 0000000000..d24574d6dd --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/pluginIcon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/META-INF/withAndroid.xml b/utbot-intellij-main/src/main/resources/META-INF/withAndroid.xml new file mode 100644 index 0000000000..09ce48b452 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withAndroid.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/META-INF/withGo.xml b/utbot-intellij-main/src/main/resources/META-INF/withGo.xml new file mode 100644 index 0000000000..65c848f900 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withGo.xml @@ -0,0 +1,3 @@ + + + diff --git a/utbot-intellij-main/src/main/resources/META-INF/withIdeaMaven.xml b/utbot-intellij-main/src/main/resources/META-INF/withIdeaMaven.xml new file mode 100644 index 0000000000..5c2f872b51 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withIdeaMaven.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/META-INF/withJS.xml b/utbot-intellij-main/src/main/resources/META-INF/withJS.xml new file mode 100644 index 0000000000..d04570b311 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withJS.xml @@ -0,0 +1,4 @@ + + + JavaScript + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/META-INF/withJava.xml b/utbot-intellij-main/src/main/resources/META-INF/withJava.xml new file mode 100644 index 0000000000..2ce2e82cc9 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withJava.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/META-INF/withKotlin.xml b/utbot-intellij-main/src/main/resources/META-INF/withKotlin.xml new file mode 100644 index 0000000000..07e0e420c3 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withKotlin.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/META-INF/withLang.xml b/utbot-intellij-main/src/main/resources/META-INF/withLang.xml new file mode 100644 index 0000000000..ed33e791e3 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withLang.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/META-INF/withPython.xml b/utbot-intellij-main/src/main/resources/META-INF/withPython.xml new file mode 100644 index 0000000000..f272fd7601 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/META-INF/withPython.xml @@ -0,0 +1,4 @@ + + + com.intellij.modules.python + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/application.properties b/utbot-intellij-main/src/main/resources/application.properties new file mode 100644 index 0000000000..f5af5a168d --- /dev/null +++ b/utbot-intellij-main/src/main/resources/application.properties @@ -0,0 +1,5 @@ +# suppress inspection "HttpUrlsUsage" for whole file +backing.service.possibleEndpoints=http://utbot.org +backing.service.urlPath=/utbot/errors +backing.service.port=11000 +request.timeoutMillis=5000 \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/bundles/UtbotBundle.properties b/utbot-intellij-main/src/main/resources/bundles/UtbotBundle.properties new file mode 100644 index 0000000000..4c13064c79 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/bundles/UtbotBundle.properties @@ -0,0 +1,10 @@ +# {0} - Test report url prefix, {1] - suffix +test.report.force.mock.warning=Warning: Some test cases were ignored, because no mocking framework is installed in the project.
    \ +Better results could be achieved by installing mocking framework. +test.report.force.static.mock.warning=Warning: Some test cases were ignored, because mockito-inline is not installed in the project.
    \ +Better results could be achieved by configuring mockito-inline. +test.report.test.framework.warning=Warning: There are several test frameworks in the project.\ +To select run configuration, please refer to the documentation depending on the project build system:\ +Gradle, \ +Maven \ +or Idea. \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html b/utbot-intellij-main/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html new file mode 100644 index 0000000000..a01f16e673 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html @@ -0,0 +1,11 @@ + + +

    Reports unchecked exceptions detected by UnitTestBot.

    +

    Example:

    +
    +void foo(int a) {
    +    return 1 / a; // throws ArithmeticException when `a == 0`
    +}
    +
    + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/log4j2.xml b/utbot-intellij-main/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..6a9ae540c8 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/log4j2.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utbot-intellij-main/src/main/resources/settings.properties b/utbot-intellij-main/src/main/resources/settings.properties new file mode 100644 index 0000000000..29ce294664 --- /dev/null +++ b/utbot-intellij-main/src/main/resources/settings.properties @@ -0,0 +1,596 @@ +# Copyright (c) 2023 utbot.org +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Setting to disable coroutines debug explicitly. +# Set it to false if debug info is required. +# +# Default value is [true] +#disableCoroutinesDebug=true + +# +# Make `true` for interactive mode (like Intellij plugin). If `false` UTBot can apply certain optimizations. +# +# Default value is [true] +#classfilesCanChange=true + +# +# Timeout for Z3 solver.check calls. +# Set it to 0 to disable timeout. +# +# Default value is [1000] +#checkSolverTimeoutMillis=1000 + +# +# Timeout for symbolic execution +# +# Default value is [60000] +#utBotGenerationTimeoutInMillis=60000 + +# +# Random seed in path selector. +# Set null to disable random. +# +# Default value is [42] +#seedInPathSelector=42 + +# +# Type of path selector. +# +# COVERED_NEW_SELECTOR: [CoveredNewSelector] +# INHERITORS_SELECTOR: [InheritorsSelector] +# BFS_SELECTOR: [BFSSelector] +# SUBPATH_GUIDED_SELECTOR: [SubpathGuidedSelector] +# CPI_SELECTOR: [CPInstSelector] +# FORK_DEPTH_SELECTOR: [ForkDepthSelector] +# ML_SELECTOR: [MLSelector] +# TORCH_SELECTOR: [TorchSelector] +# RANDOM_SELECTOR: [RandomSelector] +# RANDOM_PATH_SELECTOR: [RandomPathSelector] +# +# Default value is [INHERITORS_SELECTOR] +#pathSelectorType=INHERITORS_SELECTOR + +# +# Type of MLSelector recalculation. +# +# WITH_RECALCULATION: [MLSelectorWithRecalculation] +# WITHOUT_RECALCULATION: [MLSelectorWithoutRecalculation] +# +# Default value is [WITHOUT_RECALCULATION] +#mlSelectorRecalculationType=WITHOUT_RECALCULATION + +# +# Type of [MLPredictor]. +# +# MLP: [MultilayerPerceptronPredictor] +# LINREG: [LinearRegressionPredictor] +# +# Default value is [MLP] +#mlPredictorType=MLP + +# +# Steps limit for path selector. +# +# Default value is [3500] +#pathSelectorStepsLimit=3500 + +# +# Determines whether path selector should save remaining states for concrete execution after stopping by strategy. +# False for all framework tests by default. +#saveRemainingStatesForConcreteExecution=true + +# +# Use debug visualization. +# Set it to true if debug visualization is needed. +# +# Default value is [false] +#useDebugVisualization=false + +# +# Set the value to true to show library classes' graphs in visualization. +# +# Default value is [false] +#showLibraryClassesInVisualization=false + +# +# Use simplification of UtExpressions. +# Set it to false to disable expression simplification. +# +# Default value is [true] +#useExpressionSimplification=true + +# +# Enable the Summarization module to generate summaries for methods under test. +# Note: if it is [SummariesGenerationType.NONE], +# all the execution for a particular method will be stored at the same nameless region. +# +# FULL: All possible analysis actions are taken +# LIGHT: Analysis actions based on sources are NOT taken +# NONE: No summaries are generated +# +# Default value is [FULL] +#summaryGenerationType=FULL + +# +# If True test comments will be generated. +# +# Default value is [true] +#enableJavaDocGeneration=true + +# +# If True cluster comments will be generated. +# +# Default value is [true] +#enableClusterCommentsGeneration=true + +# +# If True names for tests will be generated. +# +# Default value is [true] +#enableTestNamesGeneration=true + +# +# If True display names for tests will be generated. +# +# Default value is [true] +#enableDisplayNameGeneration=true + +# +# If True display name in from -> to style will be generated. +# +# Default value is [true] +#useDisplayNameArrowStyle=true + +# +# Generate summaries using plugin's custom JavaDoc tags. +# +# Default value is [true] +#useCustomJavaDocTags=true + +# +# This option regulates which [NullPointerException] check should be performed for nested methods. +# Set an option in true if you want to perform NPE check in the corresponding situations, otherwise set false. +# +# Default value is [true] +#checkNpeInNestedMethods=true + +# +# This option regulates which [NullPointerException] check should be performed for nested not private methods. +# Set an option in true if you want to perform NPE check in the corresponding situations, otherwise set false. +# +# Default value is [false] +#checkNpeInNestedNotPrivateMethods=false + +# +# This option determines whether we should generate [NullPointerException] checks for final or non-public fields +# in non-application classes. Set by true, this option highly decreases test's readability in some cases +# because of using reflection API for setting final/non-public fields in non-application classes. +# NOTE: With false value loses some executions with NPE in system classes, but often most of these executions +# are not expected by user. +# +# Default value is [false] +#maximizeCoverageUsingReflection=false + +# +# Activate or deactivate substituting static fields values set in static initializer +# with symbolic variable to try to set them another value than in initializer. +# +# Default value is [true] +#substituteStaticsWithSymbolicVariable=true + +# +# Use concrete execution. +# +# Default value is [true] +#useConcreteExecution=true + +# +# Enable code generation tests with every possible configuration +# for every method in samples. +# Important: is enabled generation requires enormous amount of time. +# +# Default value is [false] +#checkAllCombinationsForEveryTestInSamples=false + +# +# Enable transformation UtCompositeModels into UtAssembleModels using AssembleModelGenerator. +# Note: false doesn't mean that there will be no assemble models, it means that the generator will be turned off. +# Assemble models will present for lists, sets, etc. +# +# Default value is [true] +#useAssembleModelGenerator=true + +# +# Test related files from the temp directory that are older than [daysLimitForTempFiles] +# will be removed at the beginning of the test run. +# +# Default value is [3] +#daysLimitForTempFiles=3 + +# +# Enables soft constraints in the engine. +# +# Default value is [true] +#preferredCexOption=true + +# +# Type of test minimization strategy. +# +# DO_NOT_MINIMIZE_STRATEGY: Always adds new test +# COVERAGE_STRATEGY: Adds new test only if it increases coverage +# +# Default value is [COVERAGE_STRATEGY] +#testMinimizationStrategyType=COVERAGE_STRATEGY + +# +# Set to true to start fuzzing if symbolic execution haven't return anything +# +# Default value is [true] +#useFuzzing=true + +# +# Set the total attempts to improve coverage by fuzzer. +# +# Default value is [2147483647] +#fuzzingMaxAttempts=2147483647 + +# +# Fuzzer tries to generate and run tests during this time. +# +# Default value is [3000] +#fuzzingTimeoutInMillis=3000 + +# +# Find implementations of interfaces and abstract classes to fuzz. +# +# Default value is [true] +#fuzzingImplementationOfAbstractClasses=true + +# +# Use methods to mutate fields of classes different from class under test or not. +# +# Default value is [false] +#tryMutateOtherClassesFieldsWithMethods=false + +# +# Generate tests that treat possible overflows in arithmetic operations as errors +# that throw Arithmetic Exception. +# +# Default value is [false] +#treatOverflowAsError=false + +# +# Generate tests that treat assertions as error suits. +# +# Default value is [true] +#treatAssertAsErrorSuite=true + +# +# Instrument all classes before start +# +# Default value is [false] +#warmupConcreteExecution=false + +# +# Ignore string literals during the code analysis to make possible to analyze antlr. +# It is a hack and must be removed after the competition. +# +# Default value is [false] +#ignoreStringLiterals=false + +# +# Timeout for specific concrete execution (in milliseconds). +# +# Default value is [1000] +#concreteExecutionDefaultTimeoutInInstrumentedProcessMillis=1000 + +# +# Enable taint analysis or not. +# +# Default value is [false] +#useTaintAnalysis=false + +# +# Path to custom log4j2 configuration file for EngineProcess. +# By default utbot-intellij/src/main/resources/log4j2.xml is used. +# Also default value is used if provided value is not a file. +#engineProcessLogConfigFile="" + +# +# The property is useful only for the IntelliJ IDEs. +# If the property is set in true the engine process opens a debug port. +# @see runInstrumentedProcessWithDebug +# @see org.utbot.intellij.plugin.process.EngineProcess +# +# Default value is [false] +#runEngineProcessWithDebug=false + +# +# The engine process JDWP agent's port of the engine process. +# A debugger attaches to the port in order to debug the process. +# +# Default value is [5005] +#engineProcessDebugPort=5005 + +# +# Value of the suspend mode for the JDWP agent of the engine process. +# If the value is true, the engine process will suspend until a debugger attaches to it. +# +# Default value is [true] +#suspendEngineProcessExecutionInDebugMode=true + +# +# The property is useful only for the IntelliJ IDEs. +# If the property is set in true the spring analyzer process opens a debug port. +# @see runInstrumentedProcessWithDebug +# @see org.utbot.spring.process.SpringAnalyzerProcess +# +# Default value is [false] +#runSpringAnalyzerProcessWithDebug=false + +# +# The spring analyzer process JDWP agent's port. +# A debugger attaches to the port in order to debug the process. +# +# Default value is [5007] +#springAnalyzerProcessDebugPort=5007 + +# +# Value of the suspend mode for the JDWP agent of the spring analyzer process. +# If the value is true, the spring analyzer process will suspend until a debugger attaches to it. +# +# Default value is [true] +#suspendSpringAnalyzerProcessExecutionInDebugMode=true + +# +# The instrumented process JDWP agent's port of the instrumented process. +# A debugger attaches to the port in order to debug the process. +# +# Default value is [5006] +#instrumentedProcessDebugPort=5006 + +# +# Value of the suspend mode for the JDWP agent of the instrumented process. +# If the value is true, the instrumented process will suspend until a debugger attaches to it. +# +# Default value is [true] +#suspendInstrumentedProcessExecutionInDebugMode=true + +# +# If true, runs the instrumented process with the ability to attach a debugger. +# To debug the instrumented process, set the breakpoint in the +# [org.utbot.instrumentation.rd.InstrumentedProcess.Companion.invoke] +# and in the instrumented process's main function and run the main process. +# Then run the remote JVM debug configuration in IDEA. +# If you see the message in console about successful connection, then +# the debugger is attached successfully. +# Now you can put the breakpoints in the instrumented process and debug +# both processes simultaneously. +# @see [org.utbot.instrumentation.rd.InstrumentedProcess.Companion.invoke] +# +# Default value is [false] +#runInstrumentedProcessWithDebug=false + +# +# Number of branch instructions using for clustering executions in the test minimization phase. +# +# Default value is [4] +#numberOfBranchInstructionsForClustering=4 + +# +# Determines should we choose only one crash execution with "minimal" model or keep all. +# +# Default value is [true] +#minimizeCrashExecutions=true + +# +# Enable it to calculate unsat cores for hard constraints as well. +# It may be usefull during debug. +# Note: it might highly impact performance, so do not enable it in release mode. +# +# Default value is [false] +#enableUnsatCoreCalculationForHardConstraints=false + +# +# Enable it to process states with unknown solver status +# from the queue to concrete execution. +# +# Default value is [true] +#processUnknownStatesDuringConcreteExecution=true + +# +# 2^{this} will be the length of observed subpath. +# See [SubpathGuidedSelector] +# +# Default value is [1] +#subpathGuidedSelectorIndex=1 + +# +# Flag that indicates whether feature processing for execution states enabled or not +# +# Default value is [false] +#enableFeatureProcess=false + +# +# Path to deserialized ML models +# +# Default value is [../models/0] +#modelPath=../models/0 + +# +# Full class name of the class containing the configuration for the ML models to solve path selection task. +# +# Default value is [org.utbot.AnalyticsConfiguration] +#analyticsConfigurationClassPath=org.utbot.AnalyticsConfiguration + +# +# Full class name of the class containing the configuration for the ML models exported from the PyTorch to solve path selection task. +# +# Default value is [org.utbot.AnalyticsTorchConfiguration] +#analyticsTorchConfigurationClassPath=org.utbot.AnalyticsTorchConfiguration + +# +# Number of model iterations that will be used during ContestEstimator +# +# Default value is [1] +#iterations=1 + +# +# Path for state features dir +# +# Default value is [eval/secondFeatures/antlr/INHERITORS_SELECTOR] +#featurePath=eval/secondFeatures/antlr/INHERITORS_SELECTOR + +# +# Counter for tests during testGeneration for one project in ContestEstimator +# +# Default value is [0] +#testCounter=0 + +# +# Flag that indicates whether tests for synthetic (see [Executable.isSynthetic]) and implicitly declared methods (like values, valueOf in enums) should be generated, or not +# +# Default value is [true] +#skipTestGenerationForSyntheticAndImplicitlyDeclaredMethods=true + +# +# Flag that indicates whether should we branch on and set static fields from trusted libraries or not. +# @see [org.utbot.common.WorkaroundReason.IGNORE_STATICS_FROM_TRUSTED_LIBRARIES] +# +# Default value is [true] +#ignoreStaticsFromTrustedLibraries=true + +# +# Use the sandbox in the instrumented process. +# If true, the sandbox will prevent potentially dangerous calls, e.g., file access, reading +# or modifying the environment, calls to `Unsafe` methods etc. +# If false, all these operations will be enabled and may lead to data loss during code analysis +# and test generation. +# +# Default value is [true] +#useSandbox=true + +# +# Transform bytecode in the instrumented process. +# If true, bytecode transformation will help fuzzing to find interesting input data, but the size of bytecode can increase. +# If false, bytecode won`t be changed. +# +# Default value is [false] +#useBytecodeTransformation=false + +# +# Limit for number of generated tests per method (in each region) +# +# Default value is [50] +#maxTestsPerMethodInRegion=50 + +# +# Max file length for generated test file +# +# Default value is [1000000] +#maxTestFileSize=1000000 + +# +# If this options set in true, all soot classes will be removed from a Soot Scene, +# therefore, you will be unable to test soot classes. +# +# Default value is [true] +#removeSootClassesFromHierarchy=true + +# +# If this options set in true, all UtBot classes will be removed from a Soot Scene, +# therefore, you will be unable to test UtBot classes. +# +# Default value is [true] +#removeUtBotClassesFromHierarchy=true + +# +# Use this option to enable calculation and logging of MD5 for dropped states by statistics. +# Example of such logging: +# Dropping state (lastStatus=UNDEFINED) by the distance statistics. MD5: 5d0bccc242e87d53578ca0ef64aa5864 +# +# Default value is [false] +#enableLoggingForDroppedStates=false + +# +# If this option set in true, depending on the number of possible types for +# a particular object will be used either type system based on conjunction +# or on bit vectors. +# @see useBitVecBasedTypeSystem +# +# Default value is [true] +#useBitVecBasedTypeSystem=true + +# +# The number of types on which the choice of the type system depends. +# +# Default value is [64] +#maxTypeNumberForEnumeration=64 + +# +# The threshold for numbers of types for which they will be encoded into solver. +# It is used to do not encode big type storages due to significand performance degradation. +# +# Default value is [512] +#maxNumberOfTypesToEncode=512 + +# +# The behaviour of further analysis if tests generation cancellation is requested. +# +# NONE: Do not react on cancellation +# CANCEL_EVERYTHING: Clear all generated test classes +# SAVE_PROCESSED_RESULTS: Show already processed test classes +# +# Default value is [SAVE_PROCESSED_RESULTS] +#cancellationStrategyType=SAVE_PROCESSED_RESULTS + +# +# Depending on this option, sections might be analyzed or not. +# Note that some clinit sections still will be initialized using runtime information. +# +# Default value is [true] +#enableClinitSectionsAnalysis=true + +# +# Process all clinit sections concretely. +# If [enableClinitSectionsAnalysis] is false, it disables effect of this option as well. +# Note that values processed concretely won't be replaced with unbounded symbolic variables. +# +# Default value is [false] +#processAllClinitSectionsConcretely=false + +# +# In cases where we don't have a body for a method, we can either throw an exception +# or treat this a method as a source of an unbounded symbolic variable returned as a result. +# If this option is set in true, instead of analysis we will return an unbounded symbolic +# variable with a corresponding type. Otherwise, an exception will be thrown. +# Default value is false since it is not a common situation when you cannot retrieve a body +# from a regular method. Setting this option in true might be suitable in situations when +# it is more important not to fall at all rather than work precisely. +#treatAbsentMethodsAsUnboundedValue=false + +# +# A maximum size for any array in the program. Note that input arrays might be less than this value +# due to the symbolic engine limitation, see `org.utbot.engine.Traverser.softMaxArraySize`. +# +# Default value is [1024] +#maxArraySize=1024 + +# +# A maximum size for any array in the program. Note that input arrays might be less than this value +# due to the symbolic engine limitation, see `org.utbot.engine.Traverser.softMaxArraySize`. +# +# Default value is [false] +#disableUnsatChecking=false diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index fd68099af8..0d370e78ac 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -63,8 +63,8 @@ intellij { when (ideType) { "IC" -> jvmPlugins + kotlinPlugins + pythonCommunityPlugins "IU" -> jvmPlugins + kotlinPlugins + pythonUltimatePlugins - "PC" -> jvmPlugins + kotlinPlugins + pythonCommunityPlugins - "PY" -> jvmPlugins + kotlinPlugins + pythonUltimatePlugins // something else, JS? + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins // something else, JS? else -> jvmPlugins } ) diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt index c1474a9ef8..7d633ef1e1 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleUtilCore +import com.intellij.openapi.module.impl.ModuleImpl import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.Task.Backgroundable @@ -24,14 +25,14 @@ import com.jetbrains.python.psi.PyElement import com.jetbrains.python.psi.PyFile import com.jetbrains.python.psi.PyFunction import com.jetbrains.python.psi.resolve.QualifiedNameFinder +import com.jetbrains.python.sdk.pythonSdk import mu.KotlinLogging -import org.jetbrains.kotlin.idea.base.util.module -import org.jetbrains.kotlin.idea.base.util.sdk +//import org.jetbrains.kotlin.idea.base.util.module +//import org.jetbrains.kotlin.idea.base.util.sdk import org.utbot.common.PathUtil.toPath import org.utbot.framework.plugin.api.util.LockFile import org.utbot.intellij.plugin.settings.Settings import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater -import org.utbot.intellij.plugin.ui.utils.testModules import org.utbot.python.PythonMethodHeader import org.utbot.python.PythonTestGenerationConfig import org.utbot.python.utils.RequirementsInstaller @@ -119,7 +120,7 @@ object PythonDialogProcessor { } } } - val pythonPath = getPythonPath(elementsToShow) + val pythonPath = getPythonPath(project) if (pythonPath == null) { showErrorDialogLater( project, @@ -146,8 +147,6 @@ object PythonDialogProcessor { focusedElement: PyElement?, pythonPath: String, ): PythonDialogWindow { - val srcModules = findSrcModules(elementsToShow) - val testModules = srcModules.flatMap {it.testModules(project)} val focusedElements = focusedElement ?.let { setOf(focusedElement.toUtPyTableItem()).filterNotNull() } ?.toSet() @@ -155,8 +154,6 @@ object PythonDialogProcessor { return PythonDialogWindow( PythonTestsModel( project, - srcModules.first(), - testModules, elementsToShow, focusedElements, project.service().generationTimeoutInMillis, @@ -334,12 +331,12 @@ object PythonDialogProcessor { } } -fun getPythonPath(elementsToShow: Set): String? { - return findSrcModules(elementsToShow).first().sdk?.homePath +fun getPythonPath(project: Project): String? { + return project.pythonSdk?.homePath } fun findSrcModules(elements: Collection): List { - return elements.mapNotNull { it.module }.distinct() + return listOf(ModuleImpl("", elements.first().project)) } fun getSrcModule(element: PyElement): Module { diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt index 29a8c20e65..ebe3c174c9 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt @@ -1,6 +1,6 @@ package org.utbot.intellij.plugin.python -import com.intellij.codeInsight.CodeInsightUtil +//import com.intellij.codeInsight.CodeInsightUtil import com.intellij.openapi.application.invokeLater import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.project.Project @@ -31,7 +31,7 @@ class PythonIntellijProcessor( testDir.findFile(testPsiFile.name)?.delete() testDir.add(testPsiFile) val file = testDir.findFile(testPsiFile.name)!! - CodeInsightUtil.positionCursor(model.project, file, file) +// CodeInsightUtil.positionCursor(model.project, file, file) } } } diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonTestsModel.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonTestsModel.kt index 1153ee7e08..a0ce0e4984 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonTestsModel.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonTestsModel.kt @@ -1,6 +1,5 @@ package org.utbot.intellij.plugin.python -import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project import com.jetbrains.python.psi.PyClass import com.jetbrains.python.psi.PyElement @@ -13,8 +12,6 @@ import org.utbot.intellij.plugin.models.BaseTestsModel class PythonTestsModel( project: Project, - srcModule: Module, - potentialTestModules: List, val elementsToDisplay: Set, val focusedElements: Set?, var timeout: Long, @@ -24,8 +21,6 @@ class PythonTestsModel( val names: Map, PyElement>, ) : BaseTestsModel( project, - srcModule, - potentialTestModules ) { lateinit var testSourceRootPath: String lateinit var testFramework: TestFramework diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt index 4edaf85e23..364e2d6b26 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt @@ -15,8 +15,8 @@ import com.intellij.psi.util.PsiTreeUtil import com.jetbrains.python.psi.PyClass import com.jetbrains.python.psi.PyFile import com.jetbrains.python.psi.PyFunction -import org.jetbrains.kotlin.idea.core.util.toPsiDirectory -import org.jetbrains.kotlin.idea.core.util.toPsiFile +//import org.jetbrains.kotlin.idea.core.util.toPsiDirectory +//import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.utbot.framework.plugin.api.util.LockFile import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant import org.utbot.intellij.plugin.python.* @@ -140,8 +140,8 @@ object PythonLanguageAssistant : LanguageAssistant() { } private fun getAllElements(project: Project, virtualFiles: Collection): Pair, Set> { - val psiFiles = virtualFiles.mapNotNull { it.toPsiFile(project) } - val psiDirectories = virtualFiles.mapNotNull { it.toPsiDirectory(project) } + val psiFiles = virtualFiles.filterIsInstance() + val psiDirectories = virtualFiles.filterIsInstance() val classes = psiFiles.flatMap { getClassesFromFile(it) }.toMutableSet() val functions = psiFiles.flatMap { getFunctionsFromFile(it) }.toMutableSet() diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index afd5662b64..7dd7e6a556 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -29,6 +29,8 @@ val junit4PlatformVersion: String by rootProject // https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" +project.tasks.asMap["runIde"]?.enabled = false + plugins { id("org.jetbrains.intellij") version "1.13.1" } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt index 8c0e78c69d..550c366084 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt @@ -72,9 +72,6 @@ import org.utbot.framework.codegen.tree.ututils.UtilClassKind import org.utbot.framework.codegen.tree.ututils.UtilClassKind.Companion.UT_UTILS_INSTANCE_NAME import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.framework.plugin.api.util.utContext -import org.utbot.framework.plugin.api.util.withUtContext -import org.utbot.framework.plugin.api.utils.ClassNameUtils.generateTestClassShortName import org.utbot.intellij.plugin.inspection.UnitTestBotInspectionManager import org.utbot.intellij.plugin.models.GenerateTestsModel import org.utbot.intellij.plugin.models.packageName @@ -90,7 +87,6 @@ import org.utbot.intellij.plugin.ui.WarningTestsReportNotifier import org.utbot.intellij.plugin.ui.utils.getOrCreateSarifReportsPath import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater import org.utbot.intellij.plugin.ui.utils.suitableTestSourceRoots -import org.utbot.intellij.plugin.util.IntelliJApiHelper import org.utbot.intellij.plugin.util.IntelliJApiHelper.Target.EDT_LATER import org.utbot.intellij.plugin.util.IntelliJApiHelper.Target.THREAD_POOL import org.utbot.intellij.plugin.util.IntelliJApiHelper.Target.WRITE_ACTION diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt index bf071056e4..c382cf30e1 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt @@ -8,12 +8,17 @@ import org.utbot.framework.codegen.domain.RuntimeExceptionTestsBehaviour import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.TestFramework import com.intellij.openapi.module.Module +import com.intellij.openapi.module.ModuleUtil import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile import com.intellij.psi.PsiClass import com.intellij.psi.PsiJavaFile +import com.intellij.psi.search.GlobalSearchScope import com.intellij.refactoring.util.classMembers.MemberInfo import org.jetbrains.concurrency.Promise import org.jetbrains.kotlin.psi.KtFile +import org.utbot.common.PathUtil.fileExtension import org.utbot.framework.SummariesGenerationType import org.utbot.framework.UtSettings import org.utbot.framework.plugin.api.ClassId @@ -24,12 +29,28 @@ import org.utbot.framework.plugin.api.SpringTestType import org.utbot.framework.plugin.api.SpringSettings import org.utbot.framework.util.ConflictTriggers import org.utbot.intellij.plugin.settings.Settings +import org.utbot.intellij.plugin.ui.utils.* +import java.nio.file.Files +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory +import kotlin.streams.asSequence + +const val HISTORY_LIMIT = 10 + +const val SPRINGBOOT_APPLICATION_FQN = "org.springframework.boot.autoconfigure.SpringBootApplication" +const val SPRINGBOOT_CONFIGURATION_FQN = "org.springframework.boot.SpringBootConfiguration" +const val SPRING_CONFIGURATION_ANNOTATION_FQN = "org.springframework.context.annotation.Configuration" +const val SPRING_TESTCONFIGURATION_ANNOTATION_FQN = "org.springframework.boot.test.context.TestConfiguration" + +const val SPRING_BEANS_SCHEMA_URL = "http://www.springframework.org/schema/beans" +const val SPRING_LOAD_DTD_GRAMMAR_PROPERTY = "http://apache.org/xml/features/nonvalidating/load-dtd-grammar" +const val SPRING_LOAD_EXTERNAL_DTD_PROPERTY = "http://apache.org/xml/features/nonvalidating/load-external-dtd" class GenerateTestsModel( project: Project, - srcModule: Module, - potentialTestModules: List, - srcClasses: Set, + val srcModule: Module, + val potentialTestModules: List, + var srcClasses: Set, val extractMembersFromSrcClasses: Boolean, var selectedMembers: Set, var timeout: Long, @@ -37,10 +58,11 @@ class GenerateTestsModel( var fuzzingValue: Double = 0.05 ): BaseTestsModel( project, - srcModule, - potentialTestModules, - srcClasses ) { + // GenerateTestsModel is supposed to be created with non-empty list of potentialTestModules. + // Otherwise, the error window is supposed to be shown earlier. + var testModule: Module = potentialTestModules.firstOrNull() ?: error("Empty list of test modules in model") + override var sourceRootHistory = project.service().sourceRootHistory override var codegenLanguage = project.service().codegenLanguage @@ -65,6 +87,145 @@ class GenerateTestsModel( var runGeneratedTestsWithCoverage : Boolean = false var summariesGenerationType : SummariesGenerationType = UtSettings.summaryGenerationType + + fun setSourceRootAndFindTestModule(newTestSourceRoot: VirtualFile?) { + requireNotNull(newTestSourceRoot) + testSourceRoot = newTestSourceRoot + var target = newTestSourceRoot + while (target != null && target is FakeVirtualFile) { + target = target.parent + } + if (target == null) { + error("Could not find module for $newTestSourceRoot") + } + + testModule = ModuleUtil.findModuleForFile(target, project) + ?: error("Could not find module for $newTestSourceRoot") + } + + val isMultiPackage: Boolean by lazy { + srcClasses.map { it.packageName }.distinct().size != 1 + } + + fun getAllTestSourceRoots() : MutableList { + with(if (project.isBuildWithGradle) project.allModules() else potentialTestModules) { + return this.flatMap { it.suitableTestSourceRoots().toList() }.toMutableList().distinct().toMutableList() + } + } + + fun getSortedTestRoots(): MutableList = getSortedTestRoots( + getAllTestSourceRoots(), + sourceRootHistory, + srcModule.rootManager.sourceRoots.map { file: VirtualFile -> file.toNioPath().toString() }, + codegenLanguage + ) + + /** + * Finds @SpringBootApplication classes in Spring application. + * + * @see [getSortedAnnotatedClasses] + */ + fun getSortedSpringBootApplicationClasses(): Set = + getSortedAnnotatedClasses(SPRINGBOOT_CONFIGURATION_FQN) + + getSortedAnnotatedClasses(SPRINGBOOT_APPLICATION_FQN) + + /** + * Finds @TestConfiguration and @Configuration classes in Spring application. + * + * @see [getSortedAnnotatedClasses] + */ + fun getSortedSpringConfigurationClasses(): Set = + getSortedAnnotatedClasses(SPRING_TESTCONFIGURATION_ANNOTATION_FQN) + + getSortedAnnotatedClasses(SPRING_CONFIGURATION_ANNOTATION_FQN) + + /** + * Finds classes annotated with given annotation in [srcModule] and [potentialTestModules]. + * + * Sorting order: + * - classes from test source roots (in the order provided by [getSortedTestRoots]) + * - classes from production source roots + */ + private fun getSortedAnnotatedClasses(annotationFqn: String): Set { + val searchScope = + potentialTestModules + .fold(GlobalSearchScope.moduleScope(srcModule)) { accScope, module -> + accScope.union(GlobalSearchScope.moduleScope(module)) + } + + val annotationClass = JavaPsiFacade + .getInstance(project) + .findClass(annotationFqn, GlobalSearchScope.allScope(project)) + ?: return emptySet() + + val testRootToIndex = + getSortedTestRoots() + .withIndex() + .associate { (i, root) -> root.dir to i } + + return AnnotatedElementsSearch + .searchPsiClasses(annotationClass, searchScope) + .findAll() + .sortedBy { testRootToIndex[it.containingFile.sourceRoot] ?: Int.MAX_VALUE } + .mapNotNullTo(mutableSetOf()) { it.binaryName } + } + + fun getSpringXMLConfigurationFiles(): Set { + val resourcesPaths = + buildList { + addAll(potentialTestModules) + add(srcModule) + }.distinct().flatMapTo(mutableSetOf()) { it.getResourcesPaths() } + val xmlFilePaths = resourcesPaths.flatMapTo(mutableListOf()) { path -> + Files.walk(path) + .asSequence() + .filter { it.fileExtension == ".xml" } + } + + val builder = customizeXmlBuilder() + return xmlFilePaths.mapNotNullTo(mutableSetOf()) { path -> + try { + val doc = builder.parse(path.toFile()) + + val hasBeanTagName = doc.documentElement.tagName == "beans" + val hasAttribute = doc.documentElement.getAttribute("xmlns") == SPRING_BEANS_SCHEMA_URL + when { + hasBeanTagName && hasAttribute -> path.toString() + else -> null + } + } catch (e: Exception) { + // `DocumentBuilder.parse` is an unpredictable operation, may have some side effects, we suppress them. + null + } + } + } + + /** + * Creates "safe" xml builder instance. + * + * Using standard `DocumentBuilderFactory.newInstance()` may lead to some problems like + * https://stackoverflow.com/questions/343383/unable-to-parse-xml-file-using-documentbuilder. + * + * We try to solve it in accordance with top-rated recommendation here + * https://stackoverflow.com/questions/155101/make-documentbuilder-parse-ignore-dtd-references. + */ + private fun customizeXmlBuilder(): DocumentBuilder { + val builderFactory = DocumentBuilderFactory.newInstance() + builderFactory.isNamespaceAware = true + + // See documentation https://xerces.apache.org/xerces2-j/features.html + builderFactory.setFeature(SPRING_LOAD_DTD_GRAMMAR_PROPERTY, false) + builderFactory.setFeature(SPRING_LOAD_EXTERNAL_DTD_PROPERTY, false) + + return builderFactory.newDocumentBuilder() + } + + fun updateSourceRootHistory(path: String) { + sourceRootHistory.apply { + remove(path)//Remove existing entry if any + add(path)//Add the most recent entry to the end to be brought first at sorting, see org.utbot.intellij.plugin.ui.utils.RootUtilsKt.getSortedTestRoots + while (size > HISTORY_LIMIT) removeFirst() + } + } } val PsiClass.packageName: String diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt similarity index 94% rename from utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt index 618df2cf6c..a57e63a9e4 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt @@ -14,14 +14,14 @@ import com.intellij.ui.ColoredListCellRenderer import com.intellij.ui.SimpleTextAttributes import com.intellij.util.ArrayUtil import com.intellij.util.ui.UIUtil -import java.io.File -import javax.swing.DefaultComboBoxModel -import javax.swing.JList import org.utbot.common.PathUtil import org.utbot.intellij.plugin.models.BaseTestsModel import org.utbot.intellij.plugin.ui.utils.ITestSourceRoot import org.utbot.intellij.plugin.ui.utils.addDedicatedTestRoot import org.utbot.intellij.plugin.ui.utils.isBuildWithGradle +import java.io.File +import javax.swing.DefaultComboBoxModel +import javax.swing.JList private const val SET_TEST_FOLDER = "set test folder" @@ -77,7 +77,7 @@ class TestFolderComboWithBrowseButton(private val model: BaseTestsModel) : } else { //Prepend and select newly added test root val testRootItems = linkedSetOf(it) - testRootItems += (0 until childComponent.itemCount).map { i -> childComponent.getItemAt(i) as VirtualFile} + testRootItems += (0 until childComponent.itemCount).map { i -> childComponent.getItemAt(i) as VirtualFile } newItemList(testRootItems) } } @@ -86,9 +86,12 @@ class TestFolderComboWithBrowseButton(private val model: BaseTestsModel) : private fun chooseTestRoot(model: BaseTestsModel): VirtualFile? = ReadAction.compute { - val desc = object:FileChooserDescriptor(false, true, false, false, false, false) { + val desc = object : FileChooserDescriptor(false, true, false, false, false, false) { override fun isFileSelectable(file: VirtualFile?): Boolean { - return file != null && ModuleUtil.findModuleForFile(file, model.project) != null && super.isFileSelectable(file) + return file != null && ModuleUtil.findModuleForFile( + file, + model.project + ) != null && super.isFileSelectable(file) } } val initialFile = model.project.guessProjectDir() diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt similarity index 99% rename from utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt index f9cf089061..5f18c2a0cb 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt @@ -148,7 +148,7 @@ fun Module.suitableTestSourceRoots(): List { .mapNotNull { it.testSourceRoot } } -private val SourceFolder.testSourceRoot:TestSourceRoot? +private val SourceFolder.testSourceRoot: TestSourceRoot? get() { val file = file val expectedLanguage = expectedLanguageForTests diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtils.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtils.kt similarity index 100% rename from utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtils.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtils.kt diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/util/PsiClassHelper.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/util/PsiClassHelper.kt similarity index 100% rename from utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/util/PsiClassHelper.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/util/PsiClassHelper.kt diff --git a/utbot-ui-commons/src/test/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtilsTest.kt b/utbot-intellij/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt similarity index 93% rename from utbot-ui-commons/src/test/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtilsTest.kt rename to utbot-intellij/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt index cbc295104f..ad36792ce7 100644 --- a/utbot-ui-commons/src/test/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtilsTest.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt @@ -1,8 +1,12 @@ -package org.utbot.intellij.plugin.ui.utils +package org.utbot.tests import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.utbot.framework.plugin.api.CodegenLanguage +import org.utbot.intellij.plugin.ui.utils.ITestSourceRoot +import org.utbot.intellij.plugin.ui.utils.SRC_MAIN +import org.utbot.intellij.plugin.ui.utils.getCommonPrefix +import org.utbot.intellij.plugin.ui.utils.getSortedTestRoots internal class RootUtilsTest { internal class MockTestSourceRoot(override val dirPath: String) : ITestSourceRoot { diff --git a/utbot-python/samples/my_cov.json b/utbot-python/samples/my_cov.json new file mode 100644 index 0000000000..b131ee2c2b --- /dev/null +++ b/utbot-python/samples/my_cov.json @@ -0,0 +1 @@ +{"covered":[{"start":4,"end":4},{"start":12,"end":15},{"start":17,"end":17}],"notCovered":[{"start":5,"end":10},{"start":16,"end":16}]} \ No newline at end of file diff --git a/utbot-ui-commons/build.gradle.kts b/utbot-ui-commons/build.gradle.kts index 608d02e918..0e32940387 100644 --- a/utbot-ui-commons/build.gradle.kts +++ b/utbot-ui-commons/build.gradle.kts @@ -15,8 +15,8 @@ intellij { type.set(ideType) plugins.set(listOf( - "java", - "org.jetbrains.android" +// "java", +// "org.jetbrains.android" )) } diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt index 2e383a36c7..fd3e5c6e32 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt @@ -11,8 +11,8 @@ import com.intellij.psi.PsiDirectory import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiFileSystemItem -import org.jetbrains.kotlin.idea.core.util.toPsiDirectory -import org.jetbrains.kotlin.idea.core.util.toPsiFile +//import org.jetbrains.kotlin.idea.core.util.toPsiDirectory +//import org.jetbrains.kotlin.idea.core.util.toPsiFile private val logger = KotlinLogging.logger {} @@ -84,9 +84,20 @@ abstract class LanguageAssistant { } private fun findLanguageRecursively(project: Project, virtualFiles: Array): Language? { - val psiFiles = virtualFiles.mapNotNull { it.toPsiFile(project) } - val psiDirectories = virtualFiles.mapNotNull { it.toPsiDirectory(project) } - + val psiFiles = virtualFiles.mapNotNull { + if (it is PsiFile) { + it + } + else null + } + val psiDirectories = virtualFiles.mapNotNull { + if (it is PsiDirectory) { + it + } + else null + } +// val psiFiles = virtualFiles.mapNotNull { it.getPsiFile(project) } +// val psiDirectories = virtualFiles.mapNotNull { it. .toPsiDirectory(project) } val fileLanguage = psiFiles.firstNotNullOfOrNull { getLanguageFromFile(it) } return fileLanguage ?: psiDirectories.firstNotNullOfOrNull { findLanguageRecursively(it) } diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/models/BaseTestModel.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/models/BaseTestModel.kt index 321a2af4e9..c6d22c4530 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/models/BaseTestModel.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/models/BaseTestModel.kt @@ -1,197 +1,17 @@ package org.utbot.intellij.plugin.models -import com.intellij.openapi.module.Module -import com.intellij.openapi.module.ModuleUtil import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile -import com.intellij.psi.JavaPsiFacade -import com.intellij.psi.PsiClass -import com.intellij.psi.search.GlobalSearchScope -import com.intellij.psi.search.searches.AnnotatedElementsSearch -import org.jetbrains.kotlin.idea.core.getPackage -import org.jetbrains.kotlin.idea.util.projectStructure.allModules -import org.jetbrains.kotlin.idea.util.rootManager -import org.jetbrains.kotlin.idea.util.sourceRoot -import org.utbot.common.PathUtil.fileExtension import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.intellij.plugin.ui.utils.ITestSourceRoot -import org.utbot.intellij.plugin.ui.utils.getResourcesPaths -import org.utbot.intellij.plugin.ui.utils.getSortedTestRoots -import org.utbot.intellij.plugin.ui.utils.isBuildWithGradle -import org.utbot.intellij.plugin.ui.utils.suitableTestSourceRoots -import org.utbot.intellij.plugin.util.binaryName -import java.nio.file.Files -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory -import kotlin.streams.asSequence -val PsiClass.packageName: String get() = this.containingFile.containingDirectory.getPackage()?.qualifiedName ?: "" -const val HISTORY_LIMIT = 10 - -const val SPRINGBOOT_APPLICATION_FQN = "org.springframework.boot.autoconfigure.SpringBootApplication" -const val SPRINGBOOT_CONFIGURATION_FQN = "org.springframework.boot.SpringBootConfiguration" -const val SPRING_CONFIGURATION_ANNOTATION_FQN = "org.springframework.context.annotation.Configuration" -const val SPRING_TESTCONFIGURATION_ANNOTATION_FQN = "org.springframework.boot.test.context.TestConfiguration" - -const val SPRING_BEANS_SCHEMA_URL = "http://www.springframework.org/schema/beans" -const val SPRING_LOAD_DTD_GRAMMAR_PROPERTY = "http://apache.org/xml/features/nonvalidating/load-dtd-grammar" -const val SPRING_LOAD_EXTERNAL_DTD_PROPERTY = "http://apache.org/xml/features/nonvalidating/load-external-dtd" - open class BaseTestsModel( val project: Project, - val srcModule: Module, - val potentialTestModules: List, - var srcClasses: Set = emptySet(), ) { - // GenerateTestsModel is supposed to be created with non-empty list of potentialTestModules. - // Otherwise, the error window is supposed to be shown earlier. - var testModule: Module = potentialTestModules.firstOrNull() ?: error("Empty list of test modules in model") - var testSourceRoot: VirtualFile? = null var testPackageName: String? = null open var sourceRootHistory : MutableList = mutableListOf() open lateinit var codegenLanguage: CodegenLanguage open lateinit var projectType: ProjectType - - fun setSourceRootAndFindTestModule(newTestSourceRoot: VirtualFile?) { - requireNotNull(newTestSourceRoot) - testSourceRoot = newTestSourceRoot - var target = newTestSourceRoot - while (target != null && target is FakeVirtualFile) { - target = target.parent - } - if (target == null) { - error("Could not find module for $newTestSourceRoot") - } - - testModule = ModuleUtil.findModuleForFile(target, project) - ?: error("Could not find module for $newTestSourceRoot") - } - - val isMultiPackage: Boolean by lazy { - srcClasses.map { it.packageName }.distinct().size != 1 - } - - fun getAllTestSourceRoots() : MutableList { - with(if (project.isBuildWithGradle) project.allModules() else potentialTestModules) { - return this.flatMap { it.suitableTestSourceRoots().toList() }.toMutableList().distinct().toMutableList() - } - } - - fun getSortedTestRoots(): MutableList = getSortedTestRoots( - getAllTestSourceRoots(), - sourceRootHistory, - srcModule.rootManager.sourceRoots.map { file: VirtualFile -> file.toNioPath().toString() }, - codegenLanguage - ) - - /** - * Finds @SpringBootApplication classes in Spring application. - * - * @see [getSortedAnnotatedClasses] - */ - fun getSortedSpringBootApplicationClasses(): Set = - getSortedAnnotatedClasses(SPRINGBOOT_CONFIGURATION_FQN) + - getSortedAnnotatedClasses(SPRINGBOOT_APPLICATION_FQN) - - /** - * Finds @TestConfiguration and @Configuration classes in Spring application. - * - * @see [getSortedAnnotatedClasses] - */ - fun getSortedSpringConfigurationClasses(): Set = - getSortedAnnotatedClasses(SPRING_TESTCONFIGURATION_ANNOTATION_FQN) + - getSortedAnnotatedClasses(SPRING_CONFIGURATION_ANNOTATION_FQN) - - /** - * Finds classes annotated with given annotation in [srcModule] and [potentialTestModules]. - * - * Sorting order: - * - classes from test source roots (in the order provided by [getSortedTestRoots]) - * - classes from production source roots - */ - private fun getSortedAnnotatedClasses(annotationFqn: String): Set { - val searchScope = - potentialTestModules - .fold(GlobalSearchScope.moduleScope(srcModule)) { accScope, module -> - accScope.union(GlobalSearchScope.moduleScope(module)) - } - - val annotationClass = JavaPsiFacade - .getInstance(project) - .findClass(annotationFqn, GlobalSearchScope.allScope(project)) - ?: return emptySet() - - val testRootToIndex = - getSortedTestRoots() - .withIndex() - .associate { (i, root) -> root.dir to i } - - return AnnotatedElementsSearch - .searchPsiClasses(annotationClass, searchScope) - .findAll() - .sortedBy { testRootToIndex[it.containingFile.sourceRoot] ?: Int.MAX_VALUE } - .mapNotNullTo(mutableSetOf()) { it.binaryName } - } - - fun getSpringXMLConfigurationFiles(): Set { - val resourcesPaths = - buildList { - addAll(potentialTestModules) - add(srcModule) - }.distinct().flatMapTo(mutableSetOf()) { it.getResourcesPaths() } - val xmlFilePaths = resourcesPaths.flatMapTo(mutableListOf()) { path -> - Files.walk(path) - .asSequence() - .filter { it.fileExtension == ".xml" } - } - - val builder = customizeXmlBuilder() - return xmlFilePaths.mapNotNullTo(mutableSetOf()) { path -> - try { - val doc = builder.parse(path.toFile()) - - val hasBeanTagName = doc.documentElement.tagName == "beans" - val hasAttribute = doc.documentElement.getAttribute("xmlns") == SPRING_BEANS_SCHEMA_URL - when { - hasBeanTagName && hasAttribute -> path.toString() - else -> null - } - } catch (e: Exception) { - // `DocumentBuilder.parse` is an unpredictable operation, may have some side effects, we suppress them. - null - } - } - } - - /** - * Creates "safe" xml builder instance. - * - * Using standard `DocumentBuilderFactory.newInstance()` may lead to some problems like - * https://stackoverflow.com/questions/343383/unable-to-parse-xml-file-using-documentbuilder. - * - * We try to solve it in accordance with top-rated recommendation here - * https://stackoverflow.com/questions/155101/make-documentbuilder-parse-ignore-dtd-references. - */ - private fun customizeXmlBuilder(): DocumentBuilder { - val builderFactory = DocumentBuilderFactory.newInstance() - builderFactory.isNamespaceAware = true - - // See documentation https://xerces.apache.org/xerces2-j/features.html - builderFactory.setFeature(SPRING_LOAD_DTD_GRAMMAR_PROPERTY, false) - builderFactory.setFeature(SPRING_LOAD_EXTERNAL_DTD_PROPERTY, false) - - return builderFactory.newDocumentBuilder() - } - - fun updateSourceRootHistory(path: String) { - sourceRootHistory.apply { - remove(path)//Remove existing entry if any - add(path)//Add the most recent entry to the end to be brought first at sorting, see org.utbot.intellij.plugin.ui.utils.RootUtilsKt.getSortedTestRoots - while (size > HISTORY_LIMIT) removeFirst() - } - } } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt similarity index 100% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt rename to utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt similarity index 91% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt rename to utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt index 133167ff2e..1e790f6341 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt @@ -11,9 +11,8 @@ import com.intellij.openapi.ui.cellvalidators.CellComponentProvider import com.intellij.openapi.ui.cellvalidators.CellTooltipManager import com.intellij.openapi.ui.cellvalidators.ValidatingTableCellRendererWrapper import com.intellij.openapi.util.Disposer -import com.intellij.psi.JavaPsiFacade -import com.intellij.psi.PsiClass -import com.intellij.psi.search.GlobalSearchScope +//import com.intellij.psi.JavaPsiFacade +//import com.intellij.psi.PsiClass import com.intellij.ui.components.fields.ExtendableTextField import com.intellij.ui.table.JBTable import com.intellij.util.ui.ColumnInfo @@ -33,7 +32,7 @@ internal class MockAlwaysClassesTable(project: Project) : ListTableWithButtons Date: Tue, 12 Sep 2023 10:30:42 +0300 Subject: [PATCH 03/43] Forks in python fuzzing and refactoring (#2588) (cherry picked from commit 45e1d371e6470d93dcc2cf480c77f5c9117b9d02) --- .../cli/language/python/PythonCliProcessor.kt | 16 ++- .../python/PythonGenerateTestsCommand.kt | 9 +- .../main/python/utbot_executor/pyproject.toml | 2 +- .../src/main/resources/utbot_executor_version | 2 +- .../generated_tests__arithmetic.py | 40 ------ .../generated_tests__deep_equals.py | 87 ----------- .../cli_utbot_tests/generated_tests__deque.py | 35 ----- .../cli_utbot_tests/generated_tests__dicts.py | 44 ------ .../generated_tests__dummy_with_eq.py | 39 ----- .../generated_tests__dummy_without_eq.py | 36 ----- .../cli_utbot_tests/generated_tests__graph.py | 36 ----- .../generated_tests__list_of_datetime.py | 32 ----- .../cli_utbot_tests/generated_tests__lists.py | 21 --- .../generated_tests__longest_subsequence.py | 25 ---- .../generated_tests__matrix.py | 41 ------ .../generated_tests__primitive_types.py | 40 ------ .../generated_tests__quick_sort.py | 30 ---- .../generated_tests__test_coverage.py | 35 ----- .../generated_tests__type_inference.py | 20 --- .../generated_tests__using_collections.py | 23 --- utbot-python/samples/generate_test_samples.sh | 24 ---- utbot-python/samples/run_test_samples.sh | 24 ---- .../samples/collection/using_collections.py | 2 + .../named_arguments/method_named_arguments.py | 3 +- .../testing_utils/collect_executions.py | 34 +++++ .../samples/testing_utils/collect_timeouts.py | 41 ++++++ utbot-python/samples/testing_utils/compare.py | 25 ++++ .../kotlin/org/utbot/python/PythonEngine.kt | 60 +++++--- .../utbot/python/PythonTestCaseGenerator.kt | 136 ++++++------------ .../kotlin/org/utbot/python/UTPythonAPI.kt | 1 + .../tree/PythonTestFrameworkManager.kt | 9 +- .../org/utbot/python/fuzzing/PythonApi.kt | 82 ++++++++++- .../fuzzing/provider/BoolValueProvider.kt | 3 +- .../fuzzing/provider/ComplexValueProvider.kt | 14 +- .../fuzzing/provider/ConstantValueProvider.kt | 3 +- .../fuzzing/provider/FloatValueProvider.kt | 5 +- .../fuzzing/provider/IntValueProvider.kt | 3 +- .../fuzzing/provider/NoneValueProvider.kt | 3 +- .../fuzzing/provider/ReduceValueProvider.kt | 3 +- .../inference/TypeInferenceAlgorithmAPI.kt | 2 - .../inference/TypeInferenceProcessor.kt | 3 +- .../inference/baseline/BaselineAlgorithm.kt | 105 ++++++++++++-- .../utils/TestGenerationLimitManager.kt | 10 +- 43 files changed, 420 insertions(+), 788 deletions(-) delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__arithmetic.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__deep_equals.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__deque.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__dicts.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__dummy_with_eq.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__dummy_without_eq.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__graph.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__list_of_datetime.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__lists.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__longest_subsequence.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__matrix.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__primitive_types.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__quick_sort.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__test_coverage.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__type_inference.py delete mode 100644 utbot-python/samples/cli_utbot_tests/generated_tests__using_collections.py delete mode 100644 utbot-python/samples/generate_test_samples.sh delete mode 100755 utbot-python/samples/run_test_samples.sh create mode 100644 utbot-python/samples/testing_utils/collect_executions.py create mode 100644 utbot-python/samples/testing_utils/collect_timeouts.py create mode 100644 utbot-python/samples/testing_utils/compare.py diff --git a/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonCliProcessor.kt b/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonCliProcessor.kt index d49b2895a9..4ded0545ac 100644 --- a/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonCliProcessor.kt +++ b/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonCliProcessor.kt @@ -10,6 +10,7 @@ class PythonCliProcessor( private val output: String, private val logger: KLogger, private val coverageOutput: String?, + private val executionCounterOutput: String?, ) : PythonTestGenerationProcessor() { override fun saveTests(testsCode: String) { @@ -22,9 +23,18 @@ class PythonCliProcessor( ) } + private fun getExecutionsNumber(testSets: List): Int { + return testSets.sumOf { it.executionsNumber } + } + override fun processCoverageInfo(testSets: List) { - val coverageReport = getStringCoverageInfo(testSets) - val output = coverageOutput ?: return - writeToFileAndSave(output, coverageReport) + coverageOutput?.let { output -> + val coverageReport = getStringCoverageInfo(testSets) + writeToFileAndSave(output, coverageReport) + } + executionCounterOutput?.let { executionOutput -> + val executionReport = "{\"executions\": ${getExecutionsNumber(testSets)}}" + writeToFileAndSave(executionOutput, executionReport) + } } } \ No newline at end of file diff --git a/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonGenerateTestsCommand.kt b/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonGenerateTestsCommand.kt index 981d2f9b4b..89448aebb9 100644 --- a/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonGenerateTestsCommand.kt +++ b/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonGenerateTestsCommand.kt @@ -76,6 +76,11 @@ class PythonGenerateTestsCommand : CliktCommand( help = "File to write coverage report." ) + private val executionCounterOutput by option( + "--executions-counter", + help = "File to write number of executions." + ) + private val installRequirementsIfMissing by option( "--install-requirements", help = "Install Python requirements if missing." @@ -255,6 +260,7 @@ class PythonGenerateTestsCommand : CliktCommand( output.toAbsolutePath(), logger, coverageOutput?.toAbsolutePath(), + executionCounterOutput?.toAbsolutePath(), ) logger.info("Loading information about Python types...") @@ -270,7 +276,8 @@ class PythonGenerateTestsCommand : CliktCommand( testSet.executions.filterNot { it.result is UtExecutionSuccess }, testSet.errors, testSet.mypyReport, - testSet.classId + testSet.classId, + testSet.executionsNumber ) } } diff --git a/utbot-python-executor/src/main/python/utbot_executor/pyproject.toml b/utbot-python-executor/src/main/python/utbot_executor/pyproject.toml index 74249105ff..13b3063e09 100644 --- a/utbot-python-executor/src/main/python/utbot_executor/pyproject.toml +++ b/utbot-python-executor/src/main/python/utbot_executor/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "utbot-executor" -version = "1.4.44" +version = "1.7.0" description = "" authors = ["Vyacheslav Tamarin "] readme = "README.md" diff --git a/utbot-python-executor/src/main/resources/utbot_executor_version b/utbot-python-executor/src/main/resources/utbot_executor_version index b0a831507c..9dbb0c0052 100644 --- a/utbot-python-executor/src/main/resources/utbot_executor_version +++ b/utbot-python-executor/src/main/resources/utbot_executor_version @@ -1 +1 @@ -1.4.44 \ No newline at end of file +1.7.0 \ No newline at end of file diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__arithmetic.py b/utbot-python/samples/cli_utbot_tests/generated_tests__arithmetic.py deleted file mode 100644 index fe6ecb2585..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__arithmetic.py +++ /dev/null @@ -1,40 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import arithmetic -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable arithmetic.calculate_function_value - # region - def test_calculate_function_value(self): - actual = arithmetic.calculate_function_value(1, 101) - - self.assertEqual(11886.327847992769, actual) - - def test_calculate_function_value1(self): - actual = arithmetic.calculate_function_value(4294967296, 101) - - self.assertEqual(65535.99845886229, actual) - - def test_calculate_function_value2(self): - actual = arithmetic.calculate_function_value(float('nan'), 4294967296) - - self.assertTrue(isinstance(actual, builtins.float)) - - def test_calculate_function_value_throws_t(self): - arithmetic.calculate_function_value(0, 101) - - # raises builtins.ZeroDivisionError - - def test_calculate_function_value_throws_t1(self): - arithmetic.calculate_function_value(101, 101) - - # raises builtins.ValueError - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__deep_equals.py b/utbot-python/samples/cli_utbot_tests/generated_tests__deep_equals.py deleted file mode 100644 index 3f04ba5a47..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__deep_equals.py +++ /dev/null @@ -1,87 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import deep_equals -import copyreg -import types -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable deep_equals.comparable_list - # region - def test_comparable_list(self): - actual = deep_equals.comparable_list(4294967296) - - comparable_class = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class.x = 0 - comparable_class1 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class1.x = 1 - comparable_class2 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class2.x = 2 - comparable_class3 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class3.x = 3 - comparable_class4 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class4.x = 4 - comparable_class5 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class5.x = 5 - comparable_class6 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class6.x = 6 - comparable_class7 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class7.x = 7 - comparable_class8 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class8.x = 8 - comparable_class9 = copyreg._reconstructor(deep_equals.ComparableClass, builtins.object, None) - comparable_class9.x = 9 - - self.assertEqual([comparable_class, comparable_class1, comparable_class2, comparable_class3, comparable_class4, comparable_class5, comparable_class6, comparable_class7, comparable_class8, comparable_class9], actual) - - # endregion - - # endregion - - # region Test suites for executable deep_equals.incomparable_list - # region - def test_incomparable_list(self): - actual = deep_equals.incomparable_list(4294967296) - - incomparable_class = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class.x = 0 - incomparable_class1 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class1.x = 1 - incomparable_class2 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class2.x = 2 - incomparable_class3 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class3.x = 3 - incomparable_class4 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class4.x = 4 - incomparable_class5 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class5.x = 5 - incomparable_class6 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class6.x = 6 - incomparable_class7 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class7.x = 7 - incomparable_class8 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class8.x = 8 - incomparable_class9 = copyreg._reconstructor(deep_equals.IncomparableClass, builtins.object, None) - incomparable_class9.x = 9 - expected_list = [incomparable_class, incomparable_class1, incomparable_class2, incomparable_class3, incomparable_class4, incomparable_class5, incomparable_class6, incomparable_class7, incomparable_class8, incomparable_class9] - expected_length = len(expected_list) - actual_length = len(actual) - - self.assertEqual(expected_length, actual_length) - - index = None - for index in range(0, expected_length, 1): - expected_element = expected_list[index] - actual_element = actual[index] - actual_x = actual_element.x - expected_x = expected_element.x - - self.assertEqual(expected_x, actual_x) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__deque.py b/utbot-python/samples/cli_utbot_tests/generated_tests__deque.py deleted file mode 100644 index fa4f36dee3..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__deque.py +++ /dev/null @@ -1,35 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import deque -import collections -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable deque.generate_people_deque - # region - def test_generate_people_deque(self): - actual = deque.generate_people_deque(4294967297) - - deque1 = collections.deque() - deque1.append('Alex') - deque1.append('Bob') - deque1.append('Cate') - deque1.append('Daisy') - deque1.append('Ed') - - self.assertEqual(deque1, actual) - - def test_generate_people_deque1(self): - actual = deque.generate_people_deque(0) - - deque1 = collections.deque() - - self.assertEqual(deque1, actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__dicts.py b/utbot-python/samples/cli_utbot_tests/generated_tests__dicts.py deleted file mode 100644 index aba188aa11..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__dicts.py +++ /dev/null @@ -1,44 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import types -import dicts -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable dicts.keys - - # region - - def test_keys(self): - word = dicts.Word({str(-123456789): str(), str(1.5 + 3.5j): str(), str(b'\x80'): str(), str(): str(1e+300 * 1e+300), str('unicode remains unicode'): str(), }) - - actual = word.keys() - - self.assertEqual(['-123456789', '(1.5+3.5j)', "b'\\x80'", '', 'unicode remains unicode'], actual) - # endregion - - # endregion - - # region Test suites for executable dicts.translate - - # region - - def test_translate(self): - dictionary = dicts.Dictionary([str(b'\xf0\xa3\x91\x96', 'utf-8'), str(id), str(1e+300 * 1e+300)], []) - - actual = dictionary.translate(str(id), str(1.5 + 3.5j)) - - self.assertEqual(None, actual) - - def test_translate_throws_t(self): - dictionary = dicts.Dictionary([], [{str(): str(), str(1e+300 * 1e+300): str(1e+300 * 1e+300), str(b'\x80'): str(), str(1.5 + 3.5j): str(), }, {str(-123456789): str(), str(id): str(), str(): str(), str(-1234567890): str(), }, {str(1.5 + 3.5j): str(), str(1e+300 * 1e+300): str(), str(-1234567890): str(), str(): str(1e+300 * 1e+300), }]) - - dictionary.translate(str('unicode remains unicode'), str(1.5 + 3.5j)) - - # raises builtins.KeyError - # endregion - - # endregion - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__dummy_with_eq.py b/utbot-python/samples/cli_utbot_tests/generated_tests__dummy_with_eq.py deleted file mode 100644 index f6eed2d5ab..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__dummy_with_eq.py +++ /dev/null @@ -1,39 +0,0 @@ -import sys -sys.path.append('samples') -import dummy_with_eq -import builtins -import copyreg -import types -import unittest - - -class TestDummy(unittest.TestCase): - # region Test suites for executable dummy_with_eq.propagate - # region - def test_propagate(self): - dummy = dummy_with_eq.Dummy(1) - - actual = dummy.propagate() - - dummy1 = copyreg._reconstructor(dummy_with_eq.Dummy, builtins.object, None) - dummy1.field = 1 - expected_list = [dummy1, dummy1] - expected_length = len(expected_list) - actual_length = len(actual) - - self.assertEqual(expected_length, actual_length) - - index = None - for index in range(0, expected_length, 1): - expected_element = expected_list[index] - actual_element = actual[index] - actual_field = actual_element.field - expected_field = expected_element.field - - self.assertEqual(expected_field, actual_field) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__dummy_without_eq.py b/utbot-python/samples/cli_utbot_tests/generated_tests__dummy_without_eq.py deleted file mode 100644 index 3a38c1f6b7..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__dummy_without_eq.py +++ /dev/null @@ -1,36 +0,0 @@ -import sys -sys.path.append('samples') -import dummy_without_eq -import builtins -import copyreg -import types -import unittest - - -class TestDummy(unittest.TestCase): - # region Test suites for executable dummy_without_eq.propagate - # region - def test_propagate(self): - dummy = dummy_without_eq.Dummy() - - actual = dummy.propagate() - - dummy1 = copyreg._reconstructor(dummy_without_eq.Dummy, builtins.object, None) - expected_list = [dummy1, dummy1] - expected_length = len(expected_list) - actual_length = len(actual) - - self.assertEqual(expected_length, actual_length) - - index = None - for index in range(0, expected_length, 1): - expected_element = expected_list[index] - actual_element = actual[index] - - self.assertTrue(isinstance(actual_element, dummy_without_eq.Dummy)) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__graph.py b/utbot-python/samples/cli_utbot_tests/generated_tests__graph.py deleted file mode 100644 index c383980fb6..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__graph.py +++ /dev/null @@ -1,36 +0,0 @@ -import sys -sys.path.append('samples') -import unittest -import builtins -import graph -import copyreg -import types - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable graph.bfs - # region - def test_bfs(self): - actual = graph.bfs([graph.Node(str(1e+300 * 1e+300), []), graph.Node(str(id), []), graph.Node(str('unicode remains unicode'), [])]) - - node = copyreg._reconstructor(graph.Node, builtins.object, None) - node.name = 'unicode remains unicode' - node.children = [] - node1 = copyreg._reconstructor(graph.Node, builtins.object, None) - node1.name = '' - node1.children = [] - node2 = copyreg._reconstructor(graph.Node, builtins.object, None) - node2.name = 'inf' - node2.children = [] - self.assertEqual([node, node1, node2], actual) - - def test_bfs1(self): - actual = graph.bfs([]) - - self.assertEqual([], actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__list_of_datetime.py b/utbot-python/samples/cli_utbot_tests/generated_tests__list_of_datetime.py deleted file mode 100644 index 4339e26c0e..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__list_of_datetime.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import list_of_datetime -import types -import datetime -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable list_of_datetime.get_data_labels - # region - def test_get_data_labels(self): - actual = list_of_datetime.get_data_labels({}) - - self.assertEqual(None, actual) - - def test_get_data_labels1(self): - actual = list_of_datetime.get_data_labels([datetime.time(0), datetime.time(microsecond=40), datetime.time(18, 45, 3, 1234), datetime.time(12, 0)]) - - self.assertEqual(['00:00', '00:00', '18:45', '12:00'], actual) - - def test_get_data_labels2(self): - actual = list_of_datetime.get_data_labels([datetime.time(microsecond=40), datetime.time()]) - - self.assertEqual(['1900-01-01', '1900-01-01'], actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__lists.py b/utbot-python/samples/cli_utbot_tests/generated_tests__lists.py deleted file mode 100644 index 38d5289f30..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__lists.py +++ /dev/null @@ -1,21 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import lists -import datetime -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable lists.find_articles_with_author - # region - def test_find_articles_with_author(self): - actual = lists.find_articles_with_author([lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str('unicode remains unicode'), datetime.datetime(2015, 4, 5, 1, 45)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str('unicode remains unicode'), datetime.datetime(2011, 1, 1)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(), datetime.datetime(1, 2, 3, 4, 5, 6, 7)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(id), datetime.datetime(1, 2, 3, 4, 5, 6, 7)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(id), datetime.datetime(2014, 11, 2, 1, 30)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(id), datetime.datetime(1, 2, 3, 4, 5, 6, 7))], str('unicode remains unicode')) - - self.assertEqual([], actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__longest_subsequence.py b/utbot-python/samples/cli_utbot_tests/generated_tests__longest_subsequence.py deleted file mode 100644 index 510171cbbc..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__longest_subsequence.py +++ /dev/null @@ -1,25 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import longest_subsequence -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable longest_subsequence.longest_subsequence - # region - def test_longest_subsequence(self): - actual = longest_subsequence.longest_subsequence([1, 83]) - - self.assertEqual([1, 83], actual) - - def test_longest_subsequence1(self): - actual = longest_subsequence.longest_subsequence([2, -1, 4294967296]) - - self.assertEqual([-1, 4294967296], actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__matrix.py b/utbot-python/samples/cli_utbot_tests/generated_tests__matrix.py deleted file mode 100644 index db4d57758e..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__matrix.py +++ /dev/null @@ -1,41 +0,0 @@ -import sys -sys.path.append('samples') -import matrix -import builtins -import types -import copyreg -import unittest - - -class TestMatrix(unittest.TestCase): - # region Test suites for executable matrix.__add__ - - # region - - def test__add__(self): - matrix1 = matrix.Matrix([[float('nan'), 0.0, float(1970), 7.3, float('nan')], [float(10 ** 23), float('1.4'), float(-1), float(-1), float('nan'), float('nan'), float(1970)], [float('nan'), 0.0, float(1970), 7.3, float('nan')], [float(314), float(-1), float('nan'), float(1970), 7.3, float(-1), float(-1)], [float('nan'), 0.0, float(1970), 7.3, float('nan')], [float('nan')]]) - self1 = matrix.Matrix([[float('nan'), 0.0, float(1970), 7.3, float('nan')], [float(10 ** 23), float('1.4'), float(-1), float(-1), float('nan'), float('nan'), float(1970)], [float('nan'), 0.0, float(1970), 7.3, float('nan')], [float(314), float(-1), float('nan'), float(1970), 7.3, float(-1), float(-1)], [float('nan'), 0.0, float(1970), 7.3, float('nan')], [float('nan')]]) - - actual = matrix1.__add__(self1) - - matrix2 = copyreg._reconstructor(matrix.Matrix, builtins.object, None) - matrix2.dim = (6, 7) - matrix2.elements = [[float('nan'), 0.0, 3940.0, 14.6, float('nan'), 0, 0], [2e+23, 2.8, -2.0, -2.0, float('nan'), float('nan'), 3940.0], [float('nan'), 0.0, 3940.0, 14.6, float('nan'), 0, 0], [628.0, -2.0, float('nan'), 3940.0, 14.6, -2.0, -2.0], [float('nan'), 0.0, 3940.0, 14.6, float('nan'), 0, 0], [float('nan'), 0, 0, 0, 0, 0, 0]] - actual_dim = actual.dim - expected_dim = matrix2.dim - - self.assertEqual(expected_dim, actual_dim) - actual_elements = actual.elements - expected_elements = matrix2.elements - expected_list = expected_elements - expected_length = len(expected_list) - actual_length = len(actual_elements) - - self.assertEqual(expected_length, actual_length) - - self.assertTrue(isinstance(actual_elements, builtins.list)) - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__primitive_types.py b/utbot-python/samples/cli_utbot_tests/generated_tests__primitive_types.py deleted file mode 100644 index 16f8f8423f..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__primitive_types.py +++ /dev/null @@ -1,40 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import primitive_types -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable primitive_types.pretty_print - # region - def test_pretty_print(self): - actual = primitive_types.pretty_print(object()) - - self.assertEqual('I do not have any variants', actual) - - def test_pretty_print1(self): - actual = primitive_types.pretty_print(str(b'\x80')) - - self.assertEqual("It is string.\nValue <>", actual) - - def test_pretty_print2(self): - actual = primitive_types.pretty_print((1 << 100)) - - self.assertEqual('It is integer.\nValue 1267650600228229401496703205376', actual) - - def test_pretty_print3(self): - actual = primitive_types.pretty_print(complex(float('inf'), float('inf'))) - - self.assertEqual('It is complex.\nValue (inf + infi)', actual) - - def test_pretty_print4(self): - actual = primitive_types.pretty_print([]) - - self.assertEqual('It is list.\nValue []', actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__quick_sort.py b/utbot-python/samples/cli_utbot_tests/generated_tests__quick_sort.py deleted file mode 100644 index ea0cf1a849..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__quick_sort.py +++ /dev/null @@ -1,30 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import quick_sort -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable quick_sort.quick_sort - # region - def test_quick_sort(self): - actual = quick_sort.quick_sort([4294967297, 83, (1 << 100), 4294967297, (1 << 100), 0, -3]) - - self.assertEqual([-3, 0, 83, 4294967297, 4294967297, 1267650600228229401496703205376, 1267650600228229401496703205376], actual) - - def test_quick_sort1(self): - actual = quick_sort.quick_sort([83, 123]) - - self.assertEqual([83, 123], actual) - - def test_quick_sort2(self): - actual = quick_sort.quick_sort([]) - - self.assertEqual([], actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__test_coverage.py b/utbot-python/samples/cli_utbot_tests/generated_tests__test_coverage.py deleted file mode 100644 index 02bcda08b6..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__test_coverage.py +++ /dev/null @@ -1,35 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import test_coverage -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable test_coverage.hard_function - # region - def test_hard_function(self): - actual = test_coverage.hard_function(83) - - self.assertEqual(2, actual) - - def test_hard_function1(self): - actual = test_coverage.hard_function(0) - - self.assertEqual(1, actual) - - def test_hard_function2(self): - actual = test_coverage.hard_function(4294967296) - - self.assertEqual(3, actual) - - def test_hard_function3(self): - actual = test_coverage.hard_function(float('nan')) - - self.assertEqual(4, actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__type_inference.py b/utbot-python/samples/cli_utbot_tests/generated_tests__type_inference.py deleted file mode 100644 index 450f3f0488..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__type_inference.py +++ /dev/null @@ -1,20 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import type_inference -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable type_inference.type_inference - # region - def test_type_inference_by_fuzzer(self): - actual = type_inference.type_inference(0, str(), str(b'\x80'), [], {}) - - self.assertEqual([0, 0, 0, 0, 0, 0, 0, 0, 0, ''], actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/cli_utbot_tests/generated_tests__using_collections.py b/utbot-python/samples/cli_utbot_tests/generated_tests__using_collections.py deleted file mode 100644 index f9fe1c7d4a..0000000000 --- a/utbot-python/samples/cli_utbot_tests/generated_tests__using_collections.py +++ /dev/null @@ -1,23 +0,0 @@ -import sys -sys.path.append('samples') -import builtins -import using_collections -import collections -import unittest - - -class TestTopLevelFunctions(unittest.TestCase): - # region Test suites for executable using_collections.generate_collections - # region - def test_generate_collections(self): - actual = using_collections.generate_collections({}) - - counter = collections.Counter({0: 100, }) - - self.assertEqual([{0: 100, }, counter, [(0, 100)]], actual) - - # endregion - - # endregion - - diff --git a/utbot-python/samples/generate_test_samples.sh b/utbot-python/samples/generate_test_samples.sh deleted file mode 100644 index 73c765a72b..0000000000 --- a/utbot-python/samples/generate_test_samples.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Usage: -# ./generate_test_samples.sh - -python_path=$1 -java_path=$2 - -$java_path -jar utbot-cli.jar generate_python samples/arithmetic.py -p $python_path -o cli_utbot_tests/generated_tests__arithmetic.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/deep_equals.py -p $python_path -o cli_utbot_tests/generated_tests__deep_equals.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/dicts.py -p $python_path -o cli_utbot_tests/generated_tests__dicts.py -s samples/ --timeout-for-run 500 --visit-only-specified-source -c Dictionary -m translate --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/deque.py -p $python_path -o cli_utbot_tests/generated_tests__deque.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/dummy_with_eq.py -p $python_path -o cli_utbot_tests/generated_tests__dummy_with_eq.py -s samples/ --timeout-for-run 500 --visit-only-specified-source -c Dummy -m propogate --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/dummy_without_eq.py -p $python_path -o cli_utbot_tests/generated_tests__dummy_without_eq.py -s samples/ --timeout-for-run 500 --visit-only-specified-source -c Dummy -m propogate --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/lists.py -p $python_path -o cli_utbot_tests/generated_tests__lists.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/list_of_datetime.py -p $python_path -o cli_utbot_tests/generated_tests__list_of_datetime.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/longest_subsequence.py -p $python_path -o cli_utbot_tests/generated_tests__longest_subsequence.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/matrix.py -p $python_path -o cli_utbot_tests/generated_tests__matrix.py -s samples/ --timeout-for-run 500 --visit-only-specified-source -c Matrix -m __add__,__mul__,__matmul__ --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/primitive_types.py -p $python_path -o cli_utbot_tests/generated_tests__primitive_types.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/quick_sort.py -p $python_path -o cli_utbot_tests/generated_tests__quick_sort.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/test_coverage.py -p $python_path -o cli_utbot_tests/generated_tests__test_coverage.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/type_inference.py -p $python_path -o cli_utbot_tests/generated_tests__type_inference.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/using_collections.py -p $python_path -o cli_utbot_tests/generated_tests__using_collections.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/dummy_without_eq.py -p $python_path -o cli_utbot_tests/generated_tests__dummy_without_eq.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 -c Dummy -m propagate --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/dummy_with_eq.py -p $python_path -o cli_utbot_tests/generated_tests__dummy_with_eq.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 -c Dummy -m propagate --do-not-check-requirements -$java_path -jar utbot-cli.jar generate_python samples/list_of_datetime.py -p $python_path -o cli_utbot_tests/generated_tests__list_of_datetime.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000 --do-not-check-requirements diff --git a/utbot-python/samples/run_test_samples.sh b/utbot-python/samples/run_test_samples.sh deleted file mode 100755 index bbbf1bb171..0000000000 --- a/utbot-python/samples/run_test_samples.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Usage: -# ./run_test_samples.sh - -python_path=$1 -java_path=$2 - -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__arithmetic.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__deep_equals.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__dicts.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__deque.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__dummy_with_eq.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__dummy_without_eq.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__lists.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__list_of_datetime.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__longest_subsequence.py -p $python_path -$java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__matrix.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__primitive_types.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__quick_sort.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__test_coverage.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__type_inference.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__using_collections.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__dummy_with_eq.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__dummy_without_eq.py -p $python_path -# $java_path -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__list_of_datetime.py -p $python_path diff --git a/utbot-python/samples/samples/collection/using_collections.py b/utbot-python/samples/samples/collection/using_collections.py index debdc31bef..e8a5e9e1ae 100644 --- a/utbot-python/samples/samples/collection/using_collections.py +++ b/utbot-python/samples/samples/collection/using_collections.py @@ -3,6 +3,8 @@ def generate_collections(collection): collection[0] = 100 + if isinstance(collection, collections.UserDict): + return collection.data elements = list(collection.items()) return [ collection, diff --git a/utbot-python/samples/samples/named_arguments/method_named_arguments.py b/utbot-python/samples/samples/named_arguments/method_named_arguments.py index 10a61f8f63..f86c3d623a 100644 --- a/utbot-python/samples/samples/named_arguments/method_named_arguments.py +++ b/utbot-python/samples/samples/named_arguments/method_named_arguments.py @@ -1,4 +1,5 @@ -from samples.named_arguments.named_arguments import g +def g(x): + return x ** 2 class A: diff --git a/utbot-python/samples/testing_utils/collect_executions.py b/utbot-python/samples/testing_utils/collect_executions.py new file mode 100644 index 0000000000..81404aa023 --- /dev/null +++ b/utbot-python/samples/testing_utils/collect_executions.py @@ -0,0 +1,34 @@ +import json +import pathlib +import sys +import typing + + +def get_all_files(folder: pathlib.Path) -> typing.List[pathlib.Path]: + if folder.is_dir: + return folder.glob("*.executions") + return [] + + +def get_excecutions_number(file: pathlib.Path) -> int: + with open(file, 'r', encoding='utf-8') as fin: + return int(json.loads(fin.readline().strip())['executions']) + + +def save_data(data: typing.Dict[pathlib.Path, int]) -> None: + with open('data_executions.json', 'w', encoding='utf-8') as fout: + print(json.dumps(data, indent=1), file=fout) + + +def main(folder: pathlib.Path) -> None: + files = get_all_files(folder) + data = { + str(file): get_excecutions_number(file) + for file in files + } + save_data(data) + + +if __name__ == '__main__': + main(pathlib.Path(sys.argv[1])) + diff --git a/utbot-python/samples/testing_utils/collect_timeouts.py b/utbot-python/samples/testing_utils/collect_timeouts.py new file mode 100644 index 0000000000..bbcb8241a2 --- /dev/null +++ b/utbot-python/samples/testing_utils/collect_timeouts.py @@ -0,0 +1,41 @@ +import json +import pathlib +import sys +import typing + +def read_test_config(path: pathlib.Path, coverage_dir: pathlib.Path) -> typing.Dict[str, int]: + with open(path, 'r', encoding='utf-8') as fin: + data = json.loads(fin.read()) + + res = {} + for part in data['parts']: + for file in part['files']: + for group in file['groups']: + file_suffix = f"{part['path'].replace('/', '_')}_{file['name']}" + executions_output_file = pathlib.Path(coverage_dir, f"coverage_{file_suffix}.json.executions") + timeout = group['timeout'] + res[executions_output_file] = timeout + return res + + +def read_executions(path: pathlib.Path): + with open(path, 'r', encoding='utf-8') as fin: + data = json.loads(fin.read()) + return data + + +def main(config_path: pathlib.Path, executions_path: pathlib.Path, coverage_dir: pathlib.Path): + timeouts = read_test_config(config_path, coverage_dir) + executions = read_executions(executions_path) + + for f, timeout in timeouts.items(): + executions[str(f)] /= timeout + + with open('speeds.json', 'w') as fout: + print(json.dumps(executions, indent=1), file=fout) + + +if __name__ == '__main__': + main(*sys.argv[1:]) + + diff --git a/utbot-python/samples/testing_utils/compare.py b/utbot-python/samples/testing_utils/compare.py new file mode 100644 index 0000000000..cb45d0cc49 --- /dev/null +++ b/utbot-python/samples/testing_utils/compare.py @@ -0,0 +1,25 @@ +import json +import matplotlib.pyplot as plt +import pathlib + + +def read_stats(path: pathlib.Path): + with open(path, 'r') as fin: + return json.loads(fin.read()) + + +data1 = read_stats('speeds_basic.json') +data2 = read_stats('speeds_forks.json') +data3 = read_stats('speeds_forks2.json') +data = [list(d.values()) for d in [data1, data2, data3]] + +fig = plt.figure() +ax = fig.add_subplot(1, 1, 1) +ax.boxplot( + data, + labels=['basic', 'forks', 'forks2'], + vert=True, + patch_artist=True + ) +ax.grid(True) +plt.show() diff --git a/utbot-python/src/main/kotlin/org/utbot/python/PythonEngine.kt b/utbot-python/src/main/kotlin/org/utbot/python/PythonEngine.kt index 6899ad1265..cc0730bffe 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/PythonEngine.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/PythonEngine.kt @@ -20,8 +20,13 @@ import org.utbot.python.framework.api.python.PythonUtExecution import org.utbot.python.fuzzing.* import org.utbot.python.newtyping.PythonTypeHintsStorage import org.utbot.python.newtyping.general.UtType +import org.utbot.python.newtyping.inference.InvalidTypeFeedback +import org.utbot.python.newtyping.inference.SuccessFeedback +import org.utbot.python.newtyping.inference.baseline.BaselineAlgorithm import org.utbot.python.newtyping.pythonModules import org.utbot.python.newtyping.pythonTypeRepresentation +import org.utbot.python.utils.ExecutionWithTimoutMode +import org.utbot.python.utils.TestGenerationLimitManager import org.utbot.python.utils.camelToSnakeCase import org.utbot.summary.fuzzer.names.TestSuggestedInfo import java.net.ServerSocket @@ -120,6 +125,7 @@ class PythonEngine( ) return ValidExecution(utFuzzedExecution) } + private fun handleSuccessResult( arguments: List, types: List, @@ -203,8 +209,7 @@ class PythonEngine( .filterNot { it.startsWith(moduleToImport) } val localAdditionalModules = (additionalModules + argumentModules + moduleToImport).toSet() - val (thisObject, modelList) = - if (methodUnderTest.hasThisArgument) + val (thisObject, modelList) = if (methodUnderTest.hasThisArgument) Pair(argumentValues[0], argumentValues.drop(1)) else Pair(null, argumentValues) @@ -219,11 +224,13 @@ class PythonEngine( return when (val evaluationResult = manager.runWithCoverage(functionArguments, localAdditionalModules, coverageId)) { is PythonEvaluationError -> { + val stackTraceMessage = evaluationResult.stackTrace.joinToString("\n") val utError = UtError( - "Error evaluation: ${evaluationResult.status}, ${evaluationResult.message}", - Throwable(evaluationResult.stackTrace.joinToString("\n")) + "Error evaluation: ${evaluationResult.status}, ${evaluationResult.message}\n${stackTraceMessage}", + Throwable(stackTraceMessage) ) - logger.debug(evaluationResult.stackTrace.joinToString("\n")) + description.limitManager.addInvalidExecution() + logger.debug(stackTraceMessage) PythonExecutionResult(InvalidExecution(utError), PythonFeedback(control = Control.PASS)) } @@ -237,33 +244,39 @@ class PythonEngine( Trie.emptyNode() else description.tracer.add(coveredInstructions) + description.limitManager.addInvalidExecution() PythonExecutionResult( utTimeoutException, - PythonFeedback(control = Control.PASS, result = trieNode) + PythonFeedback(control = Control.PASS, result = trieNode, SuccessFeedback) ) } is PythonEvaluationSuccess -> { val coveredInstructions = evaluationResult.coverage.coveredInstructions - when (val result = handleSuccessResult( - arguments, - parameters, - evaluationResult, - description, - )) { + val result = handleSuccessResult( + arguments, + parameters, + evaluationResult, + description, + ) + val typeInferenceFeedback = if (result is ValidExecution) SuccessFeedback else InvalidTypeFeedback + when (result) { is ValidExecution -> { val trieNode: Trie.Node = description.tracer.add(coveredInstructions) + description.limitManager.addSuccessExecution() PythonExecutionResult( result, - PythonFeedback(control = Control.CONTINUE, result = trieNode) + PythonFeedback(Control.CONTINUE, trieNode, typeInferenceFeedback) ) } is InvalidExecution -> { - PythonExecutionResult(result, PythonFeedback(control = Control.CONTINUE)) + description.limitManager.addInvalidExecution() + PythonExecutionResult(result, PythonFeedback(control = Control.CONTINUE, typeInferenceFeedback = typeInferenceFeedback)) } else -> { - PythonExecutionResult(result, PythonFeedback(control = Control.PASS)) + description.limitManager.addInvalidExecution() + PythonExecutionResult(result, PythonFeedback(control = Control.PASS, typeInferenceFeedback = typeInferenceFeedback)) } } } @@ -274,7 +287,12 @@ class PythonEngine( } } - fun fuzzing(parameters: List, isCancelled: () -> Boolean, until: Long): Flow = flow { + fun fuzzing( + parameters: List, + typeInferenceAlgorithm: BaselineAlgorithm, + isCancelled: () -> Boolean, + until: Long + ): Flow = flow { ServerSocket(0).use { serverSocket -> logger.debug { "Server port: ${serverSocket.localPort}" } val manager = try { @@ -295,6 +313,8 @@ class PythonEngine( pythonTypeStorage, Trie(Instruction::id), Random(0), + TestGenerationLimitManager(ExecutionWithTimoutMode, until, isRootManager = true), + methodUnderTest.definition.type, ) try { @@ -305,7 +325,7 @@ class PythonEngine( } } else { try { - PythonFuzzing(pmd.pythonTypeStorage) { description, arguments -> + PythonFuzzing(pythonTypeStorage, typeInferenceAlgorithm) { description, arguments -> if (isCancelled()) { logger.debug { "Fuzzing process was interrupted" } manager.disconnect() @@ -319,6 +339,7 @@ class PythonEngine( if (arguments.any { PythonTree.containsFakeNode(it.tree) }) { logger.debug { "FakeNode in Python model" } + description.limitManager.addFakeNodeExecutions() emit(FakeNodeFeedback) return@PythonFuzzing PythonFeedback(control = Control.CONTINUE) } @@ -326,9 +347,10 @@ class PythonEngine( val pair = Pair(description, arguments.map { PythonTreeWrapper(it.tree) }) val mem = cache.get(pair) if (mem != null) { - logger.debug("Repeat in fuzzing") + logger.debug("Repeat in fuzzing ${arguments.map {it.tree}}") + description.limitManager.addSuccessExecution() emit(CachedExecutionFeedback(mem.fuzzingExecutionFeedback)) - return@PythonFuzzing mem.fuzzingPlatformFeedback + return@PythonFuzzing mem.fuzzingPlatformFeedback.fromCache() } val result = fuzzingResultHandler(description, arguments, parameters, manager) if (result == null) { // timeout diff --git a/utbot-python/src/main/kotlin/org/utbot/python/PythonTestCaseGenerator.kt b/utbot-python/src/main/kotlin/org/utbot/python/PythonTestCaseGenerator.kt index 1500a6b801..f6ad5c1419 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/PythonTestCaseGenerator.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/PythonTestCaseGenerator.kt @@ -14,9 +14,6 @@ import org.utbot.python.newtyping.ast.visitor.Visitor import org.utbot.python.newtyping.ast.visitor.constants.ConstantCollector import org.utbot.python.newtyping.ast.visitor.hints.HintCollector import org.utbot.python.newtyping.general.* -import org.utbot.python.newtyping.inference.InferredTypeFeedback -import org.utbot.python.newtyping.inference.InvalidTypeFeedback -import org.utbot.python.newtyping.inference.SuccessFeedback import org.utbot.python.newtyping.inference.baseline.BaselineAlgorithm import org.utbot.python.newtyping.mypy.GlobalNamesStorage import org.utbot.python.newtyping.mypy.MypyInfoBuild @@ -24,7 +21,6 @@ import org.utbot.python.newtyping.mypy.MypyReportLine import org.utbot.python.newtyping.mypy.getErrorNumber import org.utbot.python.newtyping.utils.getOffsetLine import org.utbot.python.newtyping.utils.isRequired -import org.utbot.python.utils.ExecutionWithTimeoutMode import org.utbot.python.utils.TestGenerationLimitManager import org.utbot.python.utils.PriorityCartesianProduct import org.utbot.python.utils.TimeoutMode @@ -134,7 +130,7 @@ class PythonTestCaseGenerator( additionalVars: String = "", ): Set? { // returns missing lines val limitManager = TestGenerationLimitManager( - ExecutionWithTimeoutMode, + TimeoutMode, until, ) var missingLines = initMissingLines @@ -150,52 +146,66 @@ class PythonTestCaseGenerator( PythonFuzzedConcreteValue(type, value) } - inferAnnotations( + val engine = PythonEngine( method, - mypyStorage, - typeStorage, - hintCollector, - mypyReportLine, - limitManager, - additionalVars - ) { functionType -> - val args = (functionType as FunctionType).arguments - - logger.debug { "Inferred annotations: ${args.joinToString { it.pythonTypeRepresentation() }}" } - - val engine = PythonEngine( - method, - directoriesForSysPath, - curModule, - pythonPath, - constants, - timeoutForRun, - PythonTypeHintsStorage.get(mypyStorage) - ) + directoriesForSysPath, + curModule, + pythonPath, + constants, + timeoutForRun, + PythonTypeHintsStorage.get(mypyStorage) + ) + val namesInModule = mypyStorage.names + .getOrDefault(curModule, emptyList()) + .map { it.name } + .filter { + it.length < 4 || !it.startsWith("__") || !it.endsWith("__") + } - var feedback: InferredTypeFeedback = SuccessFeedback + val algo = BaselineAlgorithm( + typeStorage, + hintCollector.result, + pythonPath, + method, + directoriesForSysPath, + curModule, + namesInModule, + getErrorNumber( + mypyReportLine, + fileOfMethod, + getOffsetLine(sourceFileContent, method.ast.beginOffset), + getOffsetLine(sourceFileContent, method.ast.endOffset) + ), + mypyStorage.buildRoot.configFile, + additionalVars, + randomTypeFrequency = RANDOM_TYPE_FREQUENCY, + dMypyTimeout = timeoutForRun, + ) - val fuzzerCancellation = { isCancelled() || limitManager.isCancelled() } + val fuzzerCancellation = { isCancelled() || limitManager.isCancelled() } - engine.fuzzing(args, fuzzerCancellation, until).collect { + val initFunctionType = method.definition.type.arguments + runBlocking { + engine.fuzzing( + initFunctionType, + algo, + fuzzerCancellation, + until + ).collect { when (it) { is ValidExecution -> { executions += it.utFuzzedExecution missingLines = updateMissingLines(it.utFuzzedExecution, coveredLines, missingLines) - feedback = SuccessFeedback limitManager.addSuccessExecution() } is InvalidExecution -> { errors += it.utError - feedback = InvalidTypeFeedback limitManager.addInvalidExecution() } is ArgumentsTypeErrorFeedback -> { - feedback = InvalidTypeFeedback limitManager.addInvalidExecution() } is TypeErrorFeedback -> { - feedback = InvalidTypeFeedback limitManager.addInvalidExecution() } is CachedExecutionFeedback -> { @@ -209,14 +219,13 @@ class PythonTestCaseGenerator( } } is FakeNodeFeedback -> { - limitManager.addFakeNodeExecutions() + limitManager.addFakeNodeExecutions() } } limitManager.missedLines = missingLines?.size } - limitManager.restart() - feedback } + return missingLines } @@ -270,7 +279,8 @@ class PythonTestCaseGenerator( else coverageExecutions + emptyCoverageExecutions.take(MAX_EMPTY_COVERAGE_TESTS), errors, - storageForMypyMessages + storageForMypyMessages, + executionsNumber = executions.size, ) } @@ -291,58 +301,6 @@ class PythonTestCaseGenerator( return if (missingLines == null) curMissing else missingLines intersect curMissing } - private fun inferAnnotations( - method: PythonMethod, - mypyStorage: MypyInfoBuild, - typeStorage: PythonTypeHintsStorage, - hintCollector: HintCollector, - report: List, - limitManager: TestGenerationLimitManager, - additionalVars: String, - annotationHandler: suspend (UtType) -> InferredTypeFeedback, - ) { - val namesInModule = mypyStorage.names - .getOrDefault(curModule, emptyList()) - .map { it.name } - .filter { - it.length < 4 || !it.startsWith("__") || !it.endsWith("__") - } - val typeInferenceCancellation = { isCancelled() || limitManager.isCancelled() } - - val algo = BaselineAlgorithm( - typeStorage, - pythonPath, - method, - directoriesForSysPath, - curModule, - namesInModule, - getErrorNumber( - report, - fileOfMethod, - getOffsetLine(sourceFileContent, method.ast.beginOffset), - getOffsetLine(sourceFileContent, method.ast.endOffset) - ), - mypyStorage.buildRoot.configFile, - additionalVars, - randomTypeFrequency = RANDOM_TYPE_FREQUENCY, - dMypyTimeout = timeoutForRun - ) - - runBlocking breaking@{ - if (typeInferenceCancellation()) { - return@breaking - } - - val iterationNumber = algo.run(hintCollector.result, typeInferenceCancellation, annotationHandler) - - if (iterationNumber == 1) { // Initial annotation can't be substituted - limitManager.mode = TimeoutMode - val existsAnnotation = method.definition.type - annotationHandler(existsAnnotation) - } - } - } - companion object { fun createShortForm(method: PythonMethod): Pair? { val meta = method.definition.type.pythonDescription() as PythonCallableTypeDescription diff --git a/utbot-python/src/main/kotlin/org/utbot/python/UTPythonAPI.kt b/utbot-python/src/main/kotlin/org/utbot/python/UTPythonAPI.kt index 4b02bfa386..57da4cc17d 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/UTPythonAPI.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/UTPythonAPI.kt @@ -71,6 +71,7 @@ data class PythonTestSet( val errors: List, val mypyReport: List, val classId: PythonClassId? = null, + val executionsNumber: Int = 0, ) data class FunctionArguments( diff --git a/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt b/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt index 6cbfbb5096..8726c9af13 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt @@ -56,13 +56,13 @@ internal class PytestManager(context: CgContext) : TestFrameworkManager(context) override fun disableTestMethod(reason: String) { require(testFramework is Pytest) { "According to settings, Pytest was expected, but got: $testFramework" } - context.importIfNeeded(testFramework.skipDecoratorClassId) + context.importIfNeeded(Pytest.skipDecoratorClassId) val reasonArgument = CgNamedAnnotationArgument( name = "reason", value = CgPythonRepr(pythonStrClassId, "'${reason.replace("\"", "'")}'"), ) statementConstructor.addAnnotation( - classId = testFramework.skipDecoratorClassId, + classId = Pytest.skipDecoratorClassId, namedArguments = listOf(reasonArgument), target = Method ) @@ -145,11 +145,10 @@ internal class UnittestManager(context: CgContext) : TestFrameworkManager(contex value = CgPythonRepr(pythonStrClassId, "'${reason.replace("\"", "'")}'"), ) statementConstructor.addAnnotation( - classId = testFramework.skipDecoratorClassId, + classId = Unittest.skipDecoratorClassId, namedArguments = listOf(reasonArgument), target = Method, - - ) + ) } fun assertIsinstance(types: List, actual: CgVariable) { diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/PythonApi.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/PythonApi.kt index 6f6f5c98ad..00c3fb48e2 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/PythonApi.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/PythonApi.kt @@ -11,7 +11,15 @@ import org.utbot.python.framework.api.python.PythonUtExecution import org.utbot.python.fuzzing.provider.* import org.utbot.python.fuzzing.provider.utils.isAny import org.utbot.python.newtyping.* +import org.utbot.python.newtyping.general.FunctionType import org.utbot.python.newtyping.general.UtType +import org.utbot.python.newtyping.inference.InferredTypeFeedback +import org.utbot.python.newtyping.inference.InvalidTypeFeedback +import org.utbot.python.newtyping.inference.SuccessFeedback +import org.utbot.python.newtyping.inference.baseline.BaselineAlgorithm +import org.utbot.python.utils.ExecutionWithTimoutMode +import org.utbot.python.utils.TestGenerationLimitManager +import org.utbot.python.utils.TimeoutMode import kotlin.random.Random private val logger = KotlinLogging.logger {} @@ -29,6 +37,8 @@ class PythonMethodDescription( val pythonTypeStorage: PythonTypeHintsStorage, val tracer: Trie, val random: Random, + val limitManager: TestGenerationLimitManager, + val type: FunctionType, ) : Description(parameters) sealed interface FuzzingExecutionFeedback @@ -47,7 +57,18 @@ data class PythonExecutionResult( data class PythonFeedback( override val control: Control = Control.CONTINUE, val result: Trie.Node = Trie.emptyNode(), -) : Feedback + val typeInferenceFeedback: InferredTypeFeedback = InvalidTypeFeedback, + val fromCache: Boolean = false, +) : Feedback { + fun fromCache(): PythonFeedback { + return PythonFeedback( + control = control, + result = result, + typeInferenceFeedback = typeInferenceFeedback, + fromCache = true, + ) + } +} class PythonFuzzedValue( val tree: PythonTree.PythonTreeNode, @@ -76,8 +97,21 @@ fun pythonDefaultValueProviders(typeStorage: PythonTypeHintsStorage) = listOf( SubtypeValueProvider(typeStorage) ) +fun pythonAnyTypeValueProviders() = listOf( + NoneValueProvider, + BoolValueProvider, + IntValueProvider, + FloatValueProvider, + ComplexValueProvider, + StrValueProvider, + BytesValueProvider, + BytearrayValueProvider, + ConstantValueProvider, +) + class PythonFuzzing( private val pythonTypeStorage: PythonTypeHintsStorage, + private val typeInferenceAlgorithm: BaselineAlgorithm, val execute: suspend (description: PythonMethodDescription, values: List) -> PythonFeedback, ) : Fuzzing { @@ -103,6 +137,50 @@ class PythonFuzzing( } override suspend fun handle(description: PythonMethodDescription, values: List): PythonFeedback { - return execute(description, values) + val result = execute(description, values) + if (result.typeInferenceFeedback is SuccessFeedback && !result.fromCache) { + typeInferenceAlgorithm.laudType(description.type) + } + if (description.limitManager.isCancelled()) { + typeInferenceAlgorithm.feedbackState(description.type, result.typeInferenceFeedback) + } + return result + } + + private suspend fun forkType(description: PythonMethodDescription, stats: Statistic) { + val type: UtType? = typeInferenceAlgorithm.expandState() + if (type != null) { + val newTypes = (type as FunctionType).arguments + val d = PythonMethodDescription( + description.name, + newTypes, + description.concreteValues, + description.pythonTypeStorage, + description.tracer, + description.random, + TestGenerationLimitManager(ExecutionWithTimoutMode, description.limitManager.until), + type + ) + if (!d.limitManager.isCancelled()) { + logger.debug { "Fork new type" } + fork(d, stats) + } + logger.debug { "Fork ended" } + } else { + description.limitManager.mode = TimeoutMode + } + } + + override suspend fun isCancelled( + description: PythonMethodDescription, + stats: Statistic + ): Boolean { + if (description.limitManager.isCancelled() || description.parameters.any { it.isAny() }) { + forkType(description, stats) + if (description.limitManager.isRootManager) { + return TimeoutMode.isCancelled(description.limitManager) + } + } + return description.limitManager.isCancelled() } } diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/BoolValueProvider.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/BoolValueProvider.kt index 929ff35dae..17dbf7c2ef 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/BoolValueProvider.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/BoolValueProvider.kt @@ -9,13 +9,12 @@ import org.utbot.python.framework.api.python.util.pythonBoolClassId import org.utbot.python.fuzzing.PythonFuzzedValue import org.utbot.python.fuzzing.PythonMethodDescription import org.utbot.python.fuzzing.provider.utils.generateSummary -import org.utbot.python.fuzzing.provider.utils.isAny import org.utbot.python.newtyping.general.UtType import org.utbot.python.newtyping.pythonTypeName object BoolValueProvider : ValueProvider{ override fun accept(type: UtType): Boolean { - return type.pythonTypeName() == pythonBoolClassId.canonicalName || type.isAny() + return type.pythonTypeName() == pythonBoolClassId.canonicalName } override fun generate(description: PythonMethodDescription, type: UtType) = sequence { diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ComplexValueProvider.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ComplexValueProvider.kt index c8e910e61a..c756cd20eb 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ComplexValueProvider.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ComplexValueProvider.kt @@ -7,22 +7,28 @@ import org.utbot.python.framework.api.python.PythonTree import org.utbot.python.framework.api.python.util.pythonComplexClassId import org.utbot.python.fuzzing.PythonFuzzedValue import org.utbot.python.fuzzing.PythonMethodDescription -import org.utbot.python.fuzzing.provider.utils.isAny +import org.utbot.python.newtyping.createPythonUnionType import org.utbot.python.newtyping.general.UtType import org.utbot.python.newtyping.pythonTypeName import org.utbot.python.newtyping.pythonTypeRepresentation object ComplexValueProvider : ValueProvider { override fun accept(type: UtType): Boolean { - return type.pythonTypeName() == pythonComplexClassId.canonicalName || type.isAny() + return type.pythonTypeName() == pythonComplexClassId.canonicalName } override fun generate(description: PythonMethodDescription, type: UtType) = sequence { + val numberType = createPythonUnionType( + listOf( + description.pythonTypeStorage.pythonFloat, + description.pythonTypeStorage.pythonInt + ) + ) yield(Seed.Recursive( construct = Routine.Create( listOf( - description.pythonTypeStorage.pythonFloat, - description.pythonTypeStorage.pythonFloat, + numberType, + numberType ) ) { v -> val real = v[0].tree as PythonTree.PrimitiveNode diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ConstantValueProvider.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ConstantValueProvider.kt index 2194d13106..794c9c02d5 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ConstantValueProvider.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ConstantValueProvider.kt @@ -6,14 +6,13 @@ import org.utbot.python.framework.api.python.PythonClassId import org.utbot.python.framework.api.python.PythonTree import org.utbot.python.fuzzing.PythonFuzzedValue import org.utbot.python.fuzzing.PythonMethodDescription -import org.utbot.python.fuzzing.provider.utils.isAny import org.utbot.python.newtyping.general.UtType import org.utbot.python.newtyping.pythonTypeName import org.utbot.python.fuzzing.value.TypesFromJSONStorage object ConstantValueProvider : ValueProvider { override fun accept(type: UtType): Boolean { - return TypesFromJSONStorage.getTypesFromJsonStorage().containsKey(type.pythonTypeName()) || type.isAny() + return TypesFromJSONStorage.getTypesFromJsonStorage().containsKey(type.pythonTypeName()) } override fun generate(description: PythonMethodDescription, type: UtType): Sequence> = diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/FloatValueProvider.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/FloatValueProvider.kt index 94ed272496..496ac4b67a 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/FloatValueProvider.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/FloatValueProvider.kt @@ -10,7 +10,6 @@ import org.utbot.python.fuzzing.PythonFuzzedConcreteValue import org.utbot.python.fuzzing.PythonFuzzedValue import org.utbot.python.fuzzing.PythonMethodDescription import org.utbot.python.fuzzing.provider.utils.generateSummary -import org.utbot.python.fuzzing.provider.utils.isAny import org.utbot.python.newtyping.general.UtType import org.utbot.python.newtyping.pythonTypeName import java.math.BigDecimal @@ -18,7 +17,7 @@ import java.math.BigInteger object FloatValueProvider : ValueProvider { override fun accept(type: UtType): Boolean { - return type.pythonTypeName() == pythonFloatClassId.canonicalName || type.isAny() + return type.pythonTypeName() == pythonFloatClassId.canonicalName } private fun getFloatConstants(concreteValues: Collection): List { @@ -44,7 +43,7 @@ object FloatValueProvider : ValueProvider> = sequence { val floatConstants = getFloatConstants(description.concreteValues) val intConstants = getIntConstants(description.concreteValues) - val constants = floatConstants + intConstants + val constants = floatConstants + intConstants + listOf(0, 1).map { IEEE754Value.fromValue(it.toDouble()) } constants.asSequence().forEach { value -> yield(Seed.Known(value) { diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/IntValueProvider.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/IntValueProvider.kt index 38cb19a008..cf4f6d36dc 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/IntValueProvider.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/IntValueProvider.kt @@ -13,7 +13,6 @@ import org.utbot.python.fuzzing.PythonFuzzedConcreteValue import org.utbot.python.fuzzing.PythonFuzzedValue import org.utbot.python.fuzzing.PythonMethodDescription import org.utbot.python.fuzzing.provider.utils.generateSummary -import org.utbot.python.fuzzing.provider.utils.isAny import org.utbot.python.newtyping.general.UtType import org.utbot.python.newtyping.pythonTypeName import java.math.BigInteger @@ -24,7 +23,7 @@ object IntValueProvider : ValueProvider Unit): BitVectorValue { diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/NoneValueProvider.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/NoneValueProvider.kt index 7cd515d3f8..9d16d2db3f 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/NoneValueProvider.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/NoneValueProvider.kt @@ -5,13 +5,12 @@ import org.utbot.fuzzing.ValueProvider import org.utbot.python.framework.api.python.PythonTree import org.utbot.python.fuzzing.PythonFuzzedValue import org.utbot.python.fuzzing.PythonMethodDescription -import org.utbot.python.fuzzing.provider.utils.isAny import org.utbot.python.newtyping.PythonNoneTypeDescription import org.utbot.python.newtyping.general.UtType object NoneValueProvider : ValueProvider { override fun accept(type: UtType): Boolean { - return type.isAny() || type.meta is PythonNoneTypeDescription + return type.meta is PythonNoneTypeDescription } override fun generate(description: PythonMethodDescription, type: UtType): Sequence> = sequence { diff --git a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ReduceValueProvider.kt b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ReduceValueProvider.kt index 0af926c17c..5bcf23358a 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ReduceValueProvider.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/fuzzing/provider/ReduceValueProvider.kt @@ -8,6 +8,7 @@ import org.utbot.python.framework.api.python.PythonTree import org.utbot.python.framework.api.python.util.* import org.utbot.python.fuzzing.PythonFuzzedValue import org.utbot.python.fuzzing.PythonMethodDescription +import org.utbot.python.fuzzing.provider.utils.isAny import org.utbot.python.fuzzing.provider.utils.isCallable import org.utbot.python.fuzzing.provider.utils.isConcreteType import org.utbot.python.fuzzing.provider.utils.isMagic @@ -37,7 +38,7 @@ object ReduceValueProvider : ValueProvider Boolean, annotationHandler: suspend (UtType) -> InferredTypeFeedback, ): Int diff --git a/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/TypeInferenceProcessor.kt b/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/TypeInferenceProcessor.kt index 0947489929..be372bde78 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/TypeInferenceProcessor.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/TypeInferenceProcessor.kt @@ -90,6 +90,7 @@ class TypeInferenceProcessor( val algo = BaselineAlgorithm( typeStorage, + collector.result, pythonPath, pythonMethod, directoriesForSysPath, @@ -109,7 +110,7 @@ class TypeInferenceProcessor( startingTypeInferenceAction() val annotations = emptyList().toMutableList() runBlocking { - algo.run(collector.result, cancel) { + algo.run(cancel) { annotations.add(it) processSignature(it) SuccessFeedback diff --git a/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/baseline/BaselineAlgorithm.kt b/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/baseline/BaselineAlgorithm.kt index 278c1f0af8..5272f0ed40 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/baseline/BaselineAlgorithm.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/newtyping/inference/baseline/BaselineAlgorithm.kt @@ -25,6 +25,7 @@ private val logger = KotlinLogging.logger {} class BaselineAlgorithm( private val storage: PythonTypeHintsStorage, + private val hintCollectorResult: HintCollectorResult, private val pythonPath: String, private val pythonMethodCopy: PythonMethod, private val directoriesForSysPath: Set, @@ -38,20 +39,98 @@ class BaselineAlgorithm( ) : TypeInferenceAlgorithm() { private val random = Random(0) + private val generalRating = createGeneralTypeRating(hintCollectorResult, storage) + private val initialState = getInitialState(hintCollectorResult, generalRating) + private val states: MutableList = mutableListOf(initialState) + private val fileForMypyRuns = TemporaryFileManager.assignTemporaryFile(tag = "mypy.py") + private var iterationCounter = 0 + private var randomTypeCounter = 0 + + private val simpleTypes = simplestTypes(storage) + private val mixtureType = createPythonUnionType(simpleTypes) + + private val openedStates: MutableMap> = mutableMapOf() + private val statistic: MutableMap = mutableMapOf() + + private fun getRandomType(): UtType? { + val weights = states.map { 1.0 / (it.anyNodes.size * it.anyNodes.size + 1) } + val state = weightedRandom(states, weights, random) + val newState = expandState(state, storage, state.anyNodes.map { mixtureType }) + if (newState != null) { + logger.info("Random type: ${newState.signature.pythonTypeRepresentation()}") + openedStates[newState.signature] = newState to state + return newState.signature + } + return null + } + + private fun getLaudedType(): UtType? { + if (statistic.isEmpty()) return null + val sum = statistic.values.sum() + val weights = statistic.values.map { it.toDouble() / sum } + val newType = weightedRandom(statistic.keys.toList(), weights, random) + logger.info("Lauded type: ${newType.pythonTypeRepresentation()}") + return newType + } + + fun expandState(): UtType? { + if (states.isEmpty()) return null + + logger.debug("State number: ${states.size}") + iterationCounter++ + + if (randomTypeFrequency > 0 && iterationCounter % randomTypeFrequency == 0) { + randomTypeCounter++ + if (randomTypeCounter % 2 == 0) { + val laudedType = getLaudedType() + if (laudedType != null) return laudedType + } + val randomType = getRandomType() + if (randomType != null) return randomType + } + + val state = chooseState(states) + val newState = expandState(state, storage) + if (newState != null) { + logger.info("Checking ${newState.signature.pythonTypeRepresentation()}") + if (checkSignature(newState.signature as FunctionType, fileForMypyRuns, configFile)) { + logger.debug("Found new state!") + openedStates[newState.signature] = newState to state + return newState.signature + } + } else if (state.anyNodes.isEmpty()) { + logger.info("Checking ${state.signature.pythonTypeRepresentation()}") + if (checkSignature(state.signature as FunctionType, fileForMypyRuns, configFile)) { + return state.signature + } else { + states.remove(state) + } + } else { + states.remove(state) + } + return expandState() + } + + fun feedbackState(signature: UtType, feedback: InferredTypeFeedback) { + val stateInfo = openedStates[signature] + if (stateInfo != null) { + val (newState, parent) = stateInfo + when (feedback) { + SuccessFeedback -> { + states.add(newState) + parent.children += 1 + } + InvalidTypeFeedback -> {} + } + openedStates.remove(signature) + } + } + + override suspend fun run( - hintCollectorResult: HintCollectorResult, isCancelled: () -> Boolean, annotationHandler: suspend (UtType) -> InferredTypeFeedback, ): Int { - val generalRating = createGeneralTypeRating(hintCollectorResult, storage) - val initialState = getInitialState(hintCollectorResult, generalRating) - val states: MutableList = mutableListOf(initialState) - val fileForMypyRuns = TemporaryFileManager.assignTemporaryFile(tag = "mypy.py") - var iterationCounter = 0 - - val simpleTypes = simplestTypes(storage) - val mixtureType = createPythonUnionType(simpleTypes) - run breaking@ { while (states.isNotEmpty()) { if (isCancelled()) @@ -78,8 +157,6 @@ class BaselineAlgorithm( logger.info("Checking ${newState.signature.pythonTypeRepresentation()}") if (checkSignature(newState.signature as FunctionType, fileForMypyRuns, configFile)) { logger.debug("Found new state!") -// annotationHandler(newState.signature) -// states.add(newState) when (annotationHandler(newState.signature)) { SuccessFeedback -> { states.add(newState) @@ -143,4 +220,8 @@ class BaselineAlgorithm( } return BaselineAlgorithmState(allNodes, generalRating, storage) } + + fun laudType(type: FunctionType) { + statistic[type] = statistic[type]?.plus(1) ?: 1 + } } \ No newline at end of file diff --git a/utbot-python/src/main/kotlin/org/utbot/python/utils/TestGenerationLimitManager.kt b/utbot-python/src/main/kotlin/org/utbot/python/utils/TestGenerationLimitManager.kt index b731bf3ffd..77b3354b58 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/utils/TestGenerationLimitManager.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/utils/TestGenerationLimitManager.kt @@ -8,17 +8,21 @@ class TestGenerationLimitManager( // local settings: one type inference iteration var executions: Int = 150, var invalidExecutions: Int = 10, - var fakeNodeExecutions: Int = 20, + var cacheNodeExecutions: Int = 20, + var fakeNodeExecutions: Int = 1, var missedLines: Int? = null, + val isRootManager: Boolean = false, ) { private val initExecution = executions private val initInvalidExecutions = invalidExecutions + private val initCacheNodeExecutions = cacheNodeExecutions private val initFakeNodeExecutions = fakeNodeExecutions private val initMissedLines = missedLines fun restart() { executions = initExecution invalidExecutions = initInvalidExecutions + cacheNodeExecutions = initCacheNodeExecutions fakeNodeExecutions = initFakeNodeExecutions missedLines = initMissedLines } @@ -58,7 +62,7 @@ object TimeoutMode : LimitManagerMode { object ExecutionMode : LimitManagerMode { override fun isCancelled(manager: TestGenerationLimitManager): Boolean { - return manager.invalidExecutions <= 0 || manager.executions <= 0 || manager.fakeNodeExecutions <= 0 + return manager.invalidExecutions <= 0 || manager.executions <= 0 || manager.fakeNodeExecutions <= 0 || manager.cacheNodeExecutions <= 0 } } @@ -68,7 +72,7 @@ object MaxCoverageWithTimeoutMode : LimitManagerMode { } } -object ExecutionWithTimeoutMode : LimitManagerMode { +object ExecutionWithTimoutMode : LimitManagerMode { override fun isCancelled(manager: TestGenerationLimitManager): Boolean { return ExecutionMode.isCancelled(manager) || TimeoutMode.isCancelled(manager) } From df9705372b2f902344b2e1b53abf821310bf2b06 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Thu, 14 Sep 2023 13:34:35 +0300 Subject: [PATCH 04/43] Fix utbot-intellij --- gradle.properties | 4 +- settings.gradle.kts | 2 +- utbot-intellij-main/build.gradle.kts | 2 +- .../src/main/resources/META-INF/plugin.xml | 12 +-- .../plugin/python/PythonDialogProcessor.kt | 10 +- .../plugin/python/PythonIntellijProcessor.kt | 14 +++ .../generator/UtTestsDialogProcessor.kt | 2 +- .../plugin/models/GenerateTestsModel.kt | 6 ++ .../TestFolderComboWithBrowseButton.kt | 3 +- .../src/main/resources/META-INF/plugin.xml | 99 ------------------- .../main/resources/META-INF/pluginIcon.svg | 4 - .../main/resources/META-INF/withAndroid.xml | 3 - .../src/main/resources/META-INF/withGo.xml | 3 - .../main/resources/META-INF/withIdeaMaven.xml | 3 - .../src/main/resources/META-INF/withJS.xml | 4 - .../src/main/resources/META-INF/withJava.xml | 3 - .../main/resources/META-INF/withKotlin.xml | 3 - .../src/main/resources/META-INF/withLang.xml | 3 - .../main/resources/META-INF/withPython.xml | 4 - .../src/main/resources/application.properties | 5 - .../resources/bundles/UtbotBundle.properties | 10 -- .../UnitTestBotInspectionTool.html | 11 --- utbot-intellij/src/main/resources/log4j2.xml | 34 ------- 23 files changed, 34 insertions(+), 210 deletions(-) delete mode 100644 utbot-intellij/src/main/resources/META-INF/plugin.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/pluginIcon.svg delete mode 100644 utbot-intellij/src/main/resources/META-INF/withAndroid.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/withGo.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/withIdeaMaven.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/withJS.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/withJava.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/withKotlin.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/withLang.xml delete mode 100644 utbot-intellij/src/main/resources/META-INF/withPython.xml delete mode 100644 utbot-intellij/src/main/resources/application.properties delete mode 100644 utbot-intellij/src/main/resources/bundles/UtbotBundle.properties delete mode 100644 utbot-intellij/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html delete mode 100644 utbot-intellij/src/main/resources/log4j2.xml diff --git a/gradle.properties b/gradle.properties index 8dbfdc04be..3682db48d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,14 +10,14 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio -ideType=PC +ideType=PY #ideVersion=232.8660.185 ideVersion=2023.2 # ALL, NOJS buildType=NOJS pythonIde=IC,IU,PC,PY -jsIde=IU,PY,WS +jsIde=IU jsBuild=ALL goIde=IU diff --git a/settings.gradle.kts b/settings.gradle.kts index d53c4450ea..581f66a4c4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,7 +27,7 @@ include("utbot-core") include("utbot-framework") include("utbot-framework-api") include("utbot-modificators-analyzer") -if (ideType != "PC") { +if (ideType != "PC" && ideType != "PY") { include("utbot-intellij") } include("utbot-sample") diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index a6141ac019..e872a4f11e 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -169,7 +169,7 @@ dependencies { //Family - if (ideType != "PC") { + if (ideType != "PC" && ideType != "PY") { implementation(project(":utbot-intellij")) } diff --git a/utbot-intellij-main/src/main/resources/META-INF/plugin.xml b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml index 1b3bbf6242..5b2acbb54d 100644 --- a/utbot-intellij-main/src/main/resources/META-INF/plugin.xml +++ b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml @@ -19,7 +19,7 @@ text="Generate Tests with UnitTestBot..." description="Cover code with auto-generated tests"> - + @@ -32,13 +32,13 @@ - + - - + + - - + + diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt index 7d633ef1e1..b42c0fc1b1 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt @@ -1,5 +1,6 @@ package org.utbot.intellij.plugin.python +import com.intellij.lang.Language import com.intellij.openapi.application.ReadAction import com.intellij.openapi.application.invokeLater import com.intellij.openapi.application.runWriteAction @@ -24,7 +25,6 @@ import com.jetbrains.python.psi.PyClass import com.jetbrains.python.psi.PyElement import com.jetbrains.python.psi.PyFile import com.jetbrains.python.psi.PyFunction -import com.jetbrains.python.psi.resolve.QualifiedNameFinder import com.jetbrains.python.sdk.pythonSdk import mu.KotlinLogging //import org.jetbrains.kotlin.idea.base.util.module @@ -335,18 +335,10 @@ fun getPythonPath(project: Project): String? { return project.pythonSdk?.homePath } -fun findSrcModules(elements: Collection): List { - return listOf(ModuleImpl("", elements.first().project)) -} - fun getSrcModule(element: PyElement): Module { return ModuleUtilCore.findModuleForPsiElement(element) ?: error("Module for source class or function not found") } -fun getFullName(element: PyElement): String { - return QualifiedNameFinder.getQualifiedName(element) ?: error("Name for source class or function not found") -} - fun getContentFromPyFile(file: PyFile) = ReadAction.nonBlocking { file.viewProvider.contents.toString() diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt index ebe3c174c9..b7be740aec 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt @@ -1,11 +1,20 @@ package org.utbot.intellij.plugin.python //import com.intellij.codeInsight.CodeInsightUtil +import com.intellij.codeInsight.CodeInsightUtilBase +import com.intellij.codeInsight.CodeInsightUtilCore +import com.intellij.codeInsight.CodeInsightWorkspaceSettings +import com.intellij.codeInsight.actions.CodeInsightAction +import com.intellij.codeInsight.hints.codeVision.CodeVision +import com.intellij.icons.ExpUiIcons.CodeInsight import com.intellij.openapi.application.invokeLater import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.project.Project +import com.intellij.psi.PsiAnchor import com.intellij.psi.PsiDirectory +import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFileFactory +import com.intellij.testFramework.fixtures.CodeInsightTestUtil import com.jetbrains.python.psi.PyClass import org.utbot.intellij.plugin.python.language.PythonLanguageAssistant import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater @@ -31,6 +40,11 @@ class PythonIntellijProcessor( testDir.findFile(testPsiFile.name)?.delete() testDir.add(testPsiFile) val file = testDir.findFile(testPsiFile.name)!! + CodeInsightUtilCore.getInstance().prepareFileForWrite(file) + val document = PsiDocumentManager.getInstance(model.project).getDocument(file) + val editor = CodeInsightUtilCore.getInstance() + editor.prepareFileForWrite(file) +// CodeInsightUtilCore. // CodeInsightUtil.positionCursor(model.project, file, file) } } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt index 4b8ff4c0e8..2b7f4cf924 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt @@ -576,7 +576,7 @@ object UtTestsDialogProcessor { val classpathList = pathsList.pathList Pair(classpath, classpathList) } - val pluginJarsPath = Paths.get(PathManager.getPluginsPath(), "utbot-intellij", "lib").toFile().listFiles() + val pluginJarsPath = Paths.get(PathManager.getPluginsPath(), "utbot-intellij-main", "lib").toFile().listFiles() ?: error("Can't find plugin folder.") return BuildPaths(buildDirs, classpath, classpathList, pluginJarsPath.map { it.path }) } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt index c382cf30e1..3c23f56b51 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt @@ -10,13 +10,18 @@ import org.utbot.framework.codegen.domain.TestFramework import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleUtil import com.intellij.openapi.project.Project +import com.intellij.openapi.project.rootManager import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile +import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass import com.intellij.psi.PsiJavaFile import com.intellij.psi.search.GlobalSearchScope +import com.intellij.psi.search.searches.AnnotatedElementsSearch import com.intellij.refactoring.util.classMembers.MemberInfo import org.jetbrains.concurrency.Promise +import org.jetbrains.kotlin.idea.util.projectStructure.allModules +import org.jetbrains.kotlin.idea.util.sourceRoot import org.jetbrains.kotlin.psi.KtFile import org.utbot.common.PathUtil.fileExtension import org.utbot.framework.SummariesGenerationType @@ -30,6 +35,7 @@ import org.utbot.framework.plugin.api.SpringSettings import org.utbot.framework.util.ConflictTriggers import org.utbot.intellij.plugin.settings.Settings import org.utbot.intellij.plugin.ui.utils.* +import org.utbot.intellij.plugin.util.binaryName import java.nio.file.Files import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt index a57e63a9e4..14ce8db2e0 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt @@ -16,6 +16,7 @@ import com.intellij.util.ArrayUtil import com.intellij.util.ui.UIUtil import org.utbot.common.PathUtil import org.utbot.intellij.plugin.models.BaseTestsModel +import org.utbot.intellij.plugin.models.GenerateTestsModel import org.utbot.intellij.plugin.ui.utils.ITestSourceRoot import org.utbot.intellij.plugin.ui.utils.addDedicatedTestRoot import org.utbot.intellij.plugin.ui.utils.isBuildWithGradle @@ -25,7 +26,7 @@ import javax.swing.JList private const val SET_TEST_FOLDER = "set test folder" -class TestFolderComboWithBrowseButton(private val model: BaseTestsModel) : +class TestFolderComboWithBrowseButton(private val model: GenerateTestsModel) : ComponentWithBrowseButton>(ComboBox(), null) { diff --git a/utbot-intellij/src/main/resources/META-INF/plugin.xml b/utbot-intellij/src/main/resources/META-INF/plugin.xml deleted file mode 100644 index c21e12800d..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/plugin.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - org.utbot.intellij.plugin.id - UnitTestBot - utbot.org - com.intellij.modules.platform - - com.intellij.modules.java - org.jetbrains.kotlin - com.intellij.modules.python - org.jetbrains.plugins.go - org.jetbrains.android - org.jetbrains.idea.maven - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - Discover UnitTestBot key features in our latest release: -
      -
    • generating ready-to-use test cases — with valid inputs, method bodies, assertions, and comments
    • -
    • maximizing branch coverage in regression suite while keeping the number of tests minimized
    • -
    • finding deeply hidden code defects and expressing them as tests
    • -
    • fine-tuned mocking, including mocking static methods
    • -
    • representing all the test descriptions in a human-readable format
    • -
    • generating SARIF reports
    • -
    • innovative symbolic execution engine combined with a smart fuzzing platform
    • -
    - UnitTestBot supports the latest JDKs, JUnit 4, JUnit 5, TestNG, Mockito and is suitable for all popular operational systems. -
    - Try UnitTestBot online demo to see how it generates tests for your code in real time. -
    - Contribute to UnitTestBot via GitHub. -
    - Found a bug? File an issue. -
    - Have an idea? Start a discussion. - ]]> -
    - - -
  • Generating tests for Python and JavaScript
  • -
  • New fuzzing platform providing support for multiple languages
  • -
  • Improved test generation for Kotlin code
  • -
  • Multiprocess architecture based on the Reactive Distributed communication framework with advanced logging and debugging options
  • -
  • Symbolic execution engine with higher priority and fewer false UNSAT verdicts
  • -
  • UI/UX improvements for test sources root, setting.properties file, cancellation, timeout settings, notifications
  • -
  • Summaries with fine-grained settings
  • -
  • SARIF reports enabled by default, displaying sandbox-related and timeout test failures, properly addressing source files
  • -
  • Improved monitoring visualized with Grafana
  • -
  • Test generation bug fixes
  • -
  • Detailed documentation on UnitTestBot components including UnitTestBot architecture overview
  • - - ]]> -
    - - - - -
    diff --git a/utbot-intellij/src/main/resources/META-INF/pluginIcon.svg b/utbot-intellij/src/main/resources/META-INF/pluginIcon.svg deleted file mode 100644 index d24574d6dd..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/pluginIcon.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/META-INF/withAndroid.xml b/utbot-intellij/src/main/resources/META-INF/withAndroid.xml deleted file mode 100644 index 09ce48b452..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withAndroid.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/META-INF/withGo.xml b/utbot-intellij/src/main/resources/META-INF/withGo.xml deleted file mode 100644 index 65c848f900..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withGo.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/utbot-intellij/src/main/resources/META-INF/withIdeaMaven.xml b/utbot-intellij/src/main/resources/META-INF/withIdeaMaven.xml deleted file mode 100644 index 5c2f872b51..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withIdeaMaven.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/META-INF/withJS.xml b/utbot-intellij/src/main/resources/META-INF/withJS.xml deleted file mode 100644 index d04570b311..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withJS.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - JavaScript - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/META-INF/withJava.xml b/utbot-intellij/src/main/resources/META-INF/withJava.xml deleted file mode 100644 index 2ce2e82cc9..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withJava.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/META-INF/withKotlin.xml b/utbot-intellij/src/main/resources/META-INF/withKotlin.xml deleted file mode 100644 index 07e0e420c3..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withKotlin.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/META-INF/withLang.xml b/utbot-intellij/src/main/resources/META-INF/withLang.xml deleted file mode 100644 index ed33e791e3..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withLang.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/META-INF/withPython.xml b/utbot-intellij/src/main/resources/META-INF/withPython.xml deleted file mode 100644 index f272fd7601..0000000000 --- a/utbot-intellij/src/main/resources/META-INF/withPython.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - com.intellij.modules.python - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/application.properties b/utbot-intellij/src/main/resources/application.properties deleted file mode 100644 index f5af5a168d..0000000000 --- a/utbot-intellij/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -# suppress inspection "HttpUrlsUsage" for whole file -backing.service.possibleEndpoints=http://utbot.org -backing.service.urlPath=/utbot/errors -backing.service.port=11000 -request.timeoutMillis=5000 \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/bundles/UtbotBundle.properties b/utbot-intellij/src/main/resources/bundles/UtbotBundle.properties deleted file mode 100644 index 4c13064c79..0000000000 --- a/utbot-intellij/src/main/resources/bundles/UtbotBundle.properties +++ /dev/null @@ -1,10 +0,0 @@ -# {0} - Test report url prefix, {1] - suffix -test.report.force.mock.warning=Warning: Some test cases were ignored, because no mocking framework is installed in the project.
    \ -Better results could be achieved by installing mocking framework. -test.report.force.static.mock.warning=Warning: Some test cases were ignored, because mockito-inline is not installed in the project.
    \ -Better results could be achieved by configuring mockito-inline. -test.report.test.framework.warning=Warning: There are several test frameworks in the project.\ -To select run configuration, please refer to the documentation depending on the project build system:\ -Gradle, \ -Maven \ -or Idea. \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html b/utbot-intellij/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html deleted file mode 100644 index a01f16e673..0000000000 --- a/utbot-intellij/src/main/resources/inspectionDescriptions/UnitTestBotInspectionTool.html +++ /dev/null @@ -1,11 +0,0 @@ - - -

    Reports unchecked exceptions detected by UnitTestBot.

    -

    Example:

    -
    -void foo(int a) {
    -    return 1 / a; // throws ArithmeticException when `a == 0`
    -}
    -
    - - \ No newline at end of file diff --git a/utbot-intellij/src/main/resources/log4j2.xml b/utbot-intellij/src/main/resources/log4j2.xml deleted file mode 100644 index 6a9ae540c8..0000000000 --- a/utbot-intellij/src/main/resources/log4j2.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 9a152a6c35141360539ecb9f94f4243cc88a8123 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Mon, 18 Sep 2023 13:57:09 +0300 Subject: [PATCH 05/43] Fix python testing elements filter --- .../language/PythonLanguageAssistant.kt | 15 +++++++-------- .../language/agnostic/LanguageAssistant.kt | 19 +++---------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt index 364e2d6b26..84eff6a604 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt @@ -7,16 +7,11 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.PsiDirectory -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiFileSystemItem +import com.intellij.psi.* import com.intellij.psi.util.PsiTreeUtil import com.jetbrains.python.psi.PyClass import com.jetbrains.python.psi.PyFile import com.jetbrains.python.psi.PyFunction -//import org.jetbrains.kotlin.idea.core.util.toPsiDirectory -//import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.utbot.framework.plugin.api.util.LockFile import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant import org.utbot.intellij.plugin.python.* @@ -140,8 +135,12 @@ object PythonLanguageAssistant : LanguageAssistant() { } private fun getAllElements(project: Project, virtualFiles: Collection): Pair, Set> { - val psiFiles = virtualFiles.filterIsInstance() - val psiDirectories = virtualFiles.filterIsInstance() + val psiFiles = virtualFiles.mapNotNull { + PsiManager.getInstance(project).findFile(it) + } + val psiDirectories = virtualFiles.mapNotNull { + PsiManager.getInstance(project).findDirectory(it) + } val classes = psiFiles.flatMap { getClassesFromFile(it) }.toMutableSet() val functions = psiFiles.flatMap { getFunctionsFromFile(it) }.toMutableSet() diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt index fd3e5c6e32..4fc4a118d8 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt @@ -7,12 +7,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.PsiDirectory -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiFileSystemItem -//import org.jetbrains.kotlin.idea.core.util.toPsiDirectory -//import org.jetbrains.kotlin.idea.core.util.toPsiFile +import com.intellij.psi.* private val logger = KotlinLogging.logger {} @@ -85,19 +80,11 @@ abstract class LanguageAssistant { private fun findLanguageRecursively(project: Project, virtualFiles: Array): Language? { val psiFiles = virtualFiles.mapNotNull { - if (it is PsiFile) { - it - } - else null + PsiManager.getInstance(project).findFile(it) } val psiDirectories = virtualFiles.mapNotNull { - if (it is PsiDirectory) { - it - } - else null + PsiManager.getInstance(project).findDirectory(it) } -// val psiFiles = virtualFiles.mapNotNull { it.getPsiFile(project) } -// val psiDirectories = virtualFiles.mapNotNull { it. .toPsiDirectory(project) } val fileLanguage = psiFiles.firstNotNullOfOrNull { getLanguageFromFile(it) } return fileLanguage ?: psiDirectories.firstNotNullOfOrNull { findLanguageRecursively(it) } From 1f7fafe9630ed59535d9376e065ea3ca61620f61 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Mon, 18 Sep 2023 14:36:29 +0300 Subject: [PATCH 06/43] Replace codeInsightUtils by fileDescriptor --- .../plugin/python/PythonIntellijProcessor.kt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt index b7be740aec..bb1408958f 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonIntellijProcessor.kt @@ -1,20 +1,11 @@ package org.utbot.intellij.plugin.python -//import com.intellij.codeInsight.CodeInsightUtil -import com.intellij.codeInsight.CodeInsightUtilBase -import com.intellij.codeInsight.CodeInsightUtilCore -import com.intellij.codeInsight.CodeInsightWorkspaceSettings -import com.intellij.codeInsight.actions.CodeInsightAction -import com.intellij.codeInsight.hints.codeVision.CodeVision -import com.intellij.icons.ExpUiIcons.CodeInsight import com.intellij.openapi.application.invokeLater import com.intellij.openapi.application.runWriteAction +import com.intellij.openapi.fileEditor.OpenFileDescriptor import com.intellij.openapi.project.Project -import com.intellij.psi.PsiAnchor import com.intellij.psi.PsiDirectory -import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFileFactory -import com.intellij.testFramework.fixtures.CodeInsightTestUtil import com.jetbrains.python.psi.PyClass import org.utbot.intellij.plugin.python.language.PythonLanguageAssistant import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater @@ -40,12 +31,7 @@ class PythonIntellijProcessor( testDir.findFile(testPsiFile.name)?.delete() testDir.add(testPsiFile) val file = testDir.findFile(testPsiFile.name)!! - CodeInsightUtilCore.getInstance().prepareFileForWrite(file) - val document = PsiDocumentManager.getInstance(model.project).getDocument(file) - val editor = CodeInsightUtilCore.getInstance() - editor.prepareFileForWrite(file) -// CodeInsightUtilCore. -// CodeInsightUtil.positionCursor(model.project, file, file) + OpenFileDescriptor(project, file.virtualFile).navigate(true) } } } From c4552ed2e094b8c2bdf4e550f431354a5a6726f2 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Mon, 18 Sep 2023 17:57:52 +0300 Subject: [PATCH 07/43] Update gradle --- utbot-intellij-main/build.gradle.kts | 36 +-------- .../readme.md | 0 utbot-intellij-python/build.gradle.kts | 6 +- .../plugin/python/PythonDialogProcessor.kt | 3 - utbot-intellij/build.gradle.kts | 77 +------------------ 5 files changed, 6 insertions(+), 116 deletions(-) rename {utbot-intellij => utbot-intellij-main}/readme.md (100%) diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index e872a4f11e..309b0a2f5b 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -2,35 +2,23 @@ val projectType: String by rootProject val communityEdition: String by rootProject val ultimateEdition: String by rootProject -val intellijPluginVersion: String? by rootProject -val kotlinLoggingVersion: String? by rootProject -val apacheCommonsTextVersion: String? by rootProject -val jacksonVersion: String? by rootProject - val ideType: String? by rootProject val ideVersion: String? by rootProject val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject val goPluginVersion: String? by rootProject +val javaIde: String? by rootProject val pythonIde: String? by rootProject val jsIde: String? by rootProject val goIde: String? by rootProject -val sootVersion: String? by rootProject -val kryoVersion: String? by rootProject -val rdVersion: String? by rootProject val semVer: String? by rootProject val androidStudioPath: String? by rootProject -val junit5Version: String by rootProject -val junit4PlatformVersion: String by rootProject - // https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" -//project.tasks.asMap["runIde"]?.enabled = false - plugins { id("org.jetbrains.intellij") version "1.13.1" } @@ -150,26 +138,11 @@ repositories { } dependencies { - implementation(group ="com.jetbrains.rd", name = "rd-framework", version = rdVersion) - implementation(group ="com.jetbrains.rd", name = "rd-core", version = rdVersion) - implementation(group ="com.esotericsoftware.kryo", name = "kryo5", version = kryoVersion) - implementation(group = "io.github.microutils", name = "kotlin-logging", version = kotlinLoggingVersion) - implementation(group = "org.apache.commons", name = "commons-text", version = apacheCommonsTextVersion) - implementation("org.apache.httpcomponents.client5:httpclient5:5.1") - implementation(group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin", version = jacksonVersion) - - implementation(project(":utbot-framework")) { exclude(group = "org.slf4j", module = "slf4j-api") } - implementation(project(":utbot-spring-framework")) { exclude(group = "org.slf4j", module = "slf4j-api") } - implementation(project(":utbot-java-fuzzing")) - //api(project(":utbot-analytics")) - testImplementation("org.mock-server:mockserver-netty:5.4.1") - testApi(project(":utbot-framework")) - implementation(project(":utbot-ui-commons")) //Family - if (ideType != "PC" && ideType != "PY") { + if (javaIde?.split(',')?.contains(ideType) == true) { implementation(project(":utbot-intellij")) } @@ -202,9 +175,4 @@ dependencies { // Video Recording implementation("com.automation-remarks:video-recorder-junit5:2.0") - - testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version") - testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junit4PlatformVersion") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit5Version") - testRuntimeOnly("org.junit.vintage:junit-vintage-engine:$junit5Version") } diff --git a/utbot-intellij/readme.md b/utbot-intellij-main/readme.md similarity index 100% rename from utbot-intellij/readme.md rename to utbot-intellij-main/readme.md diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index 0d370e78ac..7899f0e5cd 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -61,11 +61,11 @@ intellij { plugins.set( when (ideType) { - "IC" -> jvmPlugins + kotlinPlugins + pythonCommunityPlugins - "IU" -> jvmPlugins + kotlinPlugins + pythonUltimatePlugins + "IC" -> pythonCommunityPlugins + "IU" -> pythonUltimatePlugins "PC" -> pythonCommunityPlugins "PY" -> pythonUltimatePlugins // something else, JS? - else -> jvmPlugins + else -> emptyList() } ) diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt index b42c0fc1b1..d8a8cae701 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt @@ -9,7 +9,6 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleUtilCore -import com.intellij.openapi.module.impl.ModuleImpl import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.Task.Backgroundable @@ -27,8 +26,6 @@ import com.jetbrains.python.psi.PyFile import com.jetbrains.python.psi.PyFunction import com.jetbrains.python.sdk.pythonSdk import mu.KotlinLogging -//import org.jetbrains.kotlin.idea.base.util.module -//import org.jetbrains.kotlin.idea.base.util.sdk import org.utbot.common.PathUtil.toPath import org.utbot.framework.plugin.api.util.LockFile import org.utbot.intellij.plugin.settings.Settings diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index 7dd7e6a556..f648a6b1d0 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -71,27 +71,13 @@ intellij { val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins - plugins.set( - when (projectType) { - communityEdition -> basePluginSet + pythonCommunityPlugins - ultimateEdition -> when (ideType) { - "IC" -> basePluginSet + pythonCommunityPlugins - "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins - "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? - else -> basePluginSet - } - else -> basePluginSet - } - ) + plugins.set(basePluginSet) version.set(ideVersion) type.set(ideTypeOrAndroidStudio) SettingsTemplateHelper.proceed(project) } -val remoteRobotVersion = "0.11.16" - tasks { compileKotlin { kotlinOptions { @@ -117,36 +103,6 @@ tasks { untilBuild.set("232.*") version.set(semVer) } - - runIdeForUiTests { - jvmArgs("-Xmx2048m", "-Didea.is.internal=true", "-Didea.ui.debug.mode=true") - - systemProperty("robot-server.port", "8082") // default port 8580 - systemProperty("ide.mac.message.dialogs.as.sheets", "false") - systemProperty("jb.privacy.policy.text", "") - systemProperty("jb.consents.confirmation.enabled", "false") - systemProperty("idea.trust.all.projects", "true") - systemProperty("ide.mac.file.chooser.native", "false") - systemProperty("jbScreenMenuBar.enabled", "false") - systemProperty("apple.laf.useScreenMenuBar", "false") - systemProperty("ide.show.tips.on.startup.default.value", "false") - } - - downloadRobotServerPlugin { - version.set(remoteRobotVersion) - } - - test { - description = "Runs UI integration tests." - useJUnitPlatform { - exclude("/org/utbot/**") //Comment this line to run the tests locally - } - } -} - -repositories { - maven("https://jitpack.io") - maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") } dependencies { @@ -166,39 +122,8 @@ dependencies { testApi(project(":utbot-framework")) implementation(project(":utbot-ui-commons")) - - //Family - - if (pythonIde?.split(',')?.contains(ideType) == true) { - implementation(project(":utbot-python")) - implementation(project(":utbot-intellij-python")) - } - - if (projectType == ultimateEdition) { - if (jsIde?.split(',')?.contains(ideType) == true) { - implementation(project(":utbot-js")) - implementation(project(":utbot-intellij-js")) - } - - if (goIde?.split(',')?.contains(ideType) == true) { - implementation(project(":utbot-go")) - implementation(project(":utbot-intellij-go")) - } - } - implementation(project(":utbot-android-studio")) - testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion") - testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion") - - testImplementation("org.assertj:assertj-core:3.11.1") - - // Logging Network Calls - testImplementation("com.squareup.okhttp3:logging-interceptor:4.10.0") - - // Video Recording - implementation("com.automation-remarks:video-recorder-junit5:2.0") - testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version") testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junit4PlatformVersion") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit5Version") From a144d516fe91f790a66ae659407373eb82a786e4 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Mon, 18 Sep 2023 19:08:20 +0300 Subject: [PATCH 08/43] Update go and js --- .../org/utbot/cli/js/JsCoverageCommand.kt | 10 ++-- .../org/utbot/cli/js/JsRunTestsCommand.kt | 2 +- .../go/generator/GoUtTestsCodeFileWriter.kt | 6 +-- .../go/generator/GoUtTestsDialogProcessor.kt | 8 +-- .../IntellijGoUtTestsGenerationController.kt | 4 +- .../go => go/language}/GoLanguageAssistant.kt | 4 +- .../go/models/GenerateGoTestsModel.kt | 2 +- .../go/ui/GenerateGoTestsDialogWindow.kt | 4 +- .../go/ui/GoFunctionsSelectionTable.kt | 2 +- .../{language => }/go/ui/utils/GoSdkUtils.kt | 2 +- .../{language => }/js/CoverageModeButtons.kt | 2 +- .../{language => }/js/JsDialogProcessor.kt | 18 ++++--- .../{language => }/js/JsDialogWindow.kt | 4 +- .../utbot/intellij/plugin/js/JsTestsModel.kt | 49 +++++++++++++++++++ .../{language => }/js/NycSourceFileChooser.kt | 2 +- .../js => js/language}/JsLanguageAssistant.kt | 3 +- .../plugin/language/js/JsTestsModel.kt | 31 ------------ .../src/main/kotlin/service/TernService.kt | 2 +- .../service/coverage/BasicCoverageService.kt | 2 +- .../service/coverage/CoverageService.kt | 4 +- .../service/coverage/FastCoverageService.kt | 2 +- .../kotlin/settings/JsPackagesSettings.kt | 6 +-- 22 files changed, 97 insertions(+), 72 deletions(-) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language => }/go/generator/GoUtTestsCodeFileWriter.kt (92%) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language => }/go/generator/GoUtTestsDialogProcessor.kt (95%) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language => }/go/generator/IntellijGoUtTestsGenerationController.kt (98%) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language/go => go/language}/GoLanguageAssistant.kt (96%) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language => }/go/models/GenerateGoTestsModel.kt (96%) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language => }/go/ui/GenerateGoTestsDialogWindow.kt (97%) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language => }/go/ui/GoFunctionsSelectionTable.kt (95%) rename utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/{language => }/go/ui/utils/GoSdkUtils.kt (81%) rename utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/{language => }/js/CoverageModeButtons.kt (94%) rename utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/{language => }/js/JsDialogProcessor.kt (96%) rename utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/{language => }/js/JsDialogWindow.kt (98%) create mode 100644 utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsTestsModel.kt rename utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/{language => }/js/NycSourceFileChooser.kt (95%) rename utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/{language/js => js/language}/JsLanguageAssistant.kt (98%) delete mode 100644 utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsTestsModel.kt diff --git a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt index 788b63c559..5e88973b6d 100644 --- a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt +++ b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt @@ -52,12 +52,12 @@ class JsCoverageCommand : CliktCommand(name = "coverage_js", help = "Get tests c shouldWait = true, timeout = 20, cmd = arrayOf( - "\"$pathToNYC\"", - "--report-dir=\"$coverageDataPath\"", - "--reporter=\"clover\"", - "--temp-dir=\"${workingDir}/cache\"", + pathToNYC, + "--report-dir=$coverageDataPath", + "--reporter=clover", + "--temp-dir=${workingDir}/cache", "mocha", - "\"$testFileAbsolutePath\"" + testFileAbsolutePath ) ) val coveredList = mutableListOf() diff --git a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt index 60d96fc374..1c094aa058 100644 --- a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt +++ b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt @@ -42,7 +42,7 @@ class JsRunTestsCommand : CliktCommand(name = "run_js", help = "Runs tests for t val (inputText, errorText) = JsCmdExec.runCommand( dir = dir, shouldWait = true, - cmd = arrayOf("mocha", "\"$fileWithTestsAbsolutePath\"") + cmd = arrayOf("mocha", fileWithTestsAbsolutePath) ) if (errorText.isNotEmpty()) { logger.error { "An error has occurred while running tests for $fileWithTests: $errorText" } diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/GoUtTestsCodeFileWriter.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt similarity index 92% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/GoUtTestsCodeFileWriter.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt index 14dca93611..4ad546935b 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/GoUtTestsCodeFileWriter.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go.generator +package org.utbot.intellij.plugin.go.generator import com.intellij.codeInsight.CodeInsightUtil import com.intellij.openapi.application.runWriteAction @@ -9,8 +9,8 @@ import com.intellij.psi.PsiFileFactory import com.intellij.psi.PsiManager import com.intellij.util.IncorrectOperationException import org.utbot.go.api.GoUtFile -import org.utbot.intellij.plugin.language.go.GoLanguageAssistant -import org.utbot.intellij.plugin.language.go.models.GenerateGoTestsModel +import org.utbot.intellij.plugin.go.language.GoLanguageAssistant +import org.utbot.intellij.plugin.go.models.GenerateGoTestsModel import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater import java.nio.file.Paths diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/GoUtTestsDialogProcessor.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsDialogProcessor.kt similarity index 95% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/GoUtTestsDialogProcessor.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsDialogProcessor.kt index be9b8cf6a7..b5c1fcdd9d 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/GoUtTestsDialogProcessor.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsDialogProcessor.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go.generator +package org.utbot.intellij.plugin.go.generator import com.goide.project.DefaultGoRootsProvider import com.goide.psi.GoFunctionOrMethodDeclaration @@ -16,9 +16,9 @@ import com.intellij.openapi.ui.Messages import org.utbot.go.gocodeanalyzer.GoParsingSourceCodeAnalysisResultException import org.utbot.go.logic.GoUtTestsGenerationConfig import org.utbot.go.worker.GoWorkerFailedException -import org.utbot.intellij.plugin.language.go.models.GenerateGoTestsModel -import org.utbot.intellij.plugin.language.go.ui.GenerateGoTestsDialogWindow -import org.utbot.intellij.plugin.language.go.ui.utils.resolveGoExecutablePath +import org.utbot.intellij.plugin.go.models.GenerateGoTestsModel +import org.utbot.intellij.plugin.go.ui.GenerateGoTestsDialogWindow +import org.utbot.intellij.plugin.go.ui.utils.resolveGoExecutablePath import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater import java.nio.file.Paths diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/IntellijGoUtTestsGenerationController.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/IntellijGoUtTestsGenerationController.kt similarity index 98% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/IntellijGoUtTestsGenerationController.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/IntellijGoUtTestsGenerationController.kt index 43858f3ece..b5a89b4c17 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/generator/IntellijGoUtTestsGenerationController.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/IntellijGoUtTestsGenerationController.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go.generator +package org.utbot.intellij.plugin.go.generator import com.intellij.openapi.application.invokeLater import com.intellij.openapi.progress.ProgressIndicator @@ -7,7 +7,7 @@ import org.utbot.go.api.GoUtFunction import org.utbot.go.api.GoUtFuzzedFunctionTestCase import org.utbot.go.gocodeanalyzer.GoSourceCodeAnalyzer import org.utbot.go.logic.AbstractGoUtTestsGenerationController -import org.utbot.intellij.plugin.language.go.models.GenerateGoTestsModel +import org.utbot.intellij.plugin.go.models.GenerateGoTestsModel import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater import org.utbot.intellij.plugin.ui.utils.showWarningDialogLater import java.nio.file.Path diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/GoLanguageAssistant.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/language/GoLanguageAssistant.kt similarity index 96% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/GoLanguageAssistant.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/language/GoLanguageAssistant.kt index b2265756c3..3dd98052de 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/GoLanguageAssistant.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/language/GoLanguageAssistant.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go +package org.utbot.intellij.plugin.go.language import com.goide.psi.* import com.intellij.lang.Language @@ -10,7 +10,7 @@ import com.intellij.psi.PsiFile import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.idea.base.util.module import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant -import org.utbot.intellij.plugin.language.go.generator.GoUtTestsDialogProcessor +import org.utbot.intellij.plugin.go.generator.GoUtTestsDialogProcessor @Suppress("unused") // is used in org.utbot.intellij.plugin.language.agnostic.LanguageAssistant via reflection object GoLanguageAssistant : LanguageAssistant() { diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/models/GenerateGoTestsModel.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/models/GenerateGoTestsModel.kt similarity index 96% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/models/GenerateGoTestsModel.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/models/GenerateGoTestsModel.kt index 2e1cc8f2ef..0b62e84649 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/models/GenerateGoTestsModel.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/models/GenerateGoTestsModel.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go.models +package org.utbot.intellij.plugin.go.models import com.goide.psi.GoFunctionDeclaration import com.goide.psi.GoFunctionOrMethodDeclaration diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/GenerateGoTestsDialogWindow.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/GenerateGoTestsDialogWindow.kt similarity index 97% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/GenerateGoTestsDialogWindow.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/GenerateGoTestsDialogWindow.kt index 6232e8a7e9..b24febe97e 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/GenerateGoTestsDialogWindow.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/GenerateGoTestsDialogWindow.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go.ui +package org.utbot.intellij.plugin.go.ui import com.goide.psi.GoFunctionDeclaration import com.goide.psi.GoFunctionOrMethodDeclaration @@ -16,7 +16,7 @@ import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import org.utbot.go.logic.GoUtTestsGenerationConfig import org.utbot.go.logic.TestsGenerationMode -import org.utbot.intellij.plugin.language.go.models.GenerateGoTestsModel +import org.utbot.intellij.plugin.go.models.GenerateGoTestsModel import org.utbot.intellij.plugin.settings.Settings import java.text.ParseException import java.util.concurrent.TimeUnit diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/GoFunctionsSelectionTable.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/GoFunctionsSelectionTable.kt similarity index 95% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/GoFunctionsSelectionTable.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/GoFunctionsSelectionTable.kt index cd7e93eb7d..ee6203c875 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/GoFunctionsSelectionTable.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/GoFunctionsSelectionTable.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go.ui +package org.utbot.intellij.plugin.go.ui import com.goide.psi.GoNamedElement import com.goide.refactor.ui.GoDeclarationInfo diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/utils/GoSdkUtils.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/utils/GoSdkUtils.kt similarity index 81% rename from utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/utils/GoSdkUtils.kt rename to utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/utils/GoSdkUtils.kt index 049098ed64..fd385cc82c 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/language/go/ui/utils/GoSdkUtils.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/ui/utils/GoSdkUtils.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.go.ui.utils +package org.utbot.intellij.plugin.go.ui.utils import com.goide.sdk.GoSdk import java.nio.file.Paths diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/CoverageModeButtons.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/CoverageModeButtons.kt similarity index 94% rename from utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/CoverageModeButtons.kt rename to utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/CoverageModeButtons.kt index 874a3f1fe9..c2f8c2f1e6 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/CoverageModeButtons.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/CoverageModeButtons.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.js +package org.utbot.intellij.plugin.js import javax.swing.ButtonGroup import javax.swing.JRadioButton diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsDialogProcessor.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt similarity index 96% rename from utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsDialogProcessor.kt rename to utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt index ba0cff9b85..1612b3d00c 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsDialogProcessor.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.js +package org.utbot.intellij.plugin.js import api.JsTestGenerator import com.intellij.codeInsight.CodeInsightUtil @@ -10,9 +10,11 @@ import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.module.Module +import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.Task import com.intellij.openapi.project.Project +import com.intellij.openapi.roots.TestModuleProperties import com.intellij.openapi.ui.Messages import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFileFactory @@ -24,8 +26,8 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.konan.file.File import org.utbot.framework.plugin.api.TimeoutException +import org.utbot.intellij.plugin.js.language.JsLanguageAssistant import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater -import org.utbot.intellij.plugin.ui.utils.testModules import settings.JsDynamicSettings import settings.JsExportsSettings.endComment import settings.JsExportsSettings.startComment @@ -87,7 +89,10 @@ object JsDialogProcessor { val pathToNode = NodeJsLocalInterpreterManager.getInstance().interpreters.first().interpreterSystemIndependentPath val (_, errorText) = JsCmdExec.runCommand( - shouldWait = true, cmd = arrayOf("\"${pathToNode}\"", "-v") + shouldWait = true, cmd = arrayOf( + pathToNode, + "-v" + ) ) if (errorText.isNotEmpty()) throw NoSuchElementException() val pathToNPM = @@ -117,7 +122,7 @@ object JsDialogProcessor { filePath: String, file: JSFile ): JsTestsModel? { - val testModules = srcModule.testModules(project) + val testModules = srcModule.testModules() if (testModules.isEmpty()) { val errorMessage = """ @@ -130,11 +135,10 @@ object JsDialogProcessor { val (pathToNode, pathToNPM) = findNodeAndNPM() ?: return null return JsTestsModel( project = project, - srcModule = srcModule, potentialTestModules = testModules, + file = file, fileMethods = fileMethods, selectedMethods = if (focusedMethod != null) setOf(focusedMethod) else emptySet(), - file = file, ).apply { containingFilePath = filePath this.pathToNode = pathToNode @@ -268,6 +272,8 @@ object JsDialogProcessor { } } +private fun Module.testModules() = listOf(this) + private fun PackageDataService.checkAndInstallRequirements(project: Project): Boolean { val missingPackages = jsPackagesList.filterNot { this.findPackage(it) } if (missingPackages.isEmpty()) return true diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsDialogWindow.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogWindow.kt similarity index 98% rename from utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsDialogWindow.kt rename to utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogWindow.kt index 24d934ada1..14b71160c7 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsDialogWindow.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogWindow.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.js +package org.utbot.intellij.plugin.js import com.intellij.lang.javascript.refactoring.ui.JSMemberSelectionTable import com.intellij.lang.javascript.refactoring.util.JSMemberInfo @@ -111,7 +111,7 @@ class JsDialogWindow(val model: JsTestsModel) : DialogWrapper(model.project) { model.testFramework = testFrameworks.item model.timeout = timeoutSpinner.number.toLong() model.pathToNYC = nycSourceFileChooserField.text - model.coverageMode = coverageMode.mode + model.coverageMode = CoverageModeButtons.mode File(testSourceFolderField.text).mkdir() model.testSourceRoot = VirtualFileManager.getInstance().refreshAndFindFileByNioPath(Paths.get(testSourceFolderField.text)) diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsTestsModel.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsTestsModel.kt new file mode 100644 index 0000000000..de18043117 --- /dev/null +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsTestsModel.kt @@ -0,0 +1,49 @@ +package org.utbot.intellij.plugin.js + +import com.intellij.lang.javascript.psi.JSFile +import com.intellij.lang.javascript.refactoring.util.JSMemberInfo +import com.intellij.openapi.module.Module +import com.intellij.openapi.module.ModuleUtil +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile +import org.utbot.framework.codegen.domain.TestFramework +import org.utbot.intellij.plugin.models.BaseTestsModel +import service.coverage.CoverageMode +import settings.JsTestGenerationSettings.defaultTimeout + +class JsTestsModel( + project: Project, + val potentialTestModules: List, + val file: JSFile, + val fileMethods: Set, + var selectedMethods: Set, +) : BaseTestsModel( + project +) { + var testModule: Module = potentialTestModules.firstOrNull() ?: error("Empty list of test modules in model") + + var timeout = defaultTimeout + + lateinit var testFramework: TestFramework + lateinit var containingFilePath: String + var pathToNode: String = "node" + var pathToNYC: String = "nyc" + var pathToNPM: String = "npm" + var coverageMode: CoverageMode = CoverageMode.FAST + + fun setSourceRootAndFindTestModule(newTestSourceRoot: VirtualFile?) { + requireNotNull(newTestSourceRoot) + testSourceRoot = newTestSourceRoot + var target = newTestSourceRoot + while (target != null && target is FakeVirtualFile) { + target = target.parent + } + if (target == null) { + error("Could not find module for $newTestSourceRoot") + } + + testModule = ModuleUtil.findModuleForFile(target, project) + ?: error("Could not find module for $newTestSourceRoot") + } +} diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/NycSourceFileChooser.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/NycSourceFileChooser.kt similarity index 95% rename from utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/NycSourceFileChooser.kt rename to utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/NycSourceFileChooser.kt index ebe84a48b3..e3683d5a6d 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/NycSourceFileChooser.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/NycSourceFileChooser.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.js +package org.utbot.intellij.plugin.js import com.intellij.openapi.fileChooser.FileChooserDescriptor import com.intellij.openapi.ui.TextBrowseFolderListener diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsLanguageAssistant.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/language/JsLanguageAssistant.kt similarity index 98% rename from utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsLanguageAssistant.kt rename to utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/language/JsLanguageAssistant.kt index 3d3eefe17a..cbc9c3f0d5 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsLanguageAssistant.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/language/JsLanguageAssistant.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.language.js +package org.utbot.intellij.plugin.js.language import com.intellij.lang.Language import com.intellij.lang.ecmascript6.psi.ES6Class @@ -16,6 +16,7 @@ import com.intellij.psi.PsiFile import com.intellij.psi.PsiFileFactory import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.idea.util.projectStructure.module +import org.utbot.intellij.plugin.js.JsDialogProcessor import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant import settings.JsTestGenerationSettings.dummyClassName diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsTestsModel.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsTestsModel.kt deleted file mode 100644 index 8c8508953d..0000000000 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/JsTestsModel.kt +++ /dev/null @@ -1,31 +0,0 @@ -package org.utbot.intellij.plugin.language.js - -import com.intellij.lang.javascript.psi.JSFile -import com.intellij.lang.javascript.refactoring.util.JSMemberInfo -import com.intellij.openapi.module.Module -import com.intellij.openapi.project.Project -import org.utbot.framework.codegen.domain.TestFramework -import org.utbot.intellij.plugin.models.BaseTestsModel -import service.coverage.CoverageMode -import settings.JsTestGenerationSettings.defaultTimeout - -class JsTestsModel( - project: Project, - srcModule: Module, - potentialTestModules: List, - val file: JSFile, - val fileMethods: Set, - var selectedMethods: Set, -) : BaseTestsModel( - project, srcModule, potentialTestModules, emptySet() -) { - - var timeout = defaultTimeout - - lateinit var testFramework: TestFramework - lateinit var containingFilePath: String - var pathToNode: String = "node" - var pathToNYC: String = "nyc" - var pathToNPM: String = "npm" - var coverageMode: CoverageMode = CoverageMode.FAST -} diff --git a/utbot-js/src/main/kotlin/service/TernService.kt b/utbot-js/src/main/kotlin/service/TernService.kt index fd215752a4..b17dcd19e8 100644 --- a/utbot-js/src/main/kotlin/service/TernService.kt +++ b/utbot-js/src/main/kotlin/service/TernService.kt @@ -80,7 +80,7 @@ test(["${filePathToInference.joinToString(separator = "\", \"")}"]) dir = "$projectPath/$utbotDir/", shouldWait = true, timeout = 20, - cmd = arrayOf("\"${settings.pathToNode}\"", "\"${projectPath}/$utbotDir/ternScript.js\""), + cmd = arrayOf(settings.pathToNode, "${projectPath}/$utbotDir/ternScript.js"), ) json = try { JSONObject(inputText.replaceAfterLast("}", "")) diff --git a/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt b/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt index 9b774d8154..6351457851 100644 --- a/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt +++ b/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt @@ -21,7 +21,7 @@ class BasicCoverageService( scriptTexts.indices.forEach { index -> try { val (_, errorText) = JsCmdExec.runCommand( - cmd = arrayOf("\"${settings.pathToNode}\"", "\"$utbotDirPath/$tempFileName$index.js\""), + cmd = arrayOf(settings.pathToNode, "$utbotDirPath/$tempFileName$index.js"), dir = projectPath, shouldWait = true, timeout = settings.timeout, diff --git a/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt b/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt index b51106e8cf..0fdcd20a90 100644 --- a/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt +++ b/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt @@ -41,8 +41,8 @@ abstract class CoverageService( ) JsCmdExec.runCommand( cmd = arrayOf( - "\"${settings.pathToNode}\"", - "\"$utbotDirPath/${JsTestGenerationSettings.tempFileName}Base.js\"" + settings.pathToNode, + "$utbotDirPath/${JsTestGenerationSettings.tempFileName}Base.js" ), dir = projectPath, shouldWait = true, diff --git a/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt b/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt index a2c3c0f05a..032ee65946 100644 --- a/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt +++ b/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt @@ -20,7 +20,7 @@ class FastCoverageService( override fun generateCoverageReport() { val (_, errorText) = JsCmdExec.runCommand( - cmd = arrayOf("\"${settings.pathToNode}\"", "\"$utbotDirPath/$tempFileName" + "0.js\""), + cmd = arrayOf(settings.pathToNode, "$utbotDirPath/$tempFileName" + "0.js"), dir = projectPath, shouldWait = true, timeout = settings.timeout, diff --git a/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt b/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt index ebea20a6ab..95a1f7946f 100644 --- a/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt +++ b/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt @@ -66,7 +66,7 @@ class PackageDataService( dir = projectPath, shouldWait = true, timeout = 10, - cmd = arrayOf("\"$pathToNpm\"", "list", npmListFlag.toString()) + cmd = arrayOf(pathToNpm, "list", npmListFlag.toString()) ) var result = inputText.contains(packageName) if (!result || this == nycData) { @@ -103,7 +103,7 @@ class PackageDataService( dir = projectPath, shouldWait = true, timeout = 10, - cmd = arrayOf("\"$pathToNpm\"", "install", NpmListFlag.L.toString(), *localPackageNames) + cmd = arrayOf(pathToNpm, "install", NpmListFlag.L.toString(), *localPackageNames) ) inputTextAllPackages += inputText errorTextAllPackages += errorText @@ -114,7 +114,7 @@ class PackageDataService( dir = projectPath, shouldWait = true, timeout = 10, - cmd = arrayOf("\"$pathToNpm\"", "install", NpmListFlag.G.toString(), *globalPackageNames) + cmd = arrayOf(pathToNpm, "install", NpmListFlag.G.toString(), *globalPackageNames) ) inputTextAllPackages += inputText errorTextAllPackages += errorText From 9e293d67900bfd841f72e94f74d8ae0b6e945836 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Tue, 19 Sep 2023 09:51:14 +0300 Subject: [PATCH 09/43] Update build.gradle --- settings.gradle.kts | 8 ++++--- utbot-intellij-go/build.gradle.kts | 26 ++--------------------- utbot-intellij-js/build.gradle.kts | 29 ++------------------------ utbot-intellij-main/build.gradle.kts | 2 +- utbot-intellij-python/build.gradle.kts | 8 ------- utbot-intellij/build.gradle.kts | 20 ------------------ 6 files changed, 10 insertions(+), 83 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 581f66a4c4..38c5173f3b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,7 @@ val ultimateEdition: String by settings val ideType: String by settings val buildType: String by settings +val javaIde: String by settings val pythonIde: String by settings val jsIde: String by settings val jsBuild: String by settings @@ -27,9 +28,6 @@ include("utbot-core") include("utbot-framework") include("utbot-framework-api") include("utbot-modificators-analyzer") -if (ideType != "PC" && ideType != "PY") { - include("utbot-intellij") -} include("utbot-sample") include("utbot-java-fuzzing") include("utbot-fuzzing") @@ -65,6 +63,10 @@ include("utbot-spring-analyzer") include("utbot-spring-sample") include("utbot-spring-test") +if (javaIde.split(",").contains(ideType)) { + include("utbot-intellij") +} + if (pythonIde.split(",").contains(ideType)) { include("utbot-python") include("utbot-cli-python") diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index 377bad3660..a949d5589e 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -43,36 +43,14 @@ dependencies { } intellij { - - val androidPlugins = listOf("org.jetbrains.android") - - val jvmPlugins = listOf( - "java" - ) - - val pythonCommunityPlugins = listOf( - "PythonCore:${pythonCommunityPluginVersion}" - ) - - val pythonUltimatePlugins = listOf( - "Pythonid:${pythonUltimatePluginVersion}" - ) - - val jsPlugins = listOf( - "JavaScript" - ) - val goPlugins = listOf( "org.jetbrains.plugins.go:${goPluginVersion}" ) plugins.set( when (ideType) { - "IC" -> jvmPlugins + pythonCommunityPlugins + androidPlugins - "IU" -> jvmPlugins + pythonUltimatePlugins + jsPlugins + goPlugins + androidPlugins - "PC" -> pythonCommunityPlugins - "PU" -> pythonUltimatePlugins // something else, JS? - else -> jvmPlugins + "IU" -> goPlugins + else -> emptyList() } ) diff --git a/utbot-intellij-js/build.gradle.kts b/utbot-intellij-js/build.gradle.kts index 815e860514..62d739ff9a 100644 --- a/utbot-intellij-js/build.gradle.kts +++ b/utbot-intellij-js/build.gradle.kts @@ -4,9 +4,6 @@ val apacheCommonsTextVersion: String? by rootProject val jacksonVersion: String? by rootProject val ideType: String? by rootProject val ideVersion: String? by rootProject -val pythonCommunityPluginVersion: String? by rootProject -val pythonUltimatePluginVersion: String? by rootProject -val goPluginVersion: String? by rootProject plugins { id("org.jetbrains.intellij") version "1.13.1" @@ -43,36 +40,14 @@ dependencies { } intellij { - - val androidPlugins = listOf("org.jetbrains.android") - - val jvmPlugins = listOf( - "java" - ) - - val pythonCommunityPlugins = listOf( - "PythonCore:${pythonCommunityPluginVersion}" - ) - - val pythonUltimatePlugins = listOf( - "Pythonid:${pythonUltimatePluginVersion}" - ) - val jsPlugins = listOf( "JavaScript" ) - val goPlugins = listOf( - "org.jetbrains.plugins.go:${goPluginVersion}" - ) - plugins.set( when (ideType) { - "IC" -> jvmPlugins + pythonCommunityPlugins + androidPlugins - "IU" -> jvmPlugins + pythonUltimatePlugins + jsPlugins + goPlugins + androidPlugins - "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? - else -> jvmPlugins + "IU" -> jsPlugins + else -> emptyList() } ) diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index 309b0a2f5b..f759ce4ebb 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -66,7 +66,7 @@ intellij { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? + "PY" -> pythonUltimatePlugins + jsPlugins // something else, JS? else -> basePluginSet } else -> basePluginSet diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index 7899f0e5cd..e96244e04f 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -6,7 +6,6 @@ val ideType: String? by rootProject val ideVersion: String by rootProject val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject -val goPluginVersion: String? by rootProject plugins { id("org.jetbrains.intellij") version "1.13.1" @@ -43,13 +42,6 @@ dependencies { } intellij { - val jvmPlugins = listOf( - "java" - ) - - val kotlinPlugins = mutableListOf( - "org.jetbrains.kotlin" - ) val pythonCommunityPlugins = listOf( "PythonCore:${pythonCommunityPluginVersion}" diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index f648a6b1d0..e9d031e8c1 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -13,10 +13,6 @@ val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject val goPluginVersion: String? by rootProject -val pythonIde: String? by rootProject -val jsIde: String? by rootProject -val goIde: String? by rootProject - val sootVersion: String? by rootProject val kryoVersion: String? by rootProject val rdVersion: String? by rootProject @@ -49,22 +45,6 @@ intellij { androidStudioPath?.let { jvmPlugins += androidPlugins } - val pythonCommunityPlugins = listOf( - "PythonCore:${pythonCommunityPluginVersion}" - ) - - val pythonUltimatePlugins = listOf( - "Pythonid:${pythonUltimatePluginVersion}" - ) - - val jsPlugins = listOf( - "JavaScript" - ) - - val goPlugins = listOf( - "org.jetbrains.plugins.go:${goPluginVersion}" - ) - val mavenUtilsPlugins = listOf( "org.jetbrains.idea.maven" ) From 32b4d74a5a36b80d1b669e266f5717cdeec1ccb4 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Tue, 19 Sep 2023 09:58:07 +0300 Subject: [PATCH 10/43] Update gradle.properties --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 3682db48d7..27c494f24f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,6 +16,7 @@ ideVersion=2023.2 # ALL, NOJS buildType=NOJS +javaIde=IC,IU pythonIde=IC,IU,PC,PY jsIde=IU jsBuild=ALL From 198708985df2f0247e98d64a8a806cb4a81961bf Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Tue, 19 Sep 2023 13:57:00 +0300 Subject: [PATCH 11/43] Update build.gradle.kts --- gradle.properties | 6 ++-- settings.gradle.kts | 3 +- utbot-intellij-go/build.gradle.kts | 48 ++++++++++++++++++++++++-- utbot-intellij-js/build.gradle.kts | 51 ++++++++++++++++++++++++++-- utbot-intellij-main/build.gradle.kts | 2 +- 5 files changed, 98 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index 27c494f24f..e157ec654a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,9 +10,9 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio -ideType=PY -#ideVersion=232.8660.185 -ideVersion=2023.2 +ideType=IC +ideVersion=232.8660.185 +#ideVersion=2023.2 # ALL, NOJS buildType=NOJS diff --git a/settings.gradle.kts b/settings.gradle.kts index 38c5173f3b..8e00d13b75 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,8 +35,6 @@ include("utbot-junit-contest") include("utbot-analytics") include("utbot-analytics-torch") -include("utbot-cli") - include("utbot-api") include("utbot-instrumentation") include("utbot-instrumentation-tests") @@ -65,6 +63,7 @@ include("utbot-spring-test") if (javaIde.split(",").contains(ideType)) { include("utbot-intellij") + include("utbot-cli") } if (pythonIde.split(",").contains(ideType)) { diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index a949d5589e..86d7c76e06 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -1,3 +1,6 @@ +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject @@ -8,6 +11,7 @@ val kotlinPluginVersion: String by rootProject val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject val goPluginVersion: String? by rootProject +val androidStudioPath: String? by rootProject plugins { id("org.jetbrains.intellij") version "1.13.1" @@ -43,14 +47,52 @@ dependencies { } intellij { + + val androidPlugins = listOf("org.jetbrains.android") + + val jvmPlugins = mutableListOf( + "java" + ) + + val kotlinPlugins = mutableListOf( + "org.jetbrains.kotlin" + ) + + androidStudioPath?.let { jvmPlugins += androidPlugins } + + val pythonCommunityPlugins = listOf( + "PythonCore:${pythonCommunityPluginVersion}" + ) + + val pythonUltimatePlugins = listOf( + "Pythonid:${pythonUltimatePluginVersion}" + ) + + val jsPlugins = listOf( + "JavaScript" + ) + val goPlugins = listOf( "org.jetbrains.plugins.go:${goPluginVersion}" ) + val mavenUtilsPlugins = listOf( + "org.jetbrains.idea.maven" + ) + + val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins + plugins.set( - when (ideType) { - "IU" -> goPlugins - else -> emptyList() + when (projectType) { + communityEdition -> basePluginSet + pythonCommunityPlugins + ultimateEdition -> when (ideType) { + "IC" -> basePluginSet + pythonCommunityPlugins + "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins // something else, JS? + else -> basePluginSet + } + else -> basePluginSet } ) diff --git a/utbot-intellij-js/build.gradle.kts b/utbot-intellij-js/build.gradle.kts index 62d739ff9a..9f2b09464e 100644 --- a/utbot-intellij-js/build.gradle.kts +++ b/utbot-intellij-js/build.gradle.kts @@ -1,9 +1,16 @@ +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject val jacksonVersion: String? by rootProject val ideType: String? by rootProject val ideVersion: String? by rootProject +val pythonCommunityPluginVersion: String? by rootProject +val pythonUltimatePluginVersion: String? by rootProject +val goPluginVersion: String? by rootProject +val androidStudioPath: String? by rootProject plugins { id("org.jetbrains.intellij") version "1.13.1" @@ -40,14 +47,52 @@ dependencies { } intellij { + + val androidPlugins = listOf("org.jetbrains.android") + + val jvmPlugins = mutableListOf( + "java" + ) + + val kotlinPlugins = mutableListOf( + "org.jetbrains.kotlin" + ) + + androidStudioPath?.let { jvmPlugins += androidPlugins } + + val pythonCommunityPlugins = listOf( + "PythonCore:${pythonCommunityPluginVersion}" + ) + + val pythonUltimatePlugins = listOf( + "Pythonid:${pythonUltimatePluginVersion}" + ) + val jsPlugins = listOf( "JavaScript" ) + val goPlugins = listOf( + "org.jetbrains.plugins.go:${goPluginVersion}" + ) + + val mavenUtilsPlugins = listOf( + "org.jetbrains.idea.maven" + ) + + val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins + plugins.set( - when (ideType) { - "IU" -> jsPlugins - else -> emptyList() + when (projectType) { + communityEdition -> basePluginSet + pythonCommunityPlugins + ultimateEdition -> when (ideType) { + "IC" -> basePluginSet + pythonCommunityPlugins + "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins // something else, JS? + else -> basePluginSet + } + else -> basePluginSet } ) diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index f759ce4ebb..309b0a2f5b 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -66,7 +66,7 @@ intellij { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins + jsPlugins // something else, JS? + "PY" -> pythonUltimatePlugins // something else, JS? else -> basePluginSet } else -> basePluginSet From 7b59128674a39e8d4e28aef5a365556653263f3b Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Tue, 19 Sep 2023 15:10:30 +0300 Subject: [PATCH 12/43] move tests --- .github/workflows/combined-projects-matrix.json | 2 +- .github/workflows/run-chosen-tests-from-branch.yml | 2 +- {utbot-intellij => utbot-intellij-main}/src/test/java/Bar.java | 0 {utbot-intellij => utbot-intellij-main}/src/test/java/Foo.java | 0 .../src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt | 0 .../src/test/kotlin/org/utbot/data/JDKVersion.kt | 0 .../src/test/kotlin/org/utbot/data/RunInfo.kt | 0 .../src/test/kotlin/org/utbot/dialogs/DialogFixture.kt | 0 .../test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt | 0 .../test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt | 0 .../test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt | 0 .../src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt | 0 .../src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt | 0 .../src/test/kotlin/org/utbot/elements/NotificationFixture.kt | 0 .../src/test/kotlin/org/utbot/pages/IdeaFrame.kt | 0 .../src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt | 0 .../src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt | 0 .../src/test/kotlin/org/utbot/pages/WelcomeFrame.kt | 0 .../src/test/kotlin/org/utbot/samples/CodeSamples.kt | 0 .../src/test/kotlin/org/utbot/steps/IDESteps.kt | 0 .../src/test/kotlin/org/utbot/tests/BaseTest.kt | 0 .../src/test/kotlin/org/utbot/tests/CreateProjects.kt | 0 .../src/test/kotlin/org/utbot/tests/RootUtilsTest.kt | 0 .../src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt | 0 .../src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt | 0 .../src/test/kotlin/org/utbot/utils/StepsLogger.kt | 0 .../src/test/resources/application.properties | 0 .../src/test/resources/junit-platform.properties | 0 .../src/test/resources/log4j.properties | 0 .../src/test/resources/log4j2.xml | 0 30 files changed, 2 insertions(+), 2 deletions(-) rename {utbot-intellij => utbot-intellij-main}/src/test/java/Bar.java (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/java/Foo.java (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/data/JDKVersion.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/data/RunInfo.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/elements/NotificationFixture.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/pages/IdeaFrame.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/samples/CodeSamples.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/steps/IDESteps.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/tests/BaseTest.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/tests/CreateProjects.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/kotlin/org/utbot/utils/StepsLogger.kt (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/resources/application.properties (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/resources/junit-platform.properties (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/resources/log4j.properties (100%) rename {utbot-intellij => utbot-intellij-main}/src/test/resources/log4j2.xml (100%) diff --git a/.github/workflows/combined-projects-matrix.json b/.github/workflows/combined-projects-matrix.json index 83130dd191..adbcb967c6 100644 --- a/.github/workflows/combined-projects-matrix.json +++ b/.github/workflows/combined-projects-matrix.json @@ -1,7 +1,7 @@ { "projects": [ { - "FIRST": "utbot-intellij", + "FIRST": "utbot-intellij-main", "SECOND": "utbot-cli" }, { diff --git a/.github/workflows/run-chosen-tests-from-branch.yml b/.github/workflows/run-chosen-tests-from-branch.yml index ea5dec9ac5..d59a68b03c 100644 --- a/.github/workflows/run-chosen-tests-from-branch.yml +++ b/.github/workflows/run-chosen-tests-from-branch.yml @@ -18,7 +18,7 @@ on: - utbot-gradle - utbot-instrumentation-tests - utbot-instrumentation - - utbot-intellij + - utbot-intellij-main - utbot-sample - utbot-summary - utbot-summary-tests diff --git a/utbot-intellij/src/test/java/Bar.java b/utbot-intellij-main/src/test/java/Bar.java similarity index 100% rename from utbot-intellij/src/test/java/Bar.java rename to utbot-intellij-main/src/test/java/Bar.java diff --git a/utbot-intellij/src/test/java/Foo.java b/utbot-intellij-main/src/test/java/Foo.java similarity index 100% rename from utbot-intellij/src/test/java/Foo.java rename to utbot-intellij-main/src/test/java/Foo.java diff --git a/utbot-intellij/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/data/JDKVersion.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/data/JDKVersion.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/data/JDKVersion.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/data/JDKVersion.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/data/RunInfo.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/data/RunInfo.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/data/RunInfo.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/data/RunInfo.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/elements/NotificationFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/elements/NotificationFixture.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/elements/NotificationFixture.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/elements/NotificationFixture.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaFrame.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaFrame.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/samples/CodeSamples.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/samples/CodeSamples.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/steps/IDESteps.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/steps/IDESteps.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/steps/IDESteps.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/steps/IDESteps.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/BaseTest.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/tests/BaseTest.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/tests/BaseTest.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/tests/BaseTest.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/tests/CreateProjects.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/tests/CreateProjects.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt diff --git a/utbot-intellij/src/test/kotlin/org/utbot/utils/StepsLogger.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/utils/StepsLogger.kt similarity index 100% rename from utbot-intellij/src/test/kotlin/org/utbot/utils/StepsLogger.kt rename to utbot-intellij-main/src/test/kotlin/org/utbot/utils/StepsLogger.kt diff --git a/utbot-intellij/src/test/resources/application.properties b/utbot-intellij-main/src/test/resources/application.properties similarity index 100% rename from utbot-intellij/src/test/resources/application.properties rename to utbot-intellij-main/src/test/resources/application.properties diff --git a/utbot-intellij/src/test/resources/junit-platform.properties b/utbot-intellij-main/src/test/resources/junit-platform.properties similarity index 100% rename from utbot-intellij/src/test/resources/junit-platform.properties rename to utbot-intellij-main/src/test/resources/junit-platform.properties diff --git a/utbot-intellij/src/test/resources/log4j.properties b/utbot-intellij-main/src/test/resources/log4j.properties similarity index 100% rename from utbot-intellij/src/test/resources/log4j.properties rename to utbot-intellij-main/src/test/resources/log4j.properties diff --git a/utbot-intellij/src/test/resources/log4j2.xml b/utbot-intellij-main/src/test/resources/log4j2.xml similarity index 100% rename from utbot-intellij/src/test/resources/log4j2.xml rename to utbot-intellij-main/src/test/resources/log4j2.xml From ce5dc47a8fbd1014760ebbc3977e9bf852c15588 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 20 Sep 2023 12:10:40 +0300 Subject: [PATCH 13/43] Update gradle --- utbot-intellij-main/build.gradle.kts | 6 +++--- utbot-intellij-python/build.gradle.kts | 2 +- utbot-intellij/build.gradle.kts | 2 +- utbot-ui-commons/build.gradle.kts | 5 ----- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index 309b0a2f5b..bf003b0dd3 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -75,7 +75,7 @@ intellij { version.set(ideVersion) type.set(ideTypeOrAndroidStudio) - SettingsTemplateHelper.proceed(project) +// SettingsTemplateHelper.proceed(project) } val remoteRobotVersion = "0.11.16" @@ -147,8 +147,8 @@ dependencies { } if (pythonIde?.split(',')?.contains(ideType) == true) { - api(project(":utbot-python")) - api(project(":utbot-intellij-python")) + implementation(project(":utbot-python")) + implementation(project(":utbot-intellij-python")) } if (projectType == ultimateEdition) { diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index e96244e04f..3b4cd83dfc 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -63,5 +63,5 @@ intellij { version.set(ideVersion) type.set(ideType) - SettingsTemplateHelper.proceed(project) +// SettingsTemplateHelper.proceed(project) } \ No newline at end of file diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index e9d031e8c1..1324747257 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -55,7 +55,7 @@ intellij { version.set(ideVersion) type.set(ideTypeOrAndroidStudio) - SettingsTemplateHelper.proceed(project) +// SettingsTemplateHelper.proceed(project) } tasks { diff --git a/utbot-ui-commons/build.gradle.kts b/utbot-ui-commons/build.gradle.kts index 0e32940387..c0d622a353 100644 --- a/utbot-ui-commons/build.gradle.kts +++ b/utbot-ui-commons/build.gradle.kts @@ -13,11 +13,6 @@ project.tasks.asMap["runIde"]?.enabled = false intellij { version.set(ideVersion) type.set(ideType) - - plugins.set(listOf( -// "java", -// "org.jetbrains.android" - )) } tasks { From 1906da3af5ba02ad44c95a226414795b0ad5fe2e Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 20 Sep 2023 13:01:28 +0300 Subject: [PATCH 14/43] Update utbot go --- gradle.properties | 2 +- settings.gradle.kts | 3 ++- utbot-intellij-go/build.gradle.kts | 3 +-- .../intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt | 4 ++-- .../utbot/intellij/plugin/go/language/GoLanguageAssistant.kt | 4 ++-- utbot-intellij-main/build.gradle.kts | 1 + utbot-intellij/build.gradle.kts | 1 - 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index e157ec654a..ce3fc26cc7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ javaIde=IC,IU pythonIde=IC,IU,PC,PY jsIde=IU jsBuild=ALL -goIde=IU +goIde=IU,GO # In order to run Android Studio instead of IntelliJ Community, specify the path to your Android Studio installation #androidStudioPath=your_path_to_android_studio diff --git a/settings.gradle.kts b/settings.gradle.kts index 8e00d13b75..38c5173f3b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,6 +35,8 @@ include("utbot-junit-contest") include("utbot-analytics") include("utbot-analytics-torch") +include("utbot-cli") + include("utbot-api") include("utbot-instrumentation") include("utbot-instrumentation-tests") @@ -63,7 +65,6 @@ include("utbot-spring-test") if (javaIde.split(",").contains(ideType)) { include("utbot-intellij") - include("utbot-cli") } if (pythonIde.split(",").contains(ideType)) { diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index 86d7c76e06..61c0efd08a 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -88,8 +88,7 @@ intellij { ultimateEdition -> when (ideType) { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins - "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? + "GO" -> goPlugins else -> basePluginSet } else -> basePluginSet diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt index 4ad546935b..19b81b6421 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/generator/GoUtTestsCodeFileWriter.kt @@ -1,7 +1,7 @@ package org.utbot.intellij.plugin.go.generator -import com.intellij.codeInsight.CodeInsightUtil import com.intellij.openapi.application.runWriteAction +import com.intellij.openapi.fileEditor.OpenFileDescriptor import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiFile @@ -37,7 +37,7 @@ object GoUtTestsCodeFileWriter { sourceFileDir.add(testPsiFile) val testFile = sourceFileDir.findFile(testsFileNameWithExtension)!! - CodeInsightUtil.positionCursor(model.project, testFile, testFile) + OpenFileDescriptor(model.project, testFile.virtualFile).navigate(true) } } catch (e: IncorrectOperationException) { showCreatingFileError(model.project, testsFileName) diff --git a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/language/GoLanguageAssistant.kt b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/language/GoLanguageAssistant.kt index 3dd98052de..f88c243ab8 100644 --- a/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/language/GoLanguageAssistant.kt +++ b/utbot-intellij-go/src/main/kotlin/org/utbot/intellij/plugin/go/language/GoLanguageAssistant.kt @@ -5,10 +5,10 @@ import com.intellij.lang.Language import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.editor.Editor +import com.intellij.openapi.module.ModuleUtilCore import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.util.PsiTreeUtil -import org.jetbrains.kotlin.idea.base.util.module import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant import org.utbot.intellij.plugin.go.generator.GoUtTestsDialogProcessor @@ -26,7 +26,7 @@ object GoLanguageAssistant : LanguageAssistant() { override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return val file = e.getData(CommonDataKeys.PSI_FILE) as? GoFile ?: return - val module = file.module ?: return + val module = ModuleUtilCore.findModuleForFile(file) ?: return val (targetFunctions, focusedTargetFunctions) = getPsiTargets(e) ?: return GoUtTestsDialogProcessor.createDialogAndGenerateTests( project, diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index bf003b0dd3..b641068991 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -67,6 +67,7 @@ intellij { "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins "PY" -> pythonUltimatePlugins // something else, JS? + "GO" -> goPlugins else -> basePluginSet } else -> basePluginSet diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index 1324747257..3c88009627 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -55,7 +55,6 @@ intellij { version.set(ideVersion) type.set(ideTypeOrAndroidStudio) -// SettingsTemplateHelper.proceed(project) } tasks { From 4695a5c75747806e2b5561d89a65d5b63eaf5a6e Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 20 Sep 2023 13:33:45 +0300 Subject: [PATCH 15/43] Update build.gradle.kts --- utbot-intellij-go/build.gradle.kts | 2 ++ utbot-intellij-js/build.gradle.kts | 1 + utbot-intellij-main/build.gradle.kts | 10 +++++- utbot-intellij-python/build.gradle.kts | 48 ++++++++++++++++++++++---- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index 61c0efd08a..7acd6f4451 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -88,6 +88,8 @@ intellij { ultimateEdition -> when (ideType) { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins // something else, JS? "GO" -> goPlugins else -> basePluginSet } diff --git a/utbot-intellij-js/build.gradle.kts b/utbot-intellij-js/build.gradle.kts index 9f2b09464e..cc716b9c05 100644 --- a/utbot-intellij-js/build.gradle.kts +++ b/utbot-intellij-js/build.gradle.kts @@ -90,6 +90,7 @@ intellij { "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins "PY" -> pythonUltimatePlugins // something else, JS? + "GO" -> goPlugins else -> basePluginSet } else -> basePluginSet diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index b641068991..689d681119 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -16,6 +16,9 @@ val goIde: String? by rootProject val semVer: String? by rootProject val androidStudioPath: String? by rootProject +val junit5Version: String by rootProject +val junit4PlatformVersion: String by rootProject + // https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" @@ -76,7 +79,7 @@ intellij { version.set(ideVersion) type.set(ideTypeOrAndroidStudio) -// SettingsTemplateHelper.proceed(project) + SettingsTemplateHelper.proceed(project) } val remoteRobotVersion = "0.11.16" @@ -176,4 +179,9 @@ dependencies { // Video Recording implementation("com.automation-remarks:video-recorder-junit5:2.0") + + testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version") + testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junit4PlatformVersion") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit5Version") + testRuntimeOnly("org.junit.vintage:junit-vintage-engine:$junit5Version") } diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index 3b4cd83dfc..731c4c6557 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -1,3 +1,6 @@ +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject @@ -6,6 +9,8 @@ val ideType: String? by rootProject val ideVersion: String by rootProject val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject +val goPluginVersion: String? by rootProject +val androidStudioPath: String? by rootProject plugins { id("org.jetbrains.intellij") version "1.13.1" @@ -43,6 +48,18 @@ dependencies { intellij { + val androidPlugins = listOf("org.jetbrains.android") + + val jvmPlugins = mutableListOf( + "java" + ) + + val kotlinPlugins = mutableListOf( + "org.jetbrains.kotlin" + ) + + androidStudioPath?.let { jvmPlugins += androidPlugins } + val pythonCommunityPlugins = listOf( "PythonCore:${pythonCommunityPluginVersion}" ) @@ -51,13 +68,32 @@ intellij { "Pythonid:${pythonUltimatePluginVersion}" ) + val jsPlugins = listOf( + "JavaScript" + ) + + val goPlugins = listOf( + "org.jetbrains.plugins.go:${goPluginVersion}" + ) + + val mavenUtilsPlugins = listOf( + "org.jetbrains.idea.maven" + ) + + val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins + plugins.set( - when (ideType) { - "IC" -> pythonCommunityPlugins - "IU" -> pythonUltimatePlugins - "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? - else -> emptyList() + when (projectType) { + communityEdition -> basePluginSet + pythonCommunityPlugins + ultimateEdition -> when (ideType) { + "IC" -> basePluginSet + pythonCommunityPlugins + "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins // something else, JS? + "GO" -> goPlugins + else -> basePluginSet + } + else -> basePluginSet } ) From bcc4f1c424097ca98d2064a7f54484bd86553dbc Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 20 Sep 2023 14:22:37 +0300 Subject: [PATCH 16/43] Update build.gradle.kts --- utbot-intellij-python/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index 731c4c6557..4c895975ac 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -99,5 +99,4 @@ intellij { version.set(ideVersion) type.set(ideType) -// SettingsTemplateHelper.proceed(project) } \ No newline at end of file From 16834d2fc4b07bb0ddb9c8c530b90abdd6d87f55 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 20 Sep 2023 16:02:27 +0300 Subject: [PATCH 17/43] Update build.gradle.kts and js --- gradle.properties | 6 +++--- utbot-intellij-go/build.gradle.kts | 2 +- utbot-intellij-js/build.gradle.kts | 2 +- .../intellij/plugin/js/JsDialogProcessor.kt | 21 +++++++++---------- .../plugin/js/language/JsLanguageAssistant.kt | 5 +++-- utbot-intellij-main/build.gradle.kts | 2 +- utbot-intellij-python/build.gradle.kts | 2 +- .../language/PythonLanguageAssistant.kt | 1 + .../intellij/plugin/language/JavaLanguage.kt | 3 ++- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/gradle.properties b/gradle.properties index ce3fc26cc7..ede58e920d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,14 +11,14 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio ideType=IC -ideVersion=232.8660.185 -#ideVersion=2023.2 +#ideVersion=232.8660.185 +ideVersion=2023.2 # ALL, NOJS buildType=NOJS javaIde=IC,IU pythonIde=IC,IU,PC,PY -jsIde=IU +jsIde=IU,PY jsBuild=ALL goIde=IU,GO diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index 7acd6f4451..bbd32e588f 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -89,7 +89,7 @@ intellij { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? + "PY" -> pythonUltimatePlugins + jsPlugins "GO" -> goPlugins else -> basePluginSet } diff --git a/utbot-intellij-js/build.gradle.kts b/utbot-intellij-js/build.gradle.kts index cc716b9c05..25fc942c32 100644 --- a/utbot-intellij-js/build.gradle.kts +++ b/utbot-intellij-js/build.gradle.kts @@ -89,7 +89,7 @@ intellij { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? + "PY" -> pythonUltimatePlugins + jsPlugins "GO" -> goPlugins else -> basePluginSet } diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt index 1612b3d00c..5923c312cd 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt @@ -1,30 +1,27 @@ package org.utbot.intellij.plugin.js import api.JsTestGenerator -import com.intellij.codeInsight.CodeInsightUtil import com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreterManager import com.intellij.lang.ecmascript6.psi.ES6Class import com.intellij.lang.javascript.psi.JSFile import com.intellij.lang.javascript.refactoring.util.JSMemberInfo +import com.intellij.openapi.application.invokeLater +import com.intellij.openapi.application.runReadAction +import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileDocumentManager +import com.intellij.openapi.fileEditor.OpenFileDescriptor import com.intellij.openapi.module.Module -import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.Task import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.TestModuleProperties import com.intellij.openapi.ui.Messages import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFileFactory import com.intellij.psi.impl.file.PsiDirectoryFactory import com.intellij.util.concurrency.AppExecutorUtil import mu.KotlinLogging -import org.jetbrains.kotlin.idea.util.application.invokeLater -import org.jetbrains.kotlin.idea.util.application.runReadAction -import org.jetbrains.kotlin.idea.util.application.runWriteAction -import org.jetbrains.kotlin.konan.file.File import org.utbot.framework.plugin.api.TimeoutException import org.utbot.intellij.plugin.js.language.JsLanguageAssistant import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater @@ -36,6 +33,7 @@ import settings.PackageDataService import settings.jsPackagesList import utils.JsCmdExec import utils.OsProvider +import java.io.File import java.io.IOException private val logger = KotlinLogging.logger {} @@ -205,10 +203,11 @@ object JsDialogProcessor { testDir.add(temp) testDir.findFile(testFileName)!! } - val testFileEditor = CodeInsightUtil.positionCursor(project, testPsiFile, testPsiFile) as Editor - unblockDocument(project, testFileEditor.document) - testFileEditor.document.setText(generatedCode) - unblockDocument(project, testFileEditor.document) +// val testFileEditor = CodeInsightUtil.positionCursor(project, testPsiFile, testPsiFile) as Editor + OpenFileDescriptor(project, testPsiFile.virtualFile).navigate(true) +// unblockDocument(project, testFileEditor.document) +// testFileEditor.document.setText(generatedCode) +// unblockDocument(project, testFileEditor.document) } } } diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/language/JsLanguageAssistant.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/language/JsLanguageAssistant.kt index cbc9c3f0d5..ec84561b6f 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/language/JsLanguageAssistant.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/language/JsLanguageAssistant.kt @@ -10,16 +10,17 @@ import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.editor.Editor import com.intellij.openapi.module.Module +import com.intellij.openapi.module.ModuleUtilCore import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiFileFactory import com.intellij.psi.util.PsiTreeUtil -import org.jetbrains.kotlin.idea.util.projectStructure.module import org.utbot.intellij.plugin.js.JsDialogProcessor import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant import settings.JsTestGenerationSettings.dummyClassName +@Suppress("unused") // is used in org.utbot.intellij.plugin.language.agnostic.LanguageAssistant via reflection object JsLanguageAssistant : LanguageAssistant() { private const val jsId = "ECMAScript 6" @@ -61,7 +62,7 @@ object JsLanguageAssistant : LanguageAssistant() { } else { e.getData(CommonDataKeys.PSI_ELEMENT) ?: return null } - val module = element.module ?: return null + val module = ModuleUtilCore.findModuleForPsiElement(element) ?: return null val virtualFile = (e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return null).path val focusedMethod = getContainingMethod(element) containingClass(element)?.let { diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index 689d681119..4e0bc593b8 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -69,7 +69,7 @@ intellij { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? + "PY" -> pythonUltimatePlugins + jsPlugins "GO" -> goPlugins else -> basePluginSet } diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index 4c895975ac..f955bb6f7d 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -89,7 +89,7 @@ intellij { "IC" -> basePluginSet + pythonCommunityPlugins "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? + "PY" -> pythonUltimatePlugins + jsPlugins "GO" -> goPlugins else -> basePluginSet } diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt index 84eff6a604..8c8a9a3a82 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/language/PythonLanguageAssistant.kt @@ -16,6 +16,7 @@ import org.utbot.framework.plugin.api.util.LockFile import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant import org.utbot.intellij.plugin.python.* +@Suppress("unused") // is used in org.utbot.intellij.plugin.language.agnostic.LanguageAssistant via reflection object PythonLanguageAssistant : LanguageAssistant() { private const val pythonID = "Python" diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/language/JavaLanguage.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/language/JavaLanguage.kt index c1afd584aa..b755acd5f9 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/language/JavaLanguage.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/language/JavaLanguage.kt @@ -32,6 +32,7 @@ import org.utbot.intellij.plugin.ui.InvalidClassNotifier import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant import org.utbot.intellij.plugin.util.findSdkVersionOrNull +@Suppress("unused") // is used in org.utbot.intellij.plugin.language.agnostic.LanguageAssistant via reflection object JvmLanguageAssistant : LanguageAssistant() { override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return @@ -100,7 +101,7 @@ object JvmLanguageAssistant : LanguageAssistant() { val memberInfoList = runReadAction> { it.extractFirstLevelMembers(false) } - if (memberInfoList.isNullOrEmpty()) + if (memberInfoList.isEmpty()) return null } From 9bff617c250f1d2cbcabf9202d77e352881474b3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 20 Sep 2023 16:08:45 +0300 Subject: [PATCH 18/43] Update version --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ede58e920d..da975e38d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,8 +11,8 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio ideType=IC -#ideVersion=232.8660.185 -ideVersion=2023.2 +ideVersion=232.8660.185 +#ideVersion=2023.2 # ALL, NOJS buildType=NOJS From e51377978664bf1a9f50ae4bc0c371b47f5a7d58 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 11 Oct 2023 09:10:37 +0300 Subject: [PATCH 19/43] Remove mutable lists with no reason --- utbot-intellij-go/build.gradle.kts | 2 +- utbot-intellij-js/build.gradle.kts | 2 +- utbot-intellij-main/build.gradle.kts | 2 +- utbot-intellij-python/build.gradle.kts | 2 +- utbot-intellij/build.gradle.kts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index bbd32e588f..0124225da5 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -54,7 +54,7 @@ intellij { "java" ) - val kotlinPlugins = mutableListOf( + val kotlinPlugins = listOf( "org.jetbrains.kotlin" ) diff --git a/utbot-intellij-js/build.gradle.kts b/utbot-intellij-js/build.gradle.kts index 25fc942c32..e3d6474ca1 100644 --- a/utbot-intellij-js/build.gradle.kts +++ b/utbot-intellij-js/build.gradle.kts @@ -54,7 +54,7 @@ intellij { "java" ) - val kotlinPlugins = mutableListOf( + val kotlinPlugins = listOf( "org.jetbrains.kotlin" ) diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index 4e0bc593b8..69c02ff51e 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -34,7 +34,7 @@ intellij { "java" ) - val kotlinPlugins = mutableListOf( + val kotlinPlugins = listOf( "org.jetbrains.kotlin" ) diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index f955bb6f7d..2c91a5662c 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -54,7 +54,7 @@ intellij { "java" ) - val kotlinPlugins = mutableListOf( + val kotlinPlugins = listOf( "org.jetbrains.kotlin" ) diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index 3c88009627..b4a9870f27 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -39,7 +39,7 @@ intellij { "java" ) - val kotlinPlugins = mutableListOf( + val kotlinPlugins = listOf( "org.jetbrains.kotlin" ) From f643b5cd55af70789c78de22e81f3433b01000e8 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 11 Oct 2023 09:57:44 +0300 Subject: [PATCH 20/43] Add ide version --- .github/workflows/publish-plugin-from-branch.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-plugin-from-branch.yml b/.github/workflows/publish-plugin-from-branch.yml index 2e4f5ec84b..37fc1c2aea 100644 --- a/.github/workflows/publish-plugin-from-branch.yml +++ b/.github/workflows/publish-plugin-from-branch.yml @@ -48,6 +48,12 @@ jobs: extra_options: "-PideType=IC -PprojectType=Community" - plugin_type: IU extra_options: "-PideType=IU -PprojectType=Ultimate" + - plugin_type: PC + extra_options: "-PideType=PC -PprojectType=Community -PideVersion=2023.2" + - plugin_type: PU + extra_options: "-PideType=PU -PprojectType=Ultimate -PideVersion=2023.2" + - plugin_type: GO + extra_options: "-PideType=PU -PprojectType=Community -PideVersion=2023.2" runs-on: ubuntu-20.04 container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 steps: @@ -79,13 +85,13 @@ jobs: - name: Build UTBot IntelliJ IDEA plugin run: | gradle clean buildPlugin --no-daemon --build-cache --no-parallel ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -PsemVer=${{ env.VERSION }} - cd utbot-intellij/build/distributions - unzip utbot-intellij-${{ env.VERSION }}.zip - rm utbot-intellij-${{ env.VERSION }}.zip + cd utbot-intellij-main/build/distributions + unzip utbot-intellij-main-${{ env.VERSION }}.zip + rm utbot-intellij-main-${{ env.VERSION }}.zip - name: Archive UTBot IntelliJ IDEA plugin if: ${{ inputs.upload-artifact == 'true' }} uses: actions/upload-artifact@v3 with: name: utbot-intellij-${{ matrix.configuration.plugin_type }}-${{ env.VERSION_ARCHIVE }} - path: utbot-intellij/build/distributions/* + path: utbot-intellij-main/build/distributions/* From 410c248929fbdbcf9fe18e3b11c1fce604254fcd Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 11 Oct 2023 09:58:20 +0300 Subject: [PATCH 21/43] Remove createNewFile --- .../src/main/kotlin/org/utbot/cli/language/python/Utils.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/Utils.kt b/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/Utils.kt index 8ff7f71457..708cfa6131 100644 --- a/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/Utils.kt +++ b/utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/Utils.kt @@ -25,5 +25,4 @@ fun writeToFileAndSave(filename: String, fileContent: String) { val file = File(filename) file.parentFile?.mkdirs() file.writeText(fileContent) - file.createNewFile() } From d260bf1c30a9892e533ab99d86046feb81ca1bb9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 11 Oct 2023 11:16:03 +0300 Subject: [PATCH 22/43] Reverse changes --- gradle.properties | 2 +- .../org/utbot/cli/js/JsCoverageCommand.kt | 10 +++--- .../org/utbot/cli/js/JsRunTestsCommand.kt | 2 +- .../intellij/plugin/js/JsDialogProcessor.kt | 9 +----- .../src/main/resources/META-INF/plugin.xml | 32 +++++++++---------- .../src/main/kotlin/service/TernService.kt | 2 +- .../service/coverage/BasicCoverageService.kt | 2 +- .../service/coverage/CoverageService.kt | 4 +-- .../service/coverage/FastCoverageService.kt | 2 +- .../kotlin/settings/JsPackagesSettings.kt | 2 +- 10 files changed, 30 insertions(+), 37 deletions(-) diff --git a/gradle.properties b/gradle.properties index da975e38d1..e02ec3ed5b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio -ideType=IC +ideType=IU ideVersion=232.8660.185 #ideVersion=2023.2 # ALL, NOJS diff --git a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt index 5e88973b6d..788b63c559 100644 --- a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt +++ b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsCoverageCommand.kt @@ -52,12 +52,12 @@ class JsCoverageCommand : CliktCommand(name = "coverage_js", help = "Get tests c shouldWait = true, timeout = 20, cmd = arrayOf( - pathToNYC, - "--report-dir=$coverageDataPath", - "--reporter=clover", - "--temp-dir=${workingDir}/cache", + "\"$pathToNYC\"", + "--report-dir=\"$coverageDataPath\"", + "--reporter=\"clover\"", + "--temp-dir=\"${workingDir}/cache\"", "mocha", - testFileAbsolutePath + "\"$testFileAbsolutePath\"" ) ) val coveredList = mutableListOf() diff --git a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt index 1c094aa058..60d96fc374 100644 --- a/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt +++ b/utbot-cli-js/src/main/kotlin/org/utbot/cli/js/JsRunTestsCommand.kt @@ -42,7 +42,7 @@ class JsRunTestsCommand : CliktCommand(name = "run_js", help = "Runs tests for t val (inputText, errorText) = JsCmdExec.runCommand( dir = dir, shouldWait = true, - cmd = arrayOf("mocha", fileWithTestsAbsolutePath) + cmd = arrayOf("mocha", "\"$fileWithTestsAbsolutePath\"") ) if (errorText.isNotEmpty()) { logger.error { "An error has occurred while running tests for $fileWithTests: $errorText" } diff --git a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt index 5923c312cd..164c2b0929 100644 --- a/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt +++ b/utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogProcessor.kt @@ -87,10 +87,7 @@ object JsDialogProcessor { val pathToNode = NodeJsLocalInterpreterManager.getInstance().interpreters.first().interpreterSystemIndependentPath val (_, errorText) = JsCmdExec.runCommand( - shouldWait = true, cmd = arrayOf( - pathToNode, - "-v" - ) + shouldWait = true, cmd = arrayOf("\"${pathToNode}\"", "-v") ) if (errorText.isNotEmpty()) throw NoSuchElementException() val pathToNPM = @@ -203,11 +200,7 @@ object JsDialogProcessor { testDir.add(temp) testDir.findFile(testFileName)!! } -// val testFileEditor = CodeInsightUtil.positionCursor(project, testPsiFile, testPsiFile) as Editor OpenFileDescriptor(project, testPsiFile.virtualFile).navigate(true) -// unblockDocument(project, testFileEditor.document) -// testFileEditor.document.setText(generatedCode) -// unblockDocument(project, testFileEditor.document) } } } diff --git a/utbot-intellij-main/src/main/resources/META-INF/plugin.xml b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml index 5b2acbb54d..c21e12800d 100644 --- a/utbot-intellij-main/src/main/resources/META-INF/plugin.xml +++ b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml @@ -6,12 +6,12 @@ utbot.org com.intellij.modules.platform - com.intellij.modules.java - org.jetbrains.kotlin - com.intellij.modules.python - org.jetbrains.plugins.go - org.jetbrains.android - org.jetbrains.idea.maven + com.intellij.modules.java + org.jetbrains.kotlin + com.intellij.modules.python + org.jetbrains.plugins.go + org.jetbrains.android + org.jetbrains.idea.maven ]]> - - - - - - - - - - + + + diff --git a/utbot-js/src/main/kotlin/service/TernService.kt b/utbot-js/src/main/kotlin/service/TernService.kt index b17dcd19e8..fd215752a4 100644 --- a/utbot-js/src/main/kotlin/service/TernService.kt +++ b/utbot-js/src/main/kotlin/service/TernService.kt @@ -80,7 +80,7 @@ test(["${filePathToInference.joinToString(separator = "\", \"")}"]) dir = "$projectPath/$utbotDir/", shouldWait = true, timeout = 20, - cmd = arrayOf(settings.pathToNode, "${projectPath}/$utbotDir/ternScript.js"), + cmd = arrayOf("\"${settings.pathToNode}\"", "\"${projectPath}/$utbotDir/ternScript.js\""), ) json = try { JSONObject(inputText.replaceAfterLast("}", "")) diff --git a/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt b/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt index 6351457851..9b774d8154 100644 --- a/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt +++ b/utbot-js/src/main/kotlin/service/coverage/BasicCoverageService.kt @@ -21,7 +21,7 @@ class BasicCoverageService( scriptTexts.indices.forEach { index -> try { val (_, errorText) = JsCmdExec.runCommand( - cmd = arrayOf(settings.pathToNode, "$utbotDirPath/$tempFileName$index.js"), + cmd = arrayOf("\"${settings.pathToNode}\"", "\"$utbotDirPath/$tempFileName$index.js\""), dir = projectPath, shouldWait = true, timeout = settings.timeout, diff --git a/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt b/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt index 0fdcd20a90..b51106e8cf 100644 --- a/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt +++ b/utbot-js/src/main/kotlin/service/coverage/CoverageService.kt @@ -41,8 +41,8 @@ abstract class CoverageService( ) JsCmdExec.runCommand( cmd = arrayOf( - settings.pathToNode, - "$utbotDirPath/${JsTestGenerationSettings.tempFileName}Base.js" + "\"${settings.pathToNode}\"", + "\"$utbotDirPath/${JsTestGenerationSettings.tempFileName}Base.js\"" ), dir = projectPath, shouldWait = true, diff --git a/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt b/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt index 032ee65946..a2c3c0f05a 100644 --- a/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt +++ b/utbot-js/src/main/kotlin/service/coverage/FastCoverageService.kt @@ -20,7 +20,7 @@ class FastCoverageService( override fun generateCoverageReport() { val (_, errorText) = JsCmdExec.runCommand( - cmd = arrayOf(settings.pathToNode, "$utbotDirPath/$tempFileName" + "0.js"), + cmd = arrayOf("\"${settings.pathToNode}\"", "\"$utbotDirPath/$tempFileName" + "0.js\""), dir = projectPath, shouldWait = true, timeout = settings.timeout, diff --git a/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt b/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt index 95a1f7946f..0ae48029ec 100644 --- a/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt +++ b/utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt @@ -66,7 +66,7 @@ class PackageDataService( dir = projectPath, shouldWait = true, timeout = 10, - cmd = arrayOf(pathToNpm, "list", npmListFlag.toString()) + cmd = arrayOf("\"$pathToNpm\"", "list", npmListFlag.toString()) ) var result = inputText.contains(packageName) if (!result || this == nycData) { From bce8404492340ffbd22b9417d26701053061fda9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 11 Oct 2023 12:41:33 +0300 Subject: [PATCH 23/43] Move Configuration to utbot-intellij --- .../utbot/intellij/plugin/settings/Configurable.kt | 0 .../plugin/settings/MockAlwaysClassesTable.kt | 11 ++++++----- .../utbot/intellij/plugin/settings/SettingsWindow.kt | 0 3 files changed, 6 insertions(+), 5 deletions(-) rename {utbot-ui-commons => utbot-intellij}/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt (100%) rename {utbot-ui-commons => utbot-intellij}/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt (91%) rename {utbot-ui-commons => utbot-intellij}/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt (100%) diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt similarity index 100% rename from utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt similarity index 91% rename from utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt index 1e790f6341..4803fcac44 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt @@ -11,8 +11,9 @@ import com.intellij.openapi.ui.cellvalidators.CellComponentProvider import com.intellij.openapi.ui.cellvalidators.CellTooltipManager import com.intellij.openapi.ui.cellvalidators.ValidatingTableCellRendererWrapper import com.intellij.openapi.util.Disposer -//import com.intellij.psi.JavaPsiFacade -//import com.intellij.psi.PsiClass +import com.intellij.psi.JavaPsiFacade +import com.intellij.psi.PsiClass +import com.intellij.psi.search.GlobalSearchScope import com.intellij.ui.components.fields.ExtendableTextField import com.intellij.ui.table.JBTable import com.intellij.util.ui.ColumnInfo @@ -86,7 +87,7 @@ internal class MockAlwaysClassesTable(project: Project) : ListTableWithButtons Date: Wed, 11 Oct 2023 12:41:44 +0300 Subject: [PATCH 24/43] change ideVersion --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index e02ec3ed5b..da975e38d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio -ideType=IU +ideType=IC ideVersion=232.8660.185 #ideVersion=2023.2 # ALL, NOJS From 52a949ca055535a8aacfaceaefb600ea1eb3c59b Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 11 Oct 2023 12:52:47 +0300 Subject: [PATCH 25/43] reverse changes --- .../utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt | 2 +- utbot-js/src/main/kotlin/settings/JsPackagesSettings.kt | 4 ++-- utbot-python/samples/my_cov.json | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 utbot-python/samples/my_cov.json diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt index 4803fcac44..133167ff2e 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/MockAlwaysClassesTable.kt @@ -33,7 +33,7 @@ internal class MockAlwaysClassesTable(project: Project) : ListTableWithButtons Date: Wed, 11 Oct 2023 13:04:36 +0300 Subject: [PATCH 26/43] Move RootUtilsTest.kt --- .../org/utbot/intellij/plugin/ui/utils}/RootUtilsTest.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) rename {utbot-intellij-main/src/test/kotlin/org/utbot/tests => utbot-intellij/src/test/kotlin/org/utbot/intellij/plugin/ui/utils}/RootUtilsTest.kt (93%) diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt b/utbot-intellij/src/test/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtilsTest.kt similarity index 93% rename from utbot-intellij-main/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt rename to utbot-intellij/src/test/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtilsTest.kt index ad36792ce7..cbc295104f 100644 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/RootUtilsTest.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/intellij/plugin/ui/utils/RootUtilsTest.kt @@ -1,12 +1,8 @@ -package org.utbot.tests +package org.utbot.intellij.plugin.ui.utils import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.intellij.plugin.ui.utils.ITestSourceRoot -import org.utbot.intellij.plugin.ui.utils.SRC_MAIN -import org.utbot.intellij.plugin.ui.utils.getCommonPrefix -import org.utbot.intellij.plugin.ui.utils.getSortedTestRoots internal class RootUtilsTest { internal class MockTestSourceRoot(override val dirPath: String) : ITestSourceRoot { From 834d3974e30f884658f659e03625b88798b75df5 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 11 Oct 2023 13:10:52 +0300 Subject: [PATCH 27/43] Update imports in LanguageAssistant.kt --- .../intellij/plugin/language/agnostic/LanguageAssistant.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt index 4fc4a118d8..732feff717 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/language/agnostic/LanguageAssistant.kt @@ -7,7 +7,11 @@ import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.* +import com.intellij.psi.PsiDirectory +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.psi.PsiFileSystemItem +import com.intellij.psi.PsiManager private val logger = KotlinLogging.logger {} From f3d3158cb5a2883760c6ea17aa6ec07179614fe7 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Thu, 12 Oct 2023 14:56:17 +0300 Subject: [PATCH 28/43] Split intellij settings --- .../src/main/java/SettingsTemplateHelper.java | 2 +- gradle.properties | 6 +- .../src/main/resources/META-INF/withJava.xml | 9 +- .../plugin/settings/JavaConfigurable.kt | 23 +++++ .../plugin/settings/SettingsWindow.kt | 43 +--------- .../plugin/settings/BaseSettingsWindow.kt | 83 +++++++++++++++++++ .../intellij/plugin/settings/Configurable.kt | 2 +- 7 files changed, 119 insertions(+), 49 deletions(-) create mode 100644 utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/JavaConfigurable.kt create mode 100644 utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt rename {utbot-intellij => utbot-ui-commons}/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt (92%) diff --git a/buildSrc/src/main/java/SettingsTemplateHelper.java b/buildSrc/src/main/java/SettingsTemplateHelper.java index 45502e2f33..d55390eaac 100644 --- a/buildSrc/src/main/java/SettingsTemplateHelper.java +++ b/buildSrc/src/main/java/SettingsTemplateHelper.java @@ -30,7 +30,7 @@ public class SettingsTemplateHelper { public static void proceed(Project project) { File settingsSourceDir = new File(project.getBuildDir().getParentFile().getParentFile(), "utbot-framework-api/src/main/kotlin/org/utbot/framework/"); String sourceFileName = "UtSettings.kt"; - File settingsResourceDir = new File(project.getBuildDir().getParentFile().getParentFile(), "utbot-intellij/src/main/resources/"); + File settingsResourceDir = new File(project.getBuildDir().getParentFile().getParentFile(), "utbot-intellij-main/src/main/resources/"); String settingsFileName = "settings.properties"; Map dictionary = new HashMap<>(); diff --git a/gradle.properties b/gradle.properties index da975e38d1..febe5c7a2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,9 +10,9 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio -ideType=IC -ideVersion=232.8660.185 -#ideVersion=2023.2 +ideType=PY +#ideVersion=232.8660.185 +ideVersion=2023.2 # ALL, NOJS buildType=NOJS diff --git a/utbot-intellij-main/src/main/resources/META-INF/withJava.xml b/utbot-intellij-main/src/main/resources/META-INF/withJava.xml index 2ce2e82cc9..fafe2e683d 100644 --- a/utbot-intellij-main/src/main/resources/META-INF/withJava.xml +++ b/utbot-intellij-main/src/main/resources/META-INF/withJava.xml @@ -1,3 +1,8 @@ - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/JavaConfigurable.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/JavaConfigurable.kt new file mode 100644 index 0000000000..b22f57ce78 --- /dev/null +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/JavaConfigurable.kt @@ -0,0 +1,23 @@ +package org.utbot.intellij.plugin.settings + +import com.intellij.openapi.options.SearchableConfigurable +import com.intellij.openapi.project.Project +import javax.swing.JComponent + +class JavaConfigurable(val project: Project) : SearchableConfigurable { + private val displayName: String = "UtBot Java Configuration" + private val id: String = "org.utbot.intellij.plugin.settings.UtBotSettingsConfigurableJava" + private val settingsWindow = SettingsWindow(project) + + override fun createComponent(): JComponent = settingsWindow.panel + + override fun isModified(): Boolean = settingsWindow.isModified() + + override fun apply() = settingsWindow.apply() + + override fun reset() = settingsWindow.reset() + + override fun getDisplayName(): String = displayName + + override fun getId(): String = id +} \ No newline at end of file diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt index 06d17cbd99..503507faab 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt @@ -16,8 +16,6 @@ import kotlin.reflect.KClass import org.utbot.framework.SummariesGenerationType import org.utbot.framework.UtSettings import org.utbot.framework.codegen.domain.ForceStaticMocking -import org.utbot.framework.codegen.domain.HangingTestsTimeout -import org.utbot.framework.codegen.domain.RuntimeExceptionTestsBehaviour import org.utbot.framework.plugin.api.CodeGenerationSettingItem import org.utbot.framework.plugin.api.CodegenLanguage import org.utbot.framework.plugin.api.JavaDocCommentStyle @@ -36,7 +34,6 @@ class SettingsWindow(val project: Project) { private lateinit var runInspectionAfterTestGenerationCheckBox: JCheckBox private lateinit var forceMockCheckBox: JCheckBox private lateinit var enableSummarizationGenerationCheckBox: JCheckBox - private lateinit var enableExperimentalLanguagesCheckBox: JCheckBox private fun Row.createCombo(loader: KClass<*>, values: Array<*>) { comboBox(DefaultComboBoxModel(values)) @@ -66,27 +63,12 @@ class SettingsWindow(val project: Project) { enableSummarizationGenerationCheckBox.isSelected = false } } - - enableExperimentalLanguagesCheckBox = checkBox("Experimental languages support") - .onApply { - settings.state.enableExperimentalLanguagesSupport = - enableExperimentalLanguagesCheckBox.isSelected - } - .onReset { - enableExperimentalLanguagesCheckBox.isSelected = - settings.experimentalLanguagesSupport == true - } - .onIsModified { enableExperimentalLanguagesCheckBox.isSelected xor settings.experimentalLanguagesSupport } - .component - contextHelp("Enable JavaScript and Python if IDE supports them") }.bottomGap(BottomGap.MEDIUM) - row("Tests with exceptions:") { - createCombo(RuntimeExceptionTestsBehaviour::class, RuntimeExceptionTestsBehaviour.values()) - } row("Overflow detection:") { createCombo(TreatOverflowAsError::class, TreatOverflowAsError.values()) } + row { useTaintAnalysisCheckBox = checkBox("Enable taint analysis") @@ -168,29 +150,6 @@ class SettingsWindow(val project: Project) { forceMockCheckBox.addActionListener { updater.run() } }.bottomGap(BottomGap.MEDIUM) - row("Hanging test timeout:") { - spinner( - range = IntRange( - HangingTestsTimeout.MIN_TIMEOUT_MS.toInt(), - HangingTestsTimeout.MAX_TIMEOUT_MS.toInt() - ), - step = 50 - ).bindIntValue( - getter = { - settings.hangingTestsTimeout.timeoutMs - .coerceIn(HangingTestsTimeout.MIN_TIMEOUT_MS, HangingTestsTimeout.MAX_TIMEOUT_MS).toInt() - }, - setter = { - settings.hangingTestsTimeout = HangingTestsTimeout(it.toLong()) - } - ) - - label("milliseconds per method") - contextHelp( - "Set this timeout to define which test is \"hanging\". Increase it to test the " + - "time-consuming method or decrease if the execution speed is critical for you." - ) - } val fuzzLabel = JBLabel("Fuzzing") val symLabel = JBLabel("Symbolic execution") row { diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt new file mode 100644 index 0000000000..334dcf025a --- /dev/null +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt @@ -0,0 +1,83 @@ +package org.utbot.intellij.plugin.settings + +import com.intellij.openapi.components.service +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.DialogPanel +import com.intellij.ui.dsl.builder.* +import javax.swing.* +import kotlin.reflect.KClass +import org.utbot.framework.codegen.domain.HangingTestsTimeout +import org.utbot.framework.codegen.domain.RuntimeExceptionTestsBehaviour +import org.utbot.framework.plugin.api.CodeGenerationSettingItem +import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer + +class BaseSettingsWindow(val project: Project) { + private val settings = project.service() + + private lateinit var enableExperimentalLanguagesCheckBox: JCheckBox + + private fun Row.createCombo(loader: KClass<*>, values: Array<*>) { + comboBox(DefaultComboBoxModel(values)) + .bindItem( + getter = { settings.providerNameByServiceLoader(loader) }, + setter = { settings.setProviderByLoader(loader, it as CodeGenerationSettingItem) }, + ).component.renderer = CodeGenerationSettingItemRenderer() + } + + val panel: JPanel = panel { + row { + enableExperimentalLanguagesCheckBox = checkBox("Experimental languages support") + .onApply { + settings.state.enableExperimentalLanguagesSupport = + enableExperimentalLanguagesCheckBox.isSelected + } + .onReset { + enableExperimentalLanguagesCheckBox.isSelected = + settings.experimentalLanguagesSupport == true + } + .onIsModified { enableExperimentalLanguagesCheckBox.isSelected xor settings.experimentalLanguagesSupport } + .component + contextHelp("Enable JavaScript and Python if IDE supports them") + }.bottomGap(BottomGap.MEDIUM) + + row("Tests with exceptions:") { + createCombo(RuntimeExceptionTestsBehaviour::class, RuntimeExceptionTestsBehaviour.values()) + } + + row("Hanging test timeout:") { + spinner( + range = IntRange( + HangingTestsTimeout.MIN_TIMEOUT_MS.toInt(), + HangingTestsTimeout.MAX_TIMEOUT_MS.toInt() + ), + step = 50 + ).bindIntValue( + getter = { + settings.hangingTestsTimeout.timeoutMs + .coerceIn(HangingTestsTimeout.MIN_TIMEOUT_MS, HangingTestsTimeout.MAX_TIMEOUT_MS).toInt() + }, + setter = { + settings.hangingTestsTimeout = HangingTestsTimeout(it.toLong()) + } + ) + + label("milliseconds per method") + contextHelp( + "Set this timeout to define which test is \"hanging\". Increase it to test the " + + "time-consuming method or decrease if the execution speed is critical for you." + ) + } + } + + fun isModified(): Boolean { + return (panel as DialogPanel).isModified() + } + + fun apply() { + (panel as DialogPanel).apply() + } + + fun reset() { + (panel as DialogPanel).reset() + } +} diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt similarity index 92% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt rename to utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt index 7a41ff805a..3c09b84ea2 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/Configurable.kt @@ -7,7 +7,7 @@ import javax.swing.JComponent class Configurable(val project: Project) : SearchableConfigurable { private val displayName: String = "UtBot Configuration" private val id: String = "org.utbot.intellij.plugin.settings.UtBotSettingsConfigurable" - private val settingsWindow = SettingsWindow(project) + private val settingsWindow = BaseSettingsWindow(project) override fun createComponent(): JComponent = settingsWindow.panel From 25907e8d4520b5ab972840b231bb0214384edc1a Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Thu, 12 Oct 2023 16:36:40 +0300 Subject: [PATCH 29/43] Split intellij settings --- gradle.properties | 6 ++-- .../src/main/resources/settings.properties | 11 +++++++ .../plugin/settings/BaseSettingsWindow.kt | 31 ++++++++++--------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/gradle.properties b/gradle.properties index febe5c7a2c..da975e38d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,9 +10,9 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio -ideType=PY -#ideVersion=232.8660.185 -ideVersion=2023.2 +ideType=IC +ideVersion=232.8660.185 +#ideVersion=2023.2 # ALL, NOJS buildType=NOJS diff --git a/utbot-intellij-main/src/main/resources/settings.properties b/utbot-intellij-main/src/main/resources/settings.properties index 29ce294664..657e42f4f4 100644 --- a/utbot-intellij-main/src/main/resources/settings.properties +++ b/utbot-intellij-main/src/main/resources/settings.properties @@ -594,3 +594,14 @@ # # Default value is [false] #disableUnsatChecking=false + +# +# When generating integration tests we only partially reset context in between executions to save time. +# For example, entity id generators do not get reset. It may lead to non-reproduceable results if +# IDs leak to the output of the method under test. +# To cope with that, we rerun executions that are left after minimization, fully resetting Spring context +# between executions. However, full context reset is slow, so we use this setting to limit number of +# tests per method that are rerun with full context reset in case minimization outputs too many tests. +# +# Default value is [25] +#maxSpringContextResetsPerMethod=25 diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt index 334dcf025a..db1433d7a9 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt @@ -25,21 +25,6 @@ class BaseSettingsWindow(val project: Project) { } val panel: JPanel = panel { - row { - enableExperimentalLanguagesCheckBox = checkBox("Experimental languages support") - .onApply { - settings.state.enableExperimentalLanguagesSupport = - enableExperimentalLanguagesCheckBox.isSelected - } - .onReset { - enableExperimentalLanguagesCheckBox.isSelected = - settings.experimentalLanguagesSupport == true - } - .onIsModified { enableExperimentalLanguagesCheckBox.isSelected xor settings.experimentalLanguagesSupport } - .component - contextHelp("Enable JavaScript and Python if IDE supports them") - }.bottomGap(BottomGap.MEDIUM) - row("Tests with exceptions:") { createCombo(RuntimeExceptionTestsBehaviour::class, RuntimeExceptionTestsBehaviour.values()) } @@ -67,6 +52,22 @@ class BaseSettingsWindow(val project: Project) { "time-consuming method or decrease if the execution speed is critical for you." ) } + + row { + enableExperimentalLanguagesCheckBox = checkBox("Experimental languages support") + .onApply { + settings.state.enableExperimentalLanguagesSupport = + enableExperimentalLanguagesCheckBox.isSelected + } + .onReset { + enableExperimentalLanguagesCheckBox.isSelected = + settings.experimentalLanguagesSupport == true + } + .onIsModified { enableExperimentalLanguagesCheckBox.isSelected xor settings.experimentalLanguagesSupport } + .component + contextHelp("Enable JavaScript and Python if IDE supports them") + }.bottomGap(BottomGap.MEDIUM) + } fun isModified(): Boolean { From eebe84fae4c068870f820912a5a9569f2d066167 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Thu, 12 Oct 2023 16:52:05 +0300 Subject: [PATCH 30/43] update script --- .github/workflows/publish-plugin-from-branch.yml | 8 ++++---- gradle.properties | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-plugin-from-branch.yml b/.github/workflows/publish-plugin-from-branch.yml index 37fc1c2aea..5a7296b4f5 100644 --- a/.github/workflows/publish-plugin-from-branch.yml +++ b/.github/workflows/publish-plugin-from-branch.yml @@ -49,11 +49,11 @@ jobs: - plugin_type: IU extra_options: "-PideType=IU -PprojectType=Ultimate" - plugin_type: PC - extra_options: "-PideType=PC -PprojectType=Community -PideVersion=2023.2" - - plugin_type: PU - extra_options: "-PideType=PU -PprojectType=Ultimate -PideVersion=2023.2" + extra_options: "-PideType=PC -PprojectType=Community -PideVersion=PpycharmIdeVersion" + - plugin_type: PY + extra_options: "-PideType=PY -PprojectType=Ultimate -PideVersion=2023.2" - plugin_type: GO - extra_options: "-PideType=PU -PprojectType=Community -PideVersion=2023.2" + extra_options: "-PideType=GO -PprojectType=Community -PideVersion=2023.2" runs-on: ubuntu-20.04 container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 steps: diff --git a/gradle.properties b/gradle.properties index da975e38d1..4d5506cf69 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,6 +13,7 @@ ultimateEdition=Ultimate ideType=IC ideVersion=232.8660.185 #ideVersion=2023.2 +pycharmIdeVersion=2023.2 # ALL, NOJS buildType=NOJS From 5980bbc74baabe04663b7f84f52418f43a55bdc3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 13 Oct 2023 08:52:30 +0300 Subject: [PATCH 31/43] update github script --- .github/workflows/publish-plugin-from-branch.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/publish-plugin-from-branch.yml b/.github/workflows/publish-plugin-from-branch.yml index 5a7296b4f5..0bfc04d289 100644 --- a/.github/workflows/publish-plugin-from-branch.yml +++ b/.github/workflows/publish-plugin-from-branch.yml @@ -48,12 +48,8 @@ jobs: extra_options: "-PideType=IC -PprojectType=Community" - plugin_type: IU extra_options: "-PideType=IU -PprojectType=Ultimate" - - plugin_type: PC - extra_options: "-PideType=PC -PprojectType=Community -PideVersion=PpycharmIdeVersion" - plugin_type: PY extra_options: "-PideType=PY -PprojectType=Ultimate -PideVersion=2023.2" - - plugin_type: GO - extra_options: "-PideType=GO -PprojectType=Community -PideVersion=2023.2" runs-on: ubuntu-20.04 container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 steps: From d048983a886decc0458020c3229ea4c36e4beea3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 13 Oct 2023 10:36:22 +0300 Subject: [PATCH 32/43] Move tests --- utbot-intellij-main/build.gradle.kts | 38 ---- .../kotlin/org/utbot/data/IdeaBuildSystem.kt | 9 - .../test/kotlin/org/utbot/data/JDKVersion.kt | 10 - .../src/test/kotlin/org/utbot/data/RunInfo.kt | 11 -- .../kotlin/org/utbot/dialogs/DialogFixture.kt | 36 ---- .../utbot/dialogs/NewProjectDialogFixture.kt | 104 ----------- .../utbot/dialogs/OpenProjectDialogFixture.kt | 21 --- .../utbot/dialogs/UnitTestBotDialogFixture.kt | 32 ---- .../org/utbot/dialogs/WarningDialogFixture.kt | 24 --- .../org/utbot/elements/ActionMenuFixture.kt | 30 --- .../org/utbot/elements/NotificationFixture.kt | 28 --- .../test/kotlin/org/utbot/pages/IdeaFrame.kt | 173 ------------------ .../kotlin/org/utbot/pages/IdeaGradleFrame.kt | 50 ----- .../kotlin/org/utbot/pages/IdeaMavenFrame.kt | 22 --- .../kotlin/org/utbot/pages/WelcomeFrame.kt | 60 ------ .../kotlin/org/utbot/samples/CodeSamples.kt | 40 ---- .../test/kotlin/org/utbot/steps/IDESteps.kt | 52 ------ .../test/kotlin/org/utbot/tests/BaseTest.kt | 93 ---------- .../kotlin/org/utbot/tests/CreateProjects.kt | 41 ----- .../org/utbot/tests/UnitTestBotActionTest.kt | 76 -------- .../org/utbot/utils/RemoteRobotExtension.kt | 135 -------------- .../kotlin/org/utbot/utils/StepsLogger.kt | 15 -- utbot-intellij/build.gradle.kts | 69 ++++++- 23 files changed, 68 insertions(+), 1101 deletions(-) delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/data/JDKVersion.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/data/RunInfo.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/elements/NotificationFixture.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaFrame.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/samples/CodeSamples.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/steps/IDESteps.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/tests/BaseTest.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/tests/CreateProjects.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt delete mode 100644 utbot-intellij-main/src/test/kotlin/org/utbot/utils/StepsLogger.kt diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index 69c02ff51e..1461820031 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -82,8 +82,6 @@ intellij { SettingsTemplateHelper.proceed(project) } -val remoteRobotVersion = "0.11.16" - tasks { compileKotlin { kotlinOptions { @@ -109,31 +107,6 @@ tasks { untilBuild.set("232.*") version.set(semVer) } - - runIdeForUiTests { - jvmArgs("-Xmx2048m", "-Didea.is.internal=true", "-Didea.ui.debug.mode=true") - - systemProperty("robot-server.port", "8082") // default port 8580 - systemProperty("ide.mac.message.dialogs.as.sheets", "false") - systemProperty("jb.privacy.policy.text", "") - systemProperty("jb.consents.confirmation.enabled", "false") - systemProperty("idea.trust.all.projects", "true") - systemProperty("ide.mac.file.chooser.native", "false") - systemProperty("jbScreenMenuBar.enabled", "false") - systemProperty("apple.laf.useScreenMenuBar", "false") - systemProperty("ide.show.tips.on.startup.default.value", "false") - } - - downloadRobotServerPlugin { - version.set(remoteRobotVersion) - } - - test { - description = "Runs UI integration tests." - useJUnitPlatform { - exclude("/org/utbot/**") //Comment this line to run the tests locally - } - } } repositories { @@ -169,17 +142,6 @@ dependencies { implementation(project(":utbot-android-studio")) - testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion") - testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion") - - testImplementation("org.assertj:assertj-core:3.11.1") - - // Logging Network Calls - testImplementation("com.squareup.okhttp3:logging-interceptor:4.10.0") - - // Video Recording - implementation("com.automation-remarks:video-recorder-junit5:2.0") - testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version") testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junit4PlatformVersion") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit5Version") diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt deleted file mode 100644 index 0e602fbff7..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.utbot.data - -enum class IdeaBuildSystem (val system: String) { - - INTELLIJ("IntelliJ"), - GRADLE("Gradle"), - MAVEN("Maven") - -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/data/JDKVersion.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/data/JDKVersion.kt deleted file mode 100644 index ea4b872573..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/data/JDKVersion.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.utbot.data - -enum class JDKVersion (val namePart: String, val number: Int, val supported: Boolean) { - - JDK_1_8(namePart = "1.8", 8, true), - JDK_11(namePart = "11", 11, true), - JDK_17(namePart = "17", 17, true), - JDK_19(namePart = "19", 19, false); - override fun toString() = namePart -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/data/RunInfo.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/data/RunInfo.kt deleted file mode 100644 index f91630c119..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/data/RunInfo.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.utbot.data - -import java.time.LocalDateTime -import java.time.format.DateTimeFormatter -import java.util.Random - -val TEST_RUN_NUMBER = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) -val DEFAULT_TEST_GENERATION_TIMEOUT = 60L -val NEW_PROJECT_NAME_START = "Aut_${TEST_RUN_NUMBER}_" -val DEFAULT_PROJECT_DIRECTORY = "~\\IdeaProjects" -var random: Random = Random() diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt deleted file mode 100644 index ca643c84cc..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt +++ /dev/null @@ -1,36 +0,0 @@ -package org.utbot.dialogs - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.CommonContainerFixture -import com.intellij.remoterobot.fixtures.ContainerFixture -import com.intellij.remoterobot.fixtures.FixtureName -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.stepsProcessing.step -import java.time.Duration - -fun ContainerFixture.dialog( - title: String, - timeout: Duration = Duration.ofSeconds(20), - function: DialogFixture.() -> Unit = {}): DialogFixture = step("Search for dialog with title $title") { - find(DialogFixture.byTitle(title), timeout).apply(function) -} - -@FixtureName("Dialog") -open class DialogFixture( - remoteRobot: RemoteRobot, - remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { - - companion object { - @JvmStatic - fun byTitle(title: String) = byXpath("title $title", "//div[@title='$title' and @class='MyDialog']") - } - - val title: String - get() = callJs("component.getTitle();") - - val closeButton - get() = button( - byXpath("//div[@class='DialogRootPane']//div[@class='JButton']")) - -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt deleted file mode 100644 index 1ddc6660cc..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt +++ /dev/null @@ -1,104 +0,0 @@ -package org.utbot.dialogs - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.* -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.stepsProcessing.step -import com.intellij.remoterobot.utils.Keyboard -import com.intellij.remoterobot.utils.keyboard -import com.intellij.remoterobot.utils.waitForIgnoringError -import org.utbot.data.DEFAULT_PROJECT_DIRECTORY -import org.utbot.data.IdeaBuildSystem -import org.utbot.data.JDKVersion -import java.awt.event.KeyEvent -import java.time.Duration -import java.time.Duration.ofSeconds - -@FixtureName("NewProjectDialog") -@DefaultXpath("type", "//*[contains(@title.key, 'title.new.project')]") -class NewProjectDialogFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) - : DialogFixture(remoteRobot, remoteComponent) { - val keyboard: Keyboard = Keyboard(remoteRobot) - - val wizardsList - get() = jList( - byXpath("//div[@class='JBList']")) - - val nameInput - get() = textField( - byXpath("//div[@class='JBTextField']")) - - val locationInput - get() = textField( - byXpath("//div[@class='ExtendableTextField']")) - - val addSampleCodeCheckbox - get() = checkBox( - byXpath("//div[@text.key='label.project.wizard.new.project.add.sample.code']")) - - val jdkComboBox - get() = comboBox( - byXpath("//div[@class='JdkComboBox']"), - Duration.ofSeconds(10)) - - val jdkList - get() = heavyWeightWindow().itemsList - - val createButton - get() = button( - byXpath("//div[@text.key='button.create']")) - - val cancelButton - get() = button( - byXpath("//div[@text.key='button.cancel']")) - - fun selectWizard(wizardName: String) { - if (title != wizardName) { - wizardsList.findText(wizardName).click() - } - } - - fun selectJDK(jdkVersion: String) { - step("Select JDK: $jdkVersion") { - jdkComboBox.click() - var jdkMatching = jdkVersion - waitForIgnoringError(ofSeconds(20)) { - findAll(byXpath("//*[@text.key='progress.title.detecting.sdks']")).isEmpty() - jdkMatching = jdkList.collectItems().first { it.contains(jdkVersion) } - jdkMatching.isEmpty().not() - } - jdkList.clickItem(jdkMatching) - } - } - - fun fillDialog(projectName: String, - location: String = "", - language: String = "Java", - buildSystem: IdeaBuildSystem = IdeaBuildSystem.INTELLIJ, - jdkVersion: JDKVersion, - addSampleCode: Boolean = true) { - step("Fill New Project dialog") { - nameInput.doubleClick() - keyboard.hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_A) - keyboard.enterText(projectName) - var input = DEFAULT_PROJECT_DIRECTORY - if (location != "") { - input = location - } - if (locationInput.hasText(input).not()) { - locationInput.click() - keyboard{ - hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_A) - enterText(input.replace("\\", "\\\\")) - } - } - this.findText(language).click() - this.findText(buildSystem.system).click() - addSampleCodeCheckbox.setValue(addSampleCode) - if (!jdkComboBox.selectedText().contains(jdkVersion.namePart)) { - selectJDK(jdkVersion.namePart) - } - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt deleted file mode 100644 index ec2cf4939e..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt +++ /dev/null @@ -1,21 +0,0 @@ -package org.utbot.dialogs - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.* -import com.intellij.remoterobot.search.locators.byXpath - -@FixtureName("OpenProjectDialog") -@DefaultXpath("Dialog type", "//*[@title.key='title.open.file.or.project']") -class OpenProjectDialogFixture( - remoteRobot: RemoteRobot, - remoteComponent: RemoteComponent) : DialogFixture(remoteRobot, remoteComponent) { - - val pathInput - get() = textField( - byXpath("//div[@class='BorderlessTextField']")) - - val okButton - get() = button( - byXpath("//div[@text.key='button.ok']")) -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt deleted file mode 100644 index 0a411ea440..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt +++ /dev/null @@ -1,32 +0,0 @@ -package org.utbot.dialogs - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.* -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.utils.Keyboard - -@FixtureName("UnitTestBotDialog") -@DefaultXpath("Dialog type", "//*[contains(@title, 'UnitTestBot')]") -class UnitTestBotDialogFixture( - remoteRobot: RemoteRobot, - remoteComponent: RemoteComponent) : DialogFixture(remoteRobot, remoteComponent) { - val keyboard: Keyboard = Keyboard(remoteRobot) - - val sdkNotificationLabel - get() = jLabel( - byXpath("//div[@class='SdkNotificationPanel']//div[@defaulticon='fatalError.svg']")) - - val setupSdkLink - get() = actionLink( - byXpath("//div[@class='SdkNotificationPanel']//div[@class='HyperlinkLabel']")) - - val testSourcesRootComboBox - get() = comboBox( - byXpath("//div[@class='TestFolderComboWithBrowseButton']/div[1]")) - - val generateTestsButton - get() = button( - byXpath("//div[@class='MainButton']")) - -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt deleted file mode 100644 index f5e4a1e651..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.utbot.dialogs - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.* -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.utils.Keyboard - -@FixtureName("MyDialog") -@DefaultXpath("type", "//div[@class='DialogRootPane']") -class WarningDialogFixture( - remoteRobot: RemoteRobot, - remoteComponent: RemoteComponent) : DialogFixture(remoteRobot, remoteComponent) { - val keyboard: Keyboard = Keyboard(remoteRobot) - - val terminateButton - get() = button( - byXpath("//div[@text.key='button.terminate']")) - - val cancelButton - get() = button( - byXpath("//div[@text.key='button.cancel']")) - -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt deleted file mode 100644 index 6ec17bc84c..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt +++ /dev/null @@ -1,30 +0,0 @@ -package org.utbot.pages - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.ComponentFixture -import com.intellij.remoterobot.fixtures.FixtureName -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.utils.waitFor - -fun RemoteRobot.actionMenu(text: String): ActionMenuFixture { - val xpath = byXpath("text '$text'", "//div[@class='ActionMenu' and @text='$text']") - waitFor { - findAll(xpath).isNotEmpty() - } - return findAll(xpath).first() -} - -fun RemoteRobot.actionMenuItem(text: String): ActionMenuItemFixture { - val xpath = byXpath("text '$text'", "//div[@class='ActionMenuItem' and @text='$text']") - waitFor { - findAll(xpath).isNotEmpty() - } - return findAll(xpath).first() -} - -@FixtureName("ActionMenu") -class ActionMenuFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : ComponentFixture(remoteRobot, remoteComponent) - -@FixtureName("ActionMenuItem") -class ActionMenuItemFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : ComponentFixture(remoteRobot, remoteComponent) diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/elements/NotificationFixture.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/elements/NotificationFixture.kt deleted file mode 100644 index 5683f12db5..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/elements/NotificationFixture.kt +++ /dev/null @@ -1,28 +0,0 @@ -package org.utbot.elements - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.CommonContainerFixture -import com.intellij.remoterobot.fixtures.ComponentFixture -import com.intellij.remoterobot.fixtures.DefaultXpath -import com.intellij.remoterobot.fixtures.FixtureName -import com.intellij.remoterobot.search.locators.byXpath -import java.time.Duration.ofSeconds - -@FixtureName("Notification Center Panel") -@DefaultXpath("NotificationCenterPanel type", "//div[@class='NotificationCenterPanel']") -class NotificationFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { - - val title - get() = jLabel(byXpath("//div[@class='JLabel']"), - ofSeconds(5)) - - val body - get() = remoteRobot.find(byXpath("//div[@class='JEditorPane']"), - ofSeconds(5)) - - val link - get() = remoteRobot.find(byXpath("//div[@class='LinkLabel']"), - ofSeconds(5)) -} - diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaFrame.kt deleted file mode 100644 index 317cd626a6..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaFrame.kt +++ /dev/null @@ -1,173 +0,0 @@ -package org.utbot.pages - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.* -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.stepsProcessing.step -import com.intellij.remoterobot.utils.keyboard -import com.intellij.remoterobot.utils.waitFor -import com.intellij.remoterobot.utils.waitForIgnoringError -import org.assertj.swing.core.MouseButton -import org.utbot.data.IdeaBuildSystem -import org.utbot.dialogs.UnitTestBotDialogFixture -import org.utbot.dialogs.WarningDialogFixture -import org.utbot.elements.NotificationFixture -import java.awt.event.KeyEvent -import java.time.Duration -import java.time.Duration.ofSeconds - -fun RemoteRobot.idea(function: IdeaFrame.() -> Unit) { - find(timeout = ofSeconds(5)).apply(function) -} - -@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']") -open class IdeaFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { - - open val buildSystemToUse: IdeaBuildSystem = IdeaBuildSystem.INTELLIJ - - val projectViewTree - get() = find(byXpath("ProjectViewTree", "//div[@class='ProjectViewTree']"), - ofSeconds(10)) - - val projectName - get() = step("Get project name") { return@step callJs("component.getProject().getName()") } - - val menuBar: JMenuBarFixture - get() = step("Menu...") { - return@step remoteRobot.find(JMenuBarFixture::class.java, JMenuBarFixture.byType()) - } - - val inlineProgressTextPanel - get() = remoteRobot.find(byXpath("//div[@class='InlineProgressPanel']//div[@class='TextPanel']"), - ofSeconds(10)) - - val statusTextPanel - get() = remoteRobot.find(byXpath("//div[@class='StatusPanel']//div[@class='TextPanel']"), - ofSeconds(10)) - - val buildResultInEditor - get() = remoteRobot.find(byXpath("//div[@class='TrafficLightButton']"), - ofSeconds(20)) - - val buildResult - get() = textField(byXpath("//div[contains(@accessiblename.key, 'editor.accessible.name')]"), - ofSeconds(20)) - - val ideError - get() = remoteRobot.find(byXpath( "//div[@class='NotificationCenterPanel'][.//div[@accessiblename.key='error.new.notification.title']]"), - ofSeconds(10)) - - val utbotNotification - get() = remoteRobot.find(byXpath( "//div[@class='NotificationCenterPanel'][div[contains(.,'UnitTestBot')]]"), - ofSeconds(10)) - - val unitTestBotDialog - get() = remoteRobot.find(UnitTestBotDialogFixture::class.java, - ofSeconds(10)) - - @JvmOverloads - fun dumbAware(timeout: Duration = Duration.ofMinutes(5), function: () -> Unit) { - step("Wait for smart mode") { - waitFor(duration = timeout, interval = ofSeconds(5)) { - runCatching { isDumbMode().not() }.getOrDefault(false) - } - function() - step("..wait for smart mode again") { - waitFor(duration = timeout, interval = ofSeconds(5)) { - isDumbMode().not() - } - } - } - } - - fun isDumbMode(): Boolean { - return callJs(""" - const frameHelper = com.intellij.openapi.wm.impl.ProjectFrameHelper.getFrameHelper(component) - if (frameHelper) { - const project = frameHelper.getProject() - project ? com.intellij.openapi.project.DumbService.isDumb(project) : true - } else { - true - } - """, true) - } - - fun closeProject() { - if (remoteRobot.isMac()) { - keyboard { - hotKey(KeyEvent.VK_SHIFT, KeyEvent.VK_META, KeyEvent.VK_A) - enterText("Close Project") - enter() - } - } else { - menuBar.select("File", "Close Project") - } - try { - remoteRobot.find(WarningDialogFixture::class.java, ofSeconds(1)) - .terminateButton.click() - } catch (ignore: Throwable) {} - } - - fun openUTBotDialogFromProjectViewForClass(classname: String) { - step("Call UnitTestBot action") { - waitFor(ofSeconds(200)) { !isDumbMode() } - with(projectViewTree) { - findText(classname).click(MouseButton.RIGHT_BUTTON) - } - remoteRobot.actionMenuItem("Generate Tests with UnitTestBot...").click() - } - } - - open fun waitProjectIsOpened() { - waitForIgnoringError(ofSeconds(30)) { - projectViewTree.hasText(projectName) - } - } - - open fun waitProjectIsCreated() { - waitProjectIsOpened() - } - - open fun expandProjectTree(projectName: String) { - with(projectViewTree) { - if (hasText("src").not()) { - findText(projectName).doubleClick() - waitForIgnoringError{ - hasText("src").and(hasText(".idea")) - } - } - } - } - - open fun createNewPackage(packageName: String) { - with(projectViewTree) { - if (hasText("src").not()) { - findText(projectName).doubleClick() - waitFor { hasText("src") } - } - findText("src").click(MouseButton.RIGHT_BUTTON) - } - remoteRobot.actionMenu("New").click() - remoteRobot.actionMenuItem("Package").click() - keyboard { - enterText(packageName) - enter() - } - } - - fun createNewJavaClass(newClassname: String = "Example", - textToClickOn: String = "Main") { - waitProjectIsOpened() - expandProjectTree(projectName) - with(projectViewTree) { - findText(textToClickOn).click(MouseButton.RIGHT_BUTTON) - } - remoteRobot.actionMenu("New").click() - remoteRobot.actionMenuItem("Java Class").click() - remoteRobot.keyboard { - enterText(newClassname) - enter() - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt deleted file mode 100644 index 52d0fad081..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt +++ /dev/null @@ -1,50 +0,0 @@ -package org.utbot.pages - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.DefaultXpath -import com.intellij.remoterobot.utils.waitForIgnoringError -import org.utbot.data.IdeaBuildSystem -import java.time.Duration.ofSeconds - -@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']") -class IdeaGradleFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : IdeaFrame(remoteRobot, remoteComponent) { - - override val buildSystemToUse = IdeaBuildSystem.GRADLE - - override fun waitProjectIsCreated() { - super.waitProjectIsOpened() - repeat (120) { - inlineProgressTextPanel.isShowing.not() - } - } - - override fun expandProjectTree(projectName: String) { - with(projectViewTree) { - waitForIgnoringError(ofSeconds(10)) { - hasText("src") - } - if (hasText("src").not()) { - findText(projectName).doubleClick() - waitForIgnoringError{ - hasText("src") - } - } - if (hasText("main").not()) { - findText("src").doubleClick() - waitForIgnoringError{ - hasText("src").and(hasText("main")) - } - } - if (hasText("java").not()) { - findText("main").doubleClick() - waitForIgnoringError{ - hasText("src").and(hasText("main")).and(hasText("java")) - } - } - if (hasText("Main").not()) { - findText("java").doubleClick() - } - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt deleted file mode 100644 index f3fbe39805..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt +++ /dev/null @@ -1,22 +0,0 @@ -package org.utbot.pages - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.DefaultXpath -import com.intellij.remoterobot.utils.waitForIgnoringError -import org.utbot.data.IdeaBuildSystem -import java.time.Duration.ofSeconds - -@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']") -class IdeaMavenFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : IdeaFrame(remoteRobot, remoteComponent) { - - override val buildSystemToUse = IdeaBuildSystem.MAVEN - - override fun waitProjectIsOpened() { - super.waitProjectIsOpened() - waitForIgnoringError (ofSeconds(60)) { - projectViewTree.hasText("Main.java").not() - projectViewTree.hasText("Main") - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt deleted file mode 100644 index 16eab0011f..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt +++ /dev/null @@ -1,60 +0,0 @@ -package org.utbot.pages - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.data.RemoteComponent -import com.intellij.remoterobot.fixtures.* -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.utils.Keyboard -import org.utbot.data.IdeaBuildSystem -import org.utbot.data.JDKVersion -import org.utbot.dialogs.NewProjectDialogFixture -import org.utbot.dialogs.OpenProjectDialogFixture -import java.time.Duration - -fun RemoteRobot.welcomeFrame(function: WelcomeFrame.()-> Unit) { - find(WelcomeFrame::class.java, Duration.ofSeconds(10)).apply(function) -} - -@FixtureName("Welcome Frame") -@DefaultXpath("Welcome Frame type", "//div[@class='FlatWelcomeFrame']") -class WelcomeFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { - val keyboard: Keyboard = Keyboard(remoteRobot) - val ideaVersion //ToDO good locator - get() = jLabel(byXpath("//div[@class='TabbedWelcomeScreen']//div[@class='JLabel' and contains(@text,'20')]")) - - val newProjectLink - get() = actionLink(byXpath("New Project","//div[(@class='MainButton' and @text='New Project') or (@accessiblename='New Project' and @class='JButton')]")) - val openProjectLink - get() = actionLink(byXpath("Open","//div[(@class='MainButton' and @text='Open') or (@accessiblename.key='action.WelcomeScreen.OpenProject.text')]")) - val moreActions - get() = button(byXpath("More Action", "//div[@accessiblename='More Actions']")) - - val recentProjectLinks - get() = jTree(byXpath("//div[@class='CardLayoutPanel']//div[@class='Tree']")) - - val openProjectDialog - get() = remoteRobot.find(OpenProjectDialogFixture::class.java) - - val newProjectDialog - get() = remoteRobot.find(NewProjectDialogFixture::class.java) - - fun openProjectByPath(projectName: String, - location: String = "") { - val localPath = location + projectName - openProjectLink.click() - keyboard.enterText(localPath) - openProjectDialog.okButton.click() - } - - fun createNewProject(projectName: String, location: String = "", - language: String = "Java", buildSystem: IdeaBuildSystem = IdeaBuildSystem.INTELLIJ, - jdkVersion: JDKVersion, addSampleCode: Boolean = true) { - newProjectLink.click() - newProjectDialog.selectWizard("New Project") - newProjectDialog.fillDialog( - projectName, location, language, - buildSystem, jdkVersion, addSampleCode - ) - newProjectDialog.createButton.click() - } -} diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/samples/CodeSamples.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/samples/CodeSamples.kt deleted file mode 100644 index 0464782fe3..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/samples/CodeSamples.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.utbot.samples - -import com.intellij.remoterobot.fixtures.TextEditorFixture -import com.intellij.remoterobot.utils.keyboard -import org.utbot.data.TEST_RUN_NUMBER -import java.awt.event.KeyEvent - -fun TextEditorFixture.typeAdditionFunction(className: String): String { - editor.selectText(className) - keyboard { - key(KeyEvent.VK_END) - enter() - enterText("public int addition(") - enterText("int a, int b") - key(KeyEvent.VK_END) - enterText("{") - enter() - enterText("// Test run ${TEST_RUN_NUMBER}") - enter() - enterText("return a + b;") - } - return "@utbot.returnsFrom {@code return a + b;}" -} - -fun TextEditorFixture.typeDivisionFunction(className: String) : String { - editor.selectText(className) - keyboard { - key(KeyEvent.VK_END) - enter() - enterText("public int division(") - enterText("int a, int b") - key(KeyEvent.VK_END) - enterText("{") - enter() - enterText("// Test run ${TEST_RUN_NUMBER}") - enter() - enterText("return a / b;") - } - return "@utbot.returnsFrom {@code return a / b;}" -} diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/steps/IDESteps.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/steps/IDESteps.kt deleted file mode 100644 index c6dc22c7b3..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/steps/IDESteps.kt +++ /dev/null @@ -1,52 +0,0 @@ -package org.utbot.steps - -import com.intellij.remoterobot.fixtures.TextEditorFixture -import com.intellij.remoterobot.fixtures.dataExtractor.contains -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.stepsProcessing.step -import com.intellij.remoterobot.utils.keyboard -import com.intellij.remoterobot.utils.waitFor -import org.utbot.dialogs.DialogFixture -import org.utbot.dialogs.DialogFixture.Companion.byTitle -import org.utbot.pages.IdeaFrame -import java.awt.event.KeyEvent -import java.time.Duration.ofSeconds - -fun IdeaFrame.autocomplete(text: String) { - step("Autocomplete '" + text + "'") { - keyboard { - enterText(text) - } - heavyWeightWindow(ofSeconds(5)) - .findText(contains(text)) - .click() - keyboard { - enter() - } - } -} - -fun TextEditorFixture.goToLineAndColumn(row: Int, column: Int) { - keyboard { - if (remoteRobot.isMac()) { - hotKey(KeyEvent.VK_META, KeyEvent.VK_L) - } else { - hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_G) - } - enterText("$row:$column") - enter() - } -} - -fun IdeaFrame.closeTipOfTheDay() { - step("Close Tip of the Day if it appears") { - waitFor(ofSeconds(20)) { - remoteRobot.findAll(byXpath("//div[@class='MyDialog'][.//div[@text='Running startup activities...']]")) - .isEmpty() - } - try { - find(byTitle ("Tip of the Day")) - .button("Close").click() - } catch (ignore: Throwable) {} - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/BaseTest.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/tests/BaseTest.kt deleted file mode 100644 index 2978faa03d..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/BaseTest.kt +++ /dev/null @@ -1,93 +0,0 @@ -package org.utbot.tests - -import com.intellij.remoterobot.RemoteRobot -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.extension.ExtendWith -import org.junit.jupiter.params.provider.Arguments -import org.utbot.data.IdeaBuildSystem -import org.utbot.data.JDKVersion -import org.utbot.pages.IdeaFrame -import org.utbot.pages.IdeaGradleFrame -import org.utbot.pages.IdeaMavenFrame -import org.utbot.pages.idea -import org.utbot.utils.RemoteRobotExtension -import org.utbot.utils.StepsLogger -import java.time.Duration.ofSeconds - -@ExtendWith(RemoteRobotExtension::class) -open class BaseTest { - fun getIdeaFrameForBuildSystem(remoteRobot: RemoteRobot, ideaBuildSystem: IdeaBuildSystem): IdeaFrame { - when (ideaBuildSystem) { - IdeaBuildSystem.INTELLIJ -> return remoteRobot.find(IdeaFrame::class.java, ofSeconds(10)) - IdeaBuildSystem.GRADLE -> return remoteRobot.find(IdeaGradleFrame::class.java, ofSeconds(10)) - IdeaBuildSystem.MAVEN -> return remoteRobot.find(IdeaMavenFrame::class.java, ofSeconds(10)) - } - } - - @BeforeEach - fun `Close each project before test`(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { - try { - idea { - closeProject() - } - } catch (ignore: Throwable) {} - } - - @AfterEach - fun `Close each project after test`(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { - idea { - closeProject() - } - } - - companion object { - @BeforeAll - @JvmStatic - fun init(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { - StepsLogger.init() - } - - private val supportedProjectsList: List = - addPairsToList(true) - private val unsupportedProjectsList: List = - addPairsToList(false) - - @JvmStatic - fun supportedProjectsProvider(): List { - return supportedProjectsList - } - - @JvmStatic - fun unsupportedProjectsProvider(): List { - return unsupportedProjectsList - } - - @JvmStatic - fun allProjectsProvider(): List { - return supportedProjectsList + unsupportedProjectsList - } - - @JvmStatic - private fun addPairsToList(supported: Boolean): List { - val ideaBuildSystems = IdeaBuildSystem.values() - ideaBuildSystems.shuffle() - var j = 0 - - val listOfArguments: MutableList = mutableListOf() - JDKVersion.values().toMutableList().filter { - it.supported == supported - }.forEach { - listOfArguments.add( - Arguments.of(ideaBuildSystems[j], it) //each (un)supported JDK with a random build system - ) - j++ - if (j >= ideaBuildSystems.size) { - j = 0 - } - } - return listOfArguments - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/CreateProjects.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/tests/CreateProjects.kt deleted file mode 100644 index eee5299898..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/CreateProjects.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.utbot.tests - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.utils.waitFor -import org.junit.jupiter.api.Order -import org.junit.jupiter.api.Tag -import org.junit.jupiter.api.Tags -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.MethodSource -import org.utbot.data.IdeaBuildSystem -import org.utbot.data.JDKVersion -import org.utbot.data.NEW_PROJECT_NAME_START -import org.utbot.pages.welcomeFrame -import java.time.Duration - -@Order(1) -class CreateProjects : BaseTest() { - @ParameterizedTest(name = "Create {0} project with JDK {1}") - @Tags(Tag("smoke"), Tag("NewProject"), Tag("Java"), Tag("UTBot"), Tag("")) - @MethodSource("allProjectsProvider") - fun createProjectWithSupportedJDK( - ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, - remoteRobot: RemoteRobot - ): Unit = with(remoteRobot) { - val newProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number - remoteRobot.welcomeFrame { - createNewProject( - projectName = newProjectName, - buildSystem = ideaBuildSystem, - jdkVersion = jdkVersion - ) - } - val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) - with(ideaFrame) { - waitProjectIsCreated() - waitFor(Duration.ofSeconds(30)) { - !isDumbMode() - } - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt deleted file mode 100644 index e06b403bc8..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt +++ /dev/null @@ -1,76 +0,0 @@ -package org.utbot.tests - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.utils.waitForIgnoringError -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.* -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.MethodSource -import org.utbot.data.IdeaBuildSystem -import org.utbot.data.JDKVersion -import org.utbot.data.NEW_PROJECT_NAME_START -import org.utbot.pages.* -import org.utbot.samples.typeAdditionFunction -import org.utbot.samples.typeDivisionFunction -import java.time.Duration.ofSeconds - -class UnitTestBotActionTest : BaseTest() { - - @ParameterizedTest(name = "Generate tests in {0} project with JDK {1}") - @MethodSource("supportedProjectsProvider") - @Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Positive")) - fun checkBasicTestGeneration(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, - remoteRobot: RemoteRobot) { - val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number - remoteRobot.welcomeFrame { - findText(createdProjectName).click() - } - val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) - with (ideaFrame) { - val newClassName = "Arithmetic" - createNewJavaClass(newClassName, "Main") - val returnsFromTagBody = textEditor().typeDivisionFunction(newClassName) - openUTBotDialogFromProjectViewForClass(newClassName) - unitTestBotDialog.generateTestsButton.click() - waitForIgnoringError (ofSeconds(5)){ - inlineProgressTextPanel.isShowing - } - waitForIgnoringError (ofSeconds(90)){ - inlineProgressTextPanel.hasText("Generate test cases for class $newClassName") - } - waitForIgnoringError(ofSeconds(30)) { - utbotNotification.title.hasText("UnitTestBot: unit tests generated successfully") - } - assertThat(textEditor().editor.text).contains("class ${newClassName}Test") - assertThat(textEditor().editor.text).contains("@Test\n") - assertThat(textEditor().editor.text).contains("assertEquals(") - assertThat(textEditor().editor.text).contains("@utbot.classUnderTest {@link ${newClassName}}") - assertThat(textEditor().editor.text).contains("@utbot.methodUnderTest {@link ${newClassName}#") - assertThat(textEditor().editor.text).contains(returnsFromTagBody) - //ToDo verify how many tests are generated - //ToDo verify Problems view and Arithmetic exception on it - } - } - - @ParameterizedTest(name = "Check Generate tests button is disabled in {0} project with unsupported JDK {1}") - @MethodSource("unsupportedProjectsProvider") - @Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Negative")) - fun checkProjectWithUnsupportedJDK(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, - remoteRobot: RemoteRobot) { - val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number - remoteRobot.welcomeFrame { - findText(createdProjectName).click() - } - val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) - return with (ideaFrame) { - val newClassName = "Arithmetic" - createNewJavaClass(newClassName, "Main") - textEditor().typeAdditionFunction(newClassName) - openUTBotDialogFromProjectViewForClass(newClassName) - assertThat(unitTestBotDialog.generateTestsButton.isEnabled().not()) - assertThat(unitTestBotDialog.sdkNotificationLabel.hasText("SDK version 19 is not supported, use 1.8, 11 or 17 instead.")) - assertThat(unitTestBotDialog.setupSdkLink.isShowing) - unitTestBotDialog.closeButton.click() - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt deleted file mode 100644 index 650542c1f2..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt +++ /dev/null @@ -1,135 +0,0 @@ -package org.utbot.utils - -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.fixtures.ContainerFixture -import com.intellij.remoterobot.search.locators.byXpath -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.logging.HttpLoggingInterceptor -import org.junit.jupiter.api.extension.AfterTestExecutionCallback -import org.junit.jupiter.api.extension.ExtensionContext -import org.junit.jupiter.api.extension.ParameterContext -import org.junit.jupiter.api.extension.ParameterResolver -import java.awt.image.BufferedImage -import java.io.ByteArrayOutputStream -import java.io.File -import java.lang.IllegalStateException -import java.lang.reflect.Method -import javax.imageio.ImageIO - -class RemoteRobotExtension : AfterTestExecutionCallback, ParameterResolver { - private val url: String = System.getProperty("remote-robot-url") ?: "http://127.0.0.1:8082" - private val remoteRobot: RemoteRobot = if (System.getProperty("debug-retrofit")?.equals("enable") == true) { - val interceptor: HttpLoggingInterceptor = HttpLoggingInterceptor().apply { - this.level = HttpLoggingInterceptor.Level.BODY - } - val client = OkHttpClient.Builder().apply { - this.addInterceptor(interceptor) - }.build() - RemoteRobot(url, client) - } else { - RemoteRobot(url) - } - private val client = OkHttpClient() - - override fun supportsParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Boolean { - return parameterContext?.parameter?.type?.equals(RemoteRobot::class.java) ?: false - } - - override fun resolveParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Any { - return remoteRobot - } - - override fun afterTestExecution(context: ExtensionContext?) { - val testMethod: Method = context?.requiredTestMethod ?: throw IllegalStateException("test method is null") - val testMethodName = testMethod.name - val testFailed: Boolean = context.executionException?.isPresent ?: false - if (testFailed) { - saveScreenshot(testMethodName) - saveIdeaFrames(testMethodName) - saveHierarchy(testMethodName) - } - } - - private fun saveScreenshot(testName: String) { - fetchScreenShot().save(testName) - } - - private fun saveHierarchy(testName: String) { - val hierarchySnapshot = - saveFile(url, "build/reports", "hierarchy-$testName.html") - if (File("build/reports/styles.css").exists().not()) { - saveFile("$url/styles.css", "build/reports", "styles.css") - } - println("Hierarchy snapshot: ${hierarchySnapshot.absolutePath}") - } - - private fun saveFile(url: String, folder: String, name: String): File { - val response = client.newCall(Request.Builder().url(url).build()).execute() - return File(folder).apply { - mkdirs() - }.resolve(name).apply { - writeText(response.body?.string() ?: "") - } - } - - private fun BufferedImage.save(name: String) { - val bytes = ByteArrayOutputStream().use { b -> - ImageIO.write(this, "png", b) - b.toByteArray() - } - File("build/reports").apply { mkdirs() }.resolve("$name.png").writeBytes(bytes) - } - - private fun saveIdeaFrames(testName: String) { - remoteRobot.findAll(byXpath("//div[@class='IdeFrameImpl']")).forEachIndexed { n, frame -> - val pic = try { - frame.callJs( - """ - importPackage(java.io) - importPackage(javax.imageio) - importPackage(java.awt.image) - const screenShot = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB); - component.paint(screenShot.getGraphics()) - let pictureBytes; - const baos = new ByteArrayOutputStream(); - try { - ImageIO.write(screenShot, "png", baos); - pictureBytes = baos.toByteArray(); - } finally { - baos.close(); - } - pictureBytes; - """, true - ) - } catch (e: Throwable) { - e.printStackTrace() - throw e - } - pic.inputStream().use { - ImageIO.read(it) - }.save(testName + "_" + n) - } - } - - private fun fetchScreenShot(): BufferedImage { - return remoteRobot.callJs( - """ - importPackage(java.io) - importPackage(javax.imageio) - const screenShot = new java.awt.Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); - let pictureBytes; - const baos = new ByteArrayOutputStream(); - try { - ImageIO.write(screenShot, "png", baos); - pictureBytes = baos.toByteArray(); - } finally { - baos.close(); - } - pictureBytes; - """ - ).inputStream().use { - ImageIO.read(it) - } - } -} \ No newline at end of file diff --git a/utbot-intellij-main/src/test/kotlin/org/utbot/utils/StepsLogger.kt b/utbot-intellij-main/src/test/kotlin/org/utbot/utils/StepsLogger.kt deleted file mode 100644 index a97ddfb70b..0000000000 --- a/utbot-intellij-main/src/test/kotlin/org/utbot/utils/StepsLogger.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.utbot.utils - -import com.intellij.remoterobot.stepsProcessing.StepLogger -import com.intellij.remoterobot.stepsProcessing.StepWorker - -object StepsLogger { - private var initialized = false - @JvmStatic - fun init() { - if (initialized.not()) { - StepWorker.registerProcessor(StepLogger()) - initialized = true - } - } -} \ No newline at end of file diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index b4a9870f27..6763a526a0 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -45,18 +45,49 @@ intellij { androidStudioPath?.let { jvmPlugins += androidPlugins } + val pythonCommunityPlugins = listOf( + "PythonCore:${pythonCommunityPluginVersion}" + ) + + val pythonUltimatePlugins = listOf( + "Pythonid:${pythonUltimatePluginVersion}" + ) + + val jsPlugins = listOf( + "JavaScript" + ) + + val goPlugins = listOf( + "org.jetbrains.plugins.go:${goPluginVersion}" + ) + val mavenUtilsPlugins = listOf( "org.jetbrains.idea.maven" ) val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins - plugins.set(basePluginSet) + plugins.set( + when (projectType) { + communityEdition -> basePluginSet + pythonCommunityPlugins + ultimateEdition -> when (ideType) { + "IC" -> basePluginSet + pythonCommunityPlugins + "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins + jsPlugins + "GO" -> goPlugins + else -> basePluginSet + } + else -> basePluginSet + } + ) version.set(ideVersion) type.set(ideTypeOrAndroidStudio) } +val remoteRobotVersion = "0.11.16" + tasks { compileKotlin { kotlinOptions { @@ -82,6 +113,31 @@ tasks { untilBuild.set("232.*") version.set(semVer) } + + runIdeForUiTests { + jvmArgs("-Xmx2048m", "-Didea.is.internal=true", "-Didea.ui.debug.mode=true") + + systemProperty("robot-server.port", "8082") // default port 8580 + systemProperty("ide.mac.message.dialogs.as.sheets", "false") + systemProperty("jb.privacy.policy.text", "") + systemProperty("jb.consents.confirmation.enabled", "false") + systemProperty("idea.trust.all.projects", "true") + systemProperty("ide.mac.file.chooser.native", "false") + systemProperty("jbScreenMenuBar.enabled", "false") + systemProperty("apple.laf.useScreenMenuBar", "false") + systemProperty("ide.show.tips.on.startup.default.value", "false") + } + + downloadRobotServerPlugin { + version.set(remoteRobotVersion) + } + + test { + description = "Runs UI integration tests." + useJUnitPlatform { + exclude("/org/utbot/**") //Comment this line to run the tests locally + } + } } dependencies { @@ -103,6 +159,17 @@ dependencies { implementation(project(":utbot-ui-commons")) implementation(project(":utbot-android-studio")) + testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion") + testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion") + + testImplementation("org.assertj:assertj-core:3.11.1") + + // Logging Network Calls + testImplementation("com.squareup.okhttp3:logging-interceptor:4.10.0") + + // Video Recording + implementation("com.automation-remarks:video-recorder-junit5:2.0") + testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version") testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junit4PlatformVersion") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit5Version") From 078b9ab0a265b93096849f9891c406cfc150f883 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 13 Oct 2023 10:38:43 +0300 Subject: [PATCH 33/43] Move tests --- utbot-intellij/src/test/java/Bar.java | 3 + utbot-intellij/src/test/java/Foo.java | 20 ++ .../kotlin/org/utbot/data/IdeaBuildSystem.kt | 9 + .../test/kotlin/org/utbot/data/JDKVersion.kt | 10 + .../src/test/kotlin/org/utbot/data/RunInfo.kt | 11 ++ .../kotlin/org/utbot/dialogs/DialogFixture.kt | 36 ++++ .../utbot/dialogs/NewProjectDialogFixture.kt | 104 +++++++++++ .../utbot/dialogs/OpenProjectDialogFixture.kt | 21 +++ .../utbot/dialogs/UnitTestBotDialogFixture.kt | 32 ++++ .../org/utbot/dialogs/WarningDialogFixture.kt | 24 +++ .../org/utbot/elements/ActionMenuFixture.kt | 30 +++ .../org/utbot/elements/NotificationFixture.kt | 28 +++ .../test/kotlin/org/utbot/pages/IdeaFrame.kt | 173 ++++++++++++++++++ .../kotlin/org/utbot/pages/IdeaGradleFrame.kt | 50 +++++ .../kotlin/org/utbot/pages/IdeaMavenFrame.kt | 22 +++ .../kotlin/org/utbot/pages/WelcomeFrame.kt | 60 ++++++ .../kotlin/org/utbot/samples/CodeSamples.kt | 40 ++++ .../test/kotlin/org/utbot/steps/IDESteps.kt | 52 ++++++ .../test/kotlin/org/utbot/tests/BaseTest.kt | 93 ++++++++++ .../kotlin/org/utbot/tests/CreateProjects.kt | 41 +++++ .../org/utbot/tests/UnitTestBotActionTest.kt | 76 ++++++++ .../org/utbot/utils/RemoteRobotExtension.kt | 135 ++++++++++++++ .../kotlin/org/utbot/utils/StepsLogger.kt | 15 ++ 23 files changed, 1085 insertions(+) create mode 100644 utbot-intellij/src/test/java/Bar.java create mode 100644 utbot-intellij/src/test/java/Foo.java create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/data/JDKVersion.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/data/RunInfo.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/elements/NotificationFixture.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/steps/IDESteps.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/tests/BaseTest.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt create mode 100644 utbot-intellij/src/test/kotlin/org/utbot/utils/StepsLogger.kt diff --git a/utbot-intellij/src/test/java/Bar.java b/utbot-intellij/src/test/java/Bar.java new file mode 100644 index 0000000000..e4d7ed9b9f --- /dev/null +++ b/utbot-intellij/src/test/java/Bar.java @@ -0,0 +1,3 @@ +public class Bar { + public int c; +} diff --git a/utbot-intellij/src/test/java/Foo.java b/utbot-intellij/src/test/java/Foo.java new file mode 100644 index 0000000000..5dd9ce9112 --- /dev/null +++ b/utbot-intellij/src/test/java/Foo.java @@ -0,0 +1,20 @@ +public class Foo { + public int a; + public int b; + public Bar c; + + public Foo() { + } + + public int getA() { + return a; + } + + public int getB() { + return b; + } + + public Bar getC() { + return c; + } +} diff --git a/utbot-intellij/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt b/utbot-intellij/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt new file mode 100644 index 0000000000..0e602fbff7 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/data/IdeaBuildSystem.kt @@ -0,0 +1,9 @@ +package org.utbot.data + +enum class IdeaBuildSystem (val system: String) { + + INTELLIJ("IntelliJ"), + GRADLE("Gradle"), + MAVEN("Maven") + +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/data/JDKVersion.kt b/utbot-intellij/src/test/kotlin/org/utbot/data/JDKVersion.kt new file mode 100644 index 0000000000..ea4b872573 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/data/JDKVersion.kt @@ -0,0 +1,10 @@ +package org.utbot.data + +enum class JDKVersion (val namePart: String, val number: Int, val supported: Boolean) { + + JDK_1_8(namePart = "1.8", 8, true), + JDK_11(namePart = "11", 11, true), + JDK_17(namePart = "17", 17, true), + JDK_19(namePart = "19", 19, false); + override fun toString() = namePart +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/data/RunInfo.kt b/utbot-intellij/src/test/kotlin/org/utbot/data/RunInfo.kt new file mode 100644 index 0000000000..f91630c119 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/data/RunInfo.kt @@ -0,0 +1,11 @@ +package org.utbot.data + +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter +import java.util.Random + +val TEST_RUN_NUMBER = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) +val DEFAULT_TEST_GENERATION_TIMEOUT = 60L +val NEW_PROJECT_NAME_START = "Aut_${TEST_RUN_NUMBER}_" +val DEFAULT_PROJECT_DIRECTORY = "~\\IdeaProjects" +var random: Random = Random() diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt new file mode 100644 index 0000000000..ca643c84cc --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt @@ -0,0 +1,36 @@ +package org.utbot.dialogs + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.CommonContainerFixture +import com.intellij.remoterobot.fixtures.ContainerFixture +import com.intellij.remoterobot.fixtures.FixtureName +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.stepsProcessing.step +import java.time.Duration + +fun ContainerFixture.dialog( + title: String, + timeout: Duration = Duration.ofSeconds(20), + function: DialogFixture.() -> Unit = {}): DialogFixture = step("Search for dialog with title $title") { + find(DialogFixture.byTitle(title), timeout).apply(function) +} + +@FixtureName("Dialog") +open class DialogFixture( + remoteRobot: RemoteRobot, + remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { + + companion object { + @JvmStatic + fun byTitle(title: String) = byXpath("title $title", "//div[@title='$title' and @class='MyDialog']") + } + + val title: String + get() = callJs("component.getTitle();") + + val closeButton + get() = button( + byXpath("//div[@class='DialogRootPane']//div[@class='JButton']")) + +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt new file mode 100644 index 0000000000..1ddc6660cc --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/NewProjectDialogFixture.kt @@ -0,0 +1,104 @@ +package org.utbot.dialogs + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.* +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.stepsProcessing.step +import com.intellij.remoterobot.utils.Keyboard +import com.intellij.remoterobot.utils.keyboard +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.utbot.data.DEFAULT_PROJECT_DIRECTORY +import org.utbot.data.IdeaBuildSystem +import org.utbot.data.JDKVersion +import java.awt.event.KeyEvent +import java.time.Duration +import java.time.Duration.ofSeconds + +@FixtureName("NewProjectDialog") +@DefaultXpath("type", "//*[contains(@title.key, 'title.new.project')]") +class NewProjectDialogFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) + : DialogFixture(remoteRobot, remoteComponent) { + val keyboard: Keyboard = Keyboard(remoteRobot) + + val wizardsList + get() = jList( + byXpath("//div[@class='JBList']")) + + val nameInput + get() = textField( + byXpath("//div[@class='JBTextField']")) + + val locationInput + get() = textField( + byXpath("//div[@class='ExtendableTextField']")) + + val addSampleCodeCheckbox + get() = checkBox( + byXpath("//div[@text.key='label.project.wizard.new.project.add.sample.code']")) + + val jdkComboBox + get() = comboBox( + byXpath("//div[@class='JdkComboBox']"), + Duration.ofSeconds(10)) + + val jdkList + get() = heavyWeightWindow().itemsList + + val createButton + get() = button( + byXpath("//div[@text.key='button.create']")) + + val cancelButton + get() = button( + byXpath("//div[@text.key='button.cancel']")) + + fun selectWizard(wizardName: String) { + if (title != wizardName) { + wizardsList.findText(wizardName).click() + } + } + + fun selectJDK(jdkVersion: String) { + step("Select JDK: $jdkVersion") { + jdkComboBox.click() + var jdkMatching = jdkVersion + waitForIgnoringError(ofSeconds(20)) { + findAll(byXpath("//*[@text.key='progress.title.detecting.sdks']")).isEmpty() + jdkMatching = jdkList.collectItems().first { it.contains(jdkVersion) } + jdkMatching.isEmpty().not() + } + jdkList.clickItem(jdkMatching) + } + } + + fun fillDialog(projectName: String, + location: String = "", + language: String = "Java", + buildSystem: IdeaBuildSystem = IdeaBuildSystem.INTELLIJ, + jdkVersion: JDKVersion, + addSampleCode: Boolean = true) { + step("Fill New Project dialog") { + nameInput.doubleClick() + keyboard.hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_A) + keyboard.enterText(projectName) + var input = DEFAULT_PROJECT_DIRECTORY + if (location != "") { + input = location + } + if (locationInput.hasText(input).not()) { + locationInput.click() + keyboard{ + hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_A) + enterText(input.replace("\\", "\\\\")) + } + } + this.findText(language).click() + this.findText(buildSystem.system).click() + addSampleCodeCheckbox.setValue(addSampleCode) + if (!jdkComboBox.selectedText().contains(jdkVersion.namePart)) { + selectJDK(jdkVersion.namePart) + } + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt new file mode 100644 index 0000000000..ec2cf4939e --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/OpenProjectDialogFixture.kt @@ -0,0 +1,21 @@ +package org.utbot.dialogs + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.* +import com.intellij.remoterobot.search.locators.byXpath + +@FixtureName("OpenProjectDialog") +@DefaultXpath("Dialog type", "//*[@title.key='title.open.file.or.project']") +class OpenProjectDialogFixture( + remoteRobot: RemoteRobot, + remoteComponent: RemoteComponent) : DialogFixture(remoteRobot, remoteComponent) { + + val pathInput + get() = textField( + byXpath("//div[@class='BorderlessTextField']")) + + val okButton + get() = button( + byXpath("//div[@text.key='button.ok']")) +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt new file mode 100644 index 0000000000..0a411ea440 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/UnitTestBotDialogFixture.kt @@ -0,0 +1,32 @@ +package org.utbot.dialogs + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.* +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.utils.Keyboard + +@FixtureName("UnitTestBotDialog") +@DefaultXpath("Dialog type", "//*[contains(@title, 'UnitTestBot')]") +class UnitTestBotDialogFixture( + remoteRobot: RemoteRobot, + remoteComponent: RemoteComponent) : DialogFixture(remoteRobot, remoteComponent) { + val keyboard: Keyboard = Keyboard(remoteRobot) + + val sdkNotificationLabel + get() = jLabel( + byXpath("//div[@class='SdkNotificationPanel']//div[@defaulticon='fatalError.svg']")) + + val setupSdkLink + get() = actionLink( + byXpath("//div[@class='SdkNotificationPanel']//div[@class='HyperlinkLabel']")) + + val testSourcesRootComboBox + get() = comboBox( + byXpath("//div[@class='TestFolderComboWithBrowseButton']/div[1]")) + + val generateTestsButton + get() = button( + byXpath("//div[@class='MainButton']")) + +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt new file mode 100644 index 0000000000..f5e4a1e651 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/WarningDialogFixture.kt @@ -0,0 +1,24 @@ +package org.utbot.dialogs + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.* +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.utils.Keyboard + +@FixtureName("MyDialog") +@DefaultXpath("type", "//div[@class='DialogRootPane']") +class WarningDialogFixture( + remoteRobot: RemoteRobot, + remoteComponent: RemoteComponent) : DialogFixture(remoteRobot, remoteComponent) { + val keyboard: Keyboard = Keyboard(remoteRobot) + + val terminateButton + get() = button( + byXpath("//div[@text.key='button.terminate']")) + + val cancelButton + get() = button( + byXpath("//div[@text.key='button.cancel']")) + +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt new file mode 100644 index 0000000000..6ec17bc84c --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/elements/ActionMenuFixture.kt @@ -0,0 +1,30 @@ +package org.utbot.pages + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.ComponentFixture +import com.intellij.remoterobot.fixtures.FixtureName +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.utils.waitFor + +fun RemoteRobot.actionMenu(text: String): ActionMenuFixture { + val xpath = byXpath("text '$text'", "//div[@class='ActionMenu' and @text='$text']") + waitFor { + findAll(xpath).isNotEmpty() + } + return findAll(xpath).first() +} + +fun RemoteRobot.actionMenuItem(text: String): ActionMenuItemFixture { + val xpath = byXpath("text '$text'", "//div[@class='ActionMenuItem' and @text='$text']") + waitFor { + findAll(xpath).isNotEmpty() + } + return findAll(xpath).first() +} + +@FixtureName("ActionMenu") +class ActionMenuFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : ComponentFixture(remoteRobot, remoteComponent) + +@FixtureName("ActionMenuItem") +class ActionMenuItemFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : ComponentFixture(remoteRobot, remoteComponent) diff --git a/utbot-intellij/src/test/kotlin/org/utbot/elements/NotificationFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/elements/NotificationFixture.kt new file mode 100644 index 0000000000..5683f12db5 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/elements/NotificationFixture.kt @@ -0,0 +1,28 @@ +package org.utbot.elements + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.CommonContainerFixture +import com.intellij.remoterobot.fixtures.ComponentFixture +import com.intellij.remoterobot.fixtures.DefaultXpath +import com.intellij.remoterobot.fixtures.FixtureName +import com.intellij.remoterobot.search.locators.byXpath +import java.time.Duration.ofSeconds + +@FixtureName("Notification Center Panel") +@DefaultXpath("NotificationCenterPanel type", "//div[@class='NotificationCenterPanel']") +class NotificationFixture(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { + + val title + get() = jLabel(byXpath("//div[@class='JLabel']"), + ofSeconds(5)) + + val body + get() = remoteRobot.find(byXpath("//div[@class='JEditorPane']"), + ofSeconds(5)) + + val link + get() = remoteRobot.find(byXpath("//div[@class='LinkLabel']"), + ofSeconds(5)) +} + diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt new file mode 100644 index 0000000000..317cd626a6 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt @@ -0,0 +1,173 @@ +package org.utbot.pages + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.* +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.stepsProcessing.step +import com.intellij.remoterobot.utils.keyboard +import com.intellij.remoterobot.utils.waitFor +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.assertj.swing.core.MouseButton +import org.utbot.data.IdeaBuildSystem +import org.utbot.dialogs.UnitTestBotDialogFixture +import org.utbot.dialogs.WarningDialogFixture +import org.utbot.elements.NotificationFixture +import java.awt.event.KeyEvent +import java.time.Duration +import java.time.Duration.ofSeconds + +fun RemoteRobot.idea(function: IdeaFrame.() -> Unit) { + find(timeout = ofSeconds(5)).apply(function) +} + +@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']") +open class IdeaFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { + + open val buildSystemToUse: IdeaBuildSystem = IdeaBuildSystem.INTELLIJ + + val projectViewTree + get() = find(byXpath("ProjectViewTree", "//div[@class='ProjectViewTree']"), + ofSeconds(10)) + + val projectName + get() = step("Get project name") { return@step callJs("component.getProject().getName()") } + + val menuBar: JMenuBarFixture + get() = step("Menu...") { + return@step remoteRobot.find(JMenuBarFixture::class.java, JMenuBarFixture.byType()) + } + + val inlineProgressTextPanel + get() = remoteRobot.find(byXpath("//div[@class='InlineProgressPanel']//div[@class='TextPanel']"), + ofSeconds(10)) + + val statusTextPanel + get() = remoteRobot.find(byXpath("//div[@class='StatusPanel']//div[@class='TextPanel']"), + ofSeconds(10)) + + val buildResultInEditor + get() = remoteRobot.find(byXpath("//div[@class='TrafficLightButton']"), + ofSeconds(20)) + + val buildResult + get() = textField(byXpath("//div[contains(@accessiblename.key, 'editor.accessible.name')]"), + ofSeconds(20)) + + val ideError + get() = remoteRobot.find(byXpath( "//div[@class='NotificationCenterPanel'][.//div[@accessiblename.key='error.new.notification.title']]"), + ofSeconds(10)) + + val utbotNotification + get() = remoteRobot.find(byXpath( "//div[@class='NotificationCenterPanel'][div[contains(.,'UnitTestBot')]]"), + ofSeconds(10)) + + val unitTestBotDialog + get() = remoteRobot.find(UnitTestBotDialogFixture::class.java, + ofSeconds(10)) + + @JvmOverloads + fun dumbAware(timeout: Duration = Duration.ofMinutes(5), function: () -> Unit) { + step("Wait for smart mode") { + waitFor(duration = timeout, interval = ofSeconds(5)) { + runCatching { isDumbMode().not() }.getOrDefault(false) + } + function() + step("..wait for smart mode again") { + waitFor(duration = timeout, interval = ofSeconds(5)) { + isDumbMode().not() + } + } + } + } + + fun isDumbMode(): Boolean { + return callJs(""" + const frameHelper = com.intellij.openapi.wm.impl.ProjectFrameHelper.getFrameHelper(component) + if (frameHelper) { + const project = frameHelper.getProject() + project ? com.intellij.openapi.project.DumbService.isDumb(project) : true + } else { + true + } + """, true) + } + + fun closeProject() { + if (remoteRobot.isMac()) { + keyboard { + hotKey(KeyEvent.VK_SHIFT, KeyEvent.VK_META, KeyEvent.VK_A) + enterText("Close Project") + enter() + } + } else { + menuBar.select("File", "Close Project") + } + try { + remoteRobot.find(WarningDialogFixture::class.java, ofSeconds(1)) + .terminateButton.click() + } catch (ignore: Throwable) {} + } + + fun openUTBotDialogFromProjectViewForClass(classname: String) { + step("Call UnitTestBot action") { + waitFor(ofSeconds(200)) { !isDumbMode() } + with(projectViewTree) { + findText(classname).click(MouseButton.RIGHT_BUTTON) + } + remoteRobot.actionMenuItem("Generate Tests with UnitTestBot...").click() + } + } + + open fun waitProjectIsOpened() { + waitForIgnoringError(ofSeconds(30)) { + projectViewTree.hasText(projectName) + } + } + + open fun waitProjectIsCreated() { + waitProjectIsOpened() + } + + open fun expandProjectTree(projectName: String) { + with(projectViewTree) { + if (hasText("src").not()) { + findText(projectName).doubleClick() + waitForIgnoringError{ + hasText("src").and(hasText(".idea")) + } + } + } + } + + open fun createNewPackage(packageName: String) { + with(projectViewTree) { + if (hasText("src").not()) { + findText(projectName).doubleClick() + waitFor { hasText("src") } + } + findText("src").click(MouseButton.RIGHT_BUTTON) + } + remoteRobot.actionMenu("New").click() + remoteRobot.actionMenuItem("Package").click() + keyboard { + enterText(packageName) + enter() + } + } + + fun createNewJavaClass(newClassname: String = "Example", + textToClickOn: String = "Main") { + waitProjectIsOpened() + expandProjectTree(projectName) + with(projectViewTree) { + findText(textToClickOn).click(MouseButton.RIGHT_BUTTON) + } + remoteRobot.actionMenu("New").click() + remoteRobot.actionMenuItem("Java Class").click() + remoteRobot.keyboard { + enterText(newClassname) + enter() + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt new file mode 100644 index 0000000000..52d0fad081 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt @@ -0,0 +1,50 @@ +package org.utbot.pages + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.DefaultXpath +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.utbot.data.IdeaBuildSystem +import java.time.Duration.ofSeconds + +@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']") +class IdeaGradleFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : IdeaFrame(remoteRobot, remoteComponent) { + + override val buildSystemToUse = IdeaBuildSystem.GRADLE + + override fun waitProjectIsCreated() { + super.waitProjectIsOpened() + repeat (120) { + inlineProgressTextPanel.isShowing.not() + } + } + + override fun expandProjectTree(projectName: String) { + with(projectViewTree) { + waitForIgnoringError(ofSeconds(10)) { + hasText("src") + } + if (hasText("src").not()) { + findText(projectName).doubleClick() + waitForIgnoringError{ + hasText("src") + } + } + if (hasText("main").not()) { + findText("src").doubleClick() + waitForIgnoringError{ + hasText("src").and(hasText("main")) + } + } + if (hasText("java").not()) { + findText("main").doubleClick() + waitForIgnoringError{ + hasText("src").and(hasText("main")).and(hasText("java")) + } + } + if (hasText("Main").not()) { + findText("java").doubleClick() + } + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt new file mode 100644 index 0000000000..f3fbe39805 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaMavenFrame.kt @@ -0,0 +1,22 @@ +package org.utbot.pages + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.DefaultXpath +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.utbot.data.IdeaBuildSystem +import java.time.Duration.ofSeconds + +@DefaultXpath("IdeFrameImpl type", "//div[@class='IdeFrameImpl']") +class IdeaMavenFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : IdeaFrame(remoteRobot, remoteComponent) { + + override val buildSystemToUse = IdeaBuildSystem.MAVEN + + override fun waitProjectIsOpened() { + super.waitProjectIsOpened() + waitForIgnoringError (ofSeconds(60)) { + projectViewTree.hasText("Main.java").not() + projectViewTree.hasText("Main") + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt b/utbot-intellij/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt new file mode 100644 index 0000000000..16eab0011f --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/pages/WelcomeFrame.kt @@ -0,0 +1,60 @@ +package org.utbot.pages + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.data.RemoteComponent +import com.intellij.remoterobot.fixtures.* +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.utils.Keyboard +import org.utbot.data.IdeaBuildSystem +import org.utbot.data.JDKVersion +import org.utbot.dialogs.NewProjectDialogFixture +import org.utbot.dialogs.OpenProjectDialogFixture +import java.time.Duration + +fun RemoteRobot.welcomeFrame(function: WelcomeFrame.()-> Unit) { + find(WelcomeFrame::class.java, Duration.ofSeconds(10)).apply(function) +} + +@FixtureName("Welcome Frame") +@DefaultXpath("Welcome Frame type", "//div[@class='FlatWelcomeFrame']") +class WelcomeFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) : CommonContainerFixture(remoteRobot, remoteComponent) { + val keyboard: Keyboard = Keyboard(remoteRobot) + val ideaVersion //ToDO good locator + get() = jLabel(byXpath("//div[@class='TabbedWelcomeScreen']//div[@class='JLabel' and contains(@text,'20')]")) + + val newProjectLink + get() = actionLink(byXpath("New Project","//div[(@class='MainButton' and @text='New Project') or (@accessiblename='New Project' and @class='JButton')]")) + val openProjectLink + get() = actionLink(byXpath("Open","//div[(@class='MainButton' and @text='Open') or (@accessiblename.key='action.WelcomeScreen.OpenProject.text')]")) + val moreActions + get() = button(byXpath("More Action", "//div[@accessiblename='More Actions']")) + + val recentProjectLinks + get() = jTree(byXpath("//div[@class='CardLayoutPanel']//div[@class='Tree']")) + + val openProjectDialog + get() = remoteRobot.find(OpenProjectDialogFixture::class.java) + + val newProjectDialog + get() = remoteRobot.find(NewProjectDialogFixture::class.java) + + fun openProjectByPath(projectName: String, + location: String = "") { + val localPath = location + projectName + openProjectLink.click() + keyboard.enterText(localPath) + openProjectDialog.okButton.click() + } + + fun createNewProject(projectName: String, location: String = "", + language: String = "Java", buildSystem: IdeaBuildSystem = IdeaBuildSystem.INTELLIJ, + jdkVersion: JDKVersion, addSampleCode: Boolean = true) { + newProjectLink.click() + newProjectDialog.selectWizard("New Project") + newProjectDialog.fillDialog( + projectName, location, language, + buildSystem, jdkVersion, addSampleCode + ) + newProjectDialog.createButton.click() + } +} diff --git a/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt b/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt new file mode 100644 index 0000000000..0464782fe3 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt @@ -0,0 +1,40 @@ +package org.utbot.samples + +import com.intellij.remoterobot.fixtures.TextEditorFixture +import com.intellij.remoterobot.utils.keyboard +import org.utbot.data.TEST_RUN_NUMBER +import java.awt.event.KeyEvent + +fun TextEditorFixture.typeAdditionFunction(className: String): String { + editor.selectText(className) + keyboard { + key(KeyEvent.VK_END) + enter() + enterText("public int addition(") + enterText("int a, int b") + key(KeyEvent.VK_END) + enterText("{") + enter() + enterText("// Test run ${TEST_RUN_NUMBER}") + enter() + enterText("return a + b;") + } + return "@utbot.returnsFrom {@code return a + b;}" +} + +fun TextEditorFixture.typeDivisionFunction(className: String) : String { + editor.selectText(className) + keyboard { + key(KeyEvent.VK_END) + enter() + enterText("public int division(") + enterText("int a, int b") + key(KeyEvent.VK_END) + enterText("{") + enter() + enterText("// Test run ${TEST_RUN_NUMBER}") + enter() + enterText("return a / b;") + } + return "@utbot.returnsFrom {@code return a / b;}" +} diff --git a/utbot-intellij/src/test/kotlin/org/utbot/steps/IDESteps.kt b/utbot-intellij/src/test/kotlin/org/utbot/steps/IDESteps.kt new file mode 100644 index 0000000000..c6dc22c7b3 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/steps/IDESteps.kt @@ -0,0 +1,52 @@ +package org.utbot.steps + +import com.intellij.remoterobot.fixtures.TextEditorFixture +import com.intellij.remoterobot.fixtures.dataExtractor.contains +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.stepsProcessing.step +import com.intellij.remoterobot.utils.keyboard +import com.intellij.remoterobot.utils.waitFor +import org.utbot.dialogs.DialogFixture +import org.utbot.dialogs.DialogFixture.Companion.byTitle +import org.utbot.pages.IdeaFrame +import java.awt.event.KeyEvent +import java.time.Duration.ofSeconds + +fun IdeaFrame.autocomplete(text: String) { + step("Autocomplete '" + text + "'") { + keyboard { + enterText(text) + } + heavyWeightWindow(ofSeconds(5)) + .findText(contains(text)) + .click() + keyboard { + enter() + } + } +} + +fun TextEditorFixture.goToLineAndColumn(row: Int, column: Int) { + keyboard { + if (remoteRobot.isMac()) { + hotKey(KeyEvent.VK_META, KeyEvent.VK_L) + } else { + hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_G) + } + enterText("$row:$column") + enter() + } +} + +fun IdeaFrame.closeTipOfTheDay() { + step("Close Tip of the Day if it appears") { + waitFor(ofSeconds(20)) { + remoteRobot.findAll(byXpath("//div[@class='MyDialog'][.//div[@text='Running startup activities...']]")) + .isEmpty() + } + try { + find(byTitle ("Tip of the Day")) + .button("Close").click() + } catch (ignore: Throwable) {} + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/BaseTest.kt b/utbot-intellij/src/test/kotlin/org/utbot/tests/BaseTest.kt new file mode 100644 index 0000000000..2978faa03d --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/tests/BaseTest.kt @@ -0,0 +1,93 @@ +package org.utbot.tests + +import com.intellij.remoterobot.RemoteRobot +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.params.provider.Arguments +import org.utbot.data.IdeaBuildSystem +import org.utbot.data.JDKVersion +import org.utbot.pages.IdeaFrame +import org.utbot.pages.IdeaGradleFrame +import org.utbot.pages.IdeaMavenFrame +import org.utbot.pages.idea +import org.utbot.utils.RemoteRobotExtension +import org.utbot.utils.StepsLogger +import java.time.Duration.ofSeconds + +@ExtendWith(RemoteRobotExtension::class) +open class BaseTest { + fun getIdeaFrameForBuildSystem(remoteRobot: RemoteRobot, ideaBuildSystem: IdeaBuildSystem): IdeaFrame { + when (ideaBuildSystem) { + IdeaBuildSystem.INTELLIJ -> return remoteRobot.find(IdeaFrame::class.java, ofSeconds(10)) + IdeaBuildSystem.GRADLE -> return remoteRobot.find(IdeaGradleFrame::class.java, ofSeconds(10)) + IdeaBuildSystem.MAVEN -> return remoteRobot.find(IdeaMavenFrame::class.java, ofSeconds(10)) + } + } + + @BeforeEach + fun `Close each project before test`(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { + try { + idea { + closeProject() + } + } catch (ignore: Throwable) {} + } + + @AfterEach + fun `Close each project after test`(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { + idea { + closeProject() + } + } + + companion object { + @BeforeAll + @JvmStatic + fun init(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { + StepsLogger.init() + } + + private val supportedProjectsList: List = + addPairsToList(true) + private val unsupportedProjectsList: List = + addPairsToList(false) + + @JvmStatic + fun supportedProjectsProvider(): List { + return supportedProjectsList + } + + @JvmStatic + fun unsupportedProjectsProvider(): List { + return unsupportedProjectsList + } + + @JvmStatic + fun allProjectsProvider(): List { + return supportedProjectsList + unsupportedProjectsList + } + + @JvmStatic + private fun addPairsToList(supported: Boolean): List { + val ideaBuildSystems = IdeaBuildSystem.values() + ideaBuildSystems.shuffle() + var j = 0 + + val listOfArguments: MutableList = mutableListOf() + JDKVersion.values().toMutableList().filter { + it.supported == supported + }.forEach { + listOfArguments.add( + Arguments.of(ideaBuildSystems[j], it) //each (un)supported JDK with a random build system + ) + j++ + if (j >= ideaBuildSystems.size) { + j = 0 + } + } + return listOfArguments + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt b/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt new file mode 100644 index 0000000000..eee5299898 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt @@ -0,0 +1,41 @@ +package org.utbot.tests + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.utils.waitFor +import org.junit.jupiter.api.Order +import org.junit.jupiter.api.Tag +import org.junit.jupiter.api.Tags +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.MethodSource +import org.utbot.data.IdeaBuildSystem +import org.utbot.data.JDKVersion +import org.utbot.data.NEW_PROJECT_NAME_START +import org.utbot.pages.welcomeFrame +import java.time.Duration + +@Order(1) +class CreateProjects : BaseTest() { + @ParameterizedTest(name = "Create {0} project with JDK {1}") + @Tags(Tag("smoke"), Tag("NewProject"), Tag("Java"), Tag("UTBot"), Tag("")) + @MethodSource("allProjectsProvider") + fun createProjectWithSupportedJDK( + ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, + remoteRobot: RemoteRobot + ): Unit = with(remoteRobot) { + val newProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number + remoteRobot.welcomeFrame { + createNewProject( + projectName = newProjectName, + buildSystem = ideaBuildSystem, + jdkVersion = jdkVersion + ) + } + val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) + with(ideaFrame) { + waitProjectIsCreated() + waitFor(Duration.ofSeconds(30)) { + !isDumbMode() + } + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt b/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt new file mode 100644 index 0000000000..e06b403bc8 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt @@ -0,0 +1,76 @@ +package org.utbot.tests + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.* +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.MethodSource +import org.utbot.data.IdeaBuildSystem +import org.utbot.data.JDKVersion +import org.utbot.data.NEW_PROJECT_NAME_START +import org.utbot.pages.* +import org.utbot.samples.typeAdditionFunction +import org.utbot.samples.typeDivisionFunction +import java.time.Duration.ofSeconds + +class UnitTestBotActionTest : BaseTest() { + + @ParameterizedTest(name = "Generate tests in {0} project with JDK {1}") + @MethodSource("supportedProjectsProvider") + @Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Positive")) + fun checkBasicTestGeneration(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, + remoteRobot: RemoteRobot) { + val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number + remoteRobot.welcomeFrame { + findText(createdProjectName).click() + } + val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) + with (ideaFrame) { + val newClassName = "Arithmetic" + createNewJavaClass(newClassName, "Main") + val returnsFromTagBody = textEditor().typeDivisionFunction(newClassName) + openUTBotDialogFromProjectViewForClass(newClassName) + unitTestBotDialog.generateTestsButton.click() + waitForIgnoringError (ofSeconds(5)){ + inlineProgressTextPanel.isShowing + } + waitForIgnoringError (ofSeconds(90)){ + inlineProgressTextPanel.hasText("Generate test cases for class $newClassName") + } + waitForIgnoringError(ofSeconds(30)) { + utbotNotification.title.hasText("UnitTestBot: unit tests generated successfully") + } + assertThat(textEditor().editor.text).contains("class ${newClassName}Test") + assertThat(textEditor().editor.text).contains("@Test\n") + assertThat(textEditor().editor.text).contains("assertEquals(") + assertThat(textEditor().editor.text).contains("@utbot.classUnderTest {@link ${newClassName}}") + assertThat(textEditor().editor.text).contains("@utbot.methodUnderTest {@link ${newClassName}#") + assertThat(textEditor().editor.text).contains(returnsFromTagBody) + //ToDo verify how many tests are generated + //ToDo verify Problems view and Arithmetic exception on it + } + } + + @ParameterizedTest(name = "Check Generate tests button is disabled in {0} project with unsupported JDK {1}") + @MethodSource("unsupportedProjectsProvider") + @Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Negative")) + fun checkProjectWithUnsupportedJDK(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, + remoteRobot: RemoteRobot) { + val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number + remoteRobot.welcomeFrame { + findText(createdProjectName).click() + } + val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) + return with (ideaFrame) { + val newClassName = "Arithmetic" + createNewJavaClass(newClassName, "Main") + textEditor().typeAdditionFunction(newClassName) + openUTBotDialogFromProjectViewForClass(newClassName) + assertThat(unitTestBotDialog.generateTestsButton.isEnabled().not()) + assertThat(unitTestBotDialog.sdkNotificationLabel.hasText("SDK version 19 is not supported, use 1.8, 11 or 17 instead.")) + assertThat(unitTestBotDialog.setupSdkLink.isShowing) + unitTestBotDialog.closeButton.click() + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt b/utbot-intellij/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt new file mode 100644 index 0000000000..650542c1f2 --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/utils/RemoteRobotExtension.kt @@ -0,0 +1,135 @@ +package org.utbot.utils + +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.fixtures.ContainerFixture +import com.intellij.remoterobot.search.locators.byXpath +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.logging.HttpLoggingInterceptor +import org.junit.jupiter.api.extension.AfterTestExecutionCallback +import org.junit.jupiter.api.extension.ExtensionContext +import org.junit.jupiter.api.extension.ParameterContext +import org.junit.jupiter.api.extension.ParameterResolver +import java.awt.image.BufferedImage +import java.io.ByteArrayOutputStream +import java.io.File +import java.lang.IllegalStateException +import java.lang.reflect.Method +import javax.imageio.ImageIO + +class RemoteRobotExtension : AfterTestExecutionCallback, ParameterResolver { + private val url: String = System.getProperty("remote-robot-url") ?: "http://127.0.0.1:8082" + private val remoteRobot: RemoteRobot = if (System.getProperty("debug-retrofit")?.equals("enable") == true) { + val interceptor: HttpLoggingInterceptor = HttpLoggingInterceptor().apply { + this.level = HttpLoggingInterceptor.Level.BODY + } + val client = OkHttpClient.Builder().apply { + this.addInterceptor(interceptor) + }.build() + RemoteRobot(url, client) + } else { + RemoteRobot(url) + } + private val client = OkHttpClient() + + override fun supportsParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Boolean { + return parameterContext?.parameter?.type?.equals(RemoteRobot::class.java) ?: false + } + + override fun resolveParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Any { + return remoteRobot + } + + override fun afterTestExecution(context: ExtensionContext?) { + val testMethod: Method = context?.requiredTestMethod ?: throw IllegalStateException("test method is null") + val testMethodName = testMethod.name + val testFailed: Boolean = context.executionException?.isPresent ?: false + if (testFailed) { + saveScreenshot(testMethodName) + saveIdeaFrames(testMethodName) + saveHierarchy(testMethodName) + } + } + + private fun saveScreenshot(testName: String) { + fetchScreenShot().save(testName) + } + + private fun saveHierarchy(testName: String) { + val hierarchySnapshot = + saveFile(url, "build/reports", "hierarchy-$testName.html") + if (File("build/reports/styles.css").exists().not()) { + saveFile("$url/styles.css", "build/reports", "styles.css") + } + println("Hierarchy snapshot: ${hierarchySnapshot.absolutePath}") + } + + private fun saveFile(url: String, folder: String, name: String): File { + val response = client.newCall(Request.Builder().url(url).build()).execute() + return File(folder).apply { + mkdirs() + }.resolve(name).apply { + writeText(response.body?.string() ?: "") + } + } + + private fun BufferedImage.save(name: String) { + val bytes = ByteArrayOutputStream().use { b -> + ImageIO.write(this, "png", b) + b.toByteArray() + } + File("build/reports").apply { mkdirs() }.resolve("$name.png").writeBytes(bytes) + } + + private fun saveIdeaFrames(testName: String) { + remoteRobot.findAll(byXpath("//div[@class='IdeFrameImpl']")).forEachIndexed { n, frame -> + val pic = try { + frame.callJs( + """ + importPackage(java.io) + importPackage(javax.imageio) + importPackage(java.awt.image) + const screenShot = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB); + component.paint(screenShot.getGraphics()) + let pictureBytes; + const baos = new ByteArrayOutputStream(); + try { + ImageIO.write(screenShot, "png", baos); + pictureBytes = baos.toByteArray(); + } finally { + baos.close(); + } + pictureBytes; + """, true + ) + } catch (e: Throwable) { + e.printStackTrace() + throw e + } + pic.inputStream().use { + ImageIO.read(it) + }.save(testName + "_" + n) + } + } + + private fun fetchScreenShot(): BufferedImage { + return remoteRobot.callJs( + """ + importPackage(java.io) + importPackage(javax.imageio) + const screenShot = new java.awt.Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); + let pictureBytes; + const baos = new ByteArrayOutputStream(); + try { + ImageIO.write(screenShot, "png", baos); + pictureBytes = baos.toByteArray(); + } finally { + baos.close(); + } + pictureBytes; + """ + ).inputStream().use { + ImageIO.read(it) + } + } +} \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/utils/StepsLogger.kt b/utbot-intellij/src/test/kotlin/org/utbot/utils/StepsLogger.kt new file mode 100644 index 0000000000..a97ddfb70b --- /dev/null +++ b/utbot-intellij/src/test/kotlin/org/utbot/utils/StepsLogger.kt @@ -0,0 +1,15 @@ +package org.utbot.utils + +import com.intellij.remoterobot.stepsProcessing.StepLogger +import com.intellij.remoterobot.stepsProcessing.StepWorker + +object StepsLogger { + private var initialized = false + @JvmStatic + fun init() { + if (initialized.not()) { + StepWorker.registerProcessor(StepLogger()) + initialized = true + } + } +} \ No newline at end of file From 74618e6474db8a8594fe54f8356377828205c43a Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 13 Oct 2023 10:52:41 +0300 Subject: [PATCH 34/43] Move readme.md --- {utbot-intellij-main => utbot-intellij}/readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {utbot-intellij-main => utbot-intellij}/readme.md (100%) diff --git a/utbot-intellij-main/readme.md b/utbot-intellij/readme.md similarity index 100% rename from utbot-intellij-main/readme.md rename to utbot-intellij/readme.md From 3bf4e5a556f7dffc673fd57e78be4cdeedce93b9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 13 Oct 2023 13:43:52 +0300 Subject: [PATCH 35/43] Add titled separators --- .../plugin/settings/SettingsWindow.kt | 270 +++++++++--------- .../plugin/settings/BaseSettingsWindow.kt | 81 +++--- 2 files changed, 177 insertions(+), 174 deletions(-) diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt index 503507faab..4474e95217 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt @@ -44,162 +44,164 @@ class SettingsWindow(val project: Project) { } val panel: JPanel = panel { - row("Generated test language:") { - codegenLanguageCombo = comboBox(DefaultComboBoxModel(CodegenLanguage.values())).gap(RightGap.COLUMNS) - .apply { - component.renderer = CodeGenerationSettingItemRenderer() - ContextHelpLabel.create("You can generate test methods in Java or Kotlin regardless of your source code language.") - }.bindItem( - getter = { settings.providerNameByServiceLoader(CodegenLanguage::class) as CodegenLanguage }, - setter = { - settings.setProviderByLoader( - CodegenLanguage::class, - it as CodeGenerationSettingItem - ) + group("Java Specific Settings") { + row("Generated test language:") { + codegenLanguageCombo = comboBox(DefaultComboBoxModel(CodegenLanguage.values())).gap(RightGap.COLUMNS) + .apply { + component.renderer = CodeGenerationSettingItemRenderer() + ContextHelpLabel.create("You can generate test methods in Java or Kotlin regardless of your source code language.") + }.bindItem( + getter = { settings.providerNameByServiceLoader(CodegenLanguage::class) as CodegenLanguage }, + setter = { + settings.setProviderByLoader( + CodegenLanguage::class, + it as CodeGenerationSettingItem + ) + } + ).component + codegenLanguageCombo.addActionListener { + if (!codegenLanguageCombo.item.isSummarizationCompatible()) { + enableSummarizationGenerationCheckBox.isSelected = false } - ).component - codegenLanguageCombo.addActionListener { - if (!codegenLanguageCombo.item.isSummarizationCompatible()) { - enableSummarizationGenerationCheckBox.isSelected = false } - } - }.bottomGap(BottomGap.MEDIUM) + }.bottomGap(BottomGap.MEDIUM) - row("Overflow detection:") { - createCombo(TreatOverflowAsError::class, TreatOverflowAsError.values()) - } + row("Overflow detection:") { + createCombo(TreatOverflowAsError::class, TreatOverflowAsError.values()) + } - row { - useTaintAnalysisCheckBox = - checkBox("Enable taint analysis") + row { + useTaintAnalysisCheckBox = + checkBox("Enable taint analysis") + .onApply { + settings.state.useTaintAnalysis = useTaintAnalysisCheckBox.isSelected + } + .onReset { + useTaintAnalysisCheckBox.isSelected = settings.state.useTaintAnalysis + } + .onIsModified { + useTaintAnalysisCheckBox.isSelected xor settings.state.useTaintAnalysis + } + .component + contextHelp("Experimental taint analysis support") + } + row { + runInspectionAfterTestGenerationCheckBox = + checkBox("Display detected errors on the Problems tool window") + .onApply { + settings.state.runInspectionAfterTestGeneration = + runInspectionAfterTestGenerationCheckBox.isSelected + } + .onReset { + runInspectionAfterTestGenerationCheckBox.isSelected = + settings.state.runInspectionAfterTestGeneration + } + .onIsModified { + runInspectionAfterTestGenerationCheckBox.isSelected xor settings.state.runInspectionAfterTestGeneration + } + .component + contextHelp("Automatically run code inspection after test generation") + } + row { + enableSummarizationGenerationCheckBox = checkBox("Enable summaries generation") .onApply { - settings.state.useTaintAnalysis = useTaintAnalysisCheckBox.isSelected + settings.state.summariesGenerationType = + if (enableSummarizationGenerationCheckBox.isSelected) SummariesGenerationType.FULL else SummariesGenerationType.NONE } .onReset { - useTaintAnalysisCheckBox.isSelected = settings.state.useTaintAnalysis + enableSummarizationGenerationCheckBox.isSelected = + settings.state.summariesGenerationType != SummariesGenerationType.NONE } .onIsModified { - useTaintAnalysisCheckBox.isSelected xor settings.state.useTaintAnalysis - } + enableSummarizationGenerationCheckBox.isSelected xor (settings.state.summariesGenerationType != SummariesGenerationType.NONE) + }.enabledIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible)) .component - contextHelp("Experimental taint analysis support") - } - row { - runInspectionAfterTestGenerationCheckBox = - checkBox("Display detected errors on the Problems tool window") + } + indent { + row("Javadoc comment style:") { + createCombo(JavaDocCommentStyle::class, JavaDocCommentStyle.values()) + }.enabledIf(enableSummarizationGenerationCheckBox.selected).bottomGap(BottomGap.MEDIUM) + } + + row { + forceMockCheckBox = checkBox("Force mocking static methods") .onApply { - settings.state.runInspectionAfterTestGeneration = - runInspectionAfterTestGenerationCheckBox.isSelected - } - .onReset { - runInspectionAfterTestGenerationCheckBox.isSelected = - settings.state.runInspectionAfterTestGeneration - } - .onIsModified { - runInspectionAfterTestGenerationCheckBox.isSelected xor settings.state.runInspectionAfterTestGeneration + settings.state.forceStaticMocking = + if (forceMockCheckBox.isSelected) ForceStaticMocking.FORCE else ForceStaticMocking.DO_NOT_FORCE } + .onReset { forceMockCheckBox.isSelected = settings.forceStaticMocking == ForceStaticMocking.FORCE } + .onIsModified { forceMockCheckBox.isSelected xor (settings.forceStaticMocking != ForceStaticMocking.DO_NOT_FORCE) } .component - contextHelp("Automatically run code inspection after test generation") - } - row { - enableSummarizationGenerationCheckBox = checkBox("Enable summaries generation") - .onApply { - settings.state.summariesGenerationType = - if (enableSummarizationGenerationCheckBox.isSelected) SummariesGenerationType.FULL else SummariesGenerationType.NONE - } - .onReset { - enableSummarizationGenerationCheckBox.isSelected = - settings.state.summariesGenerationType != SummariesGenerationType.NONE - } - .onIsModified { - enableSummarizationGenerationCheckBox.isSelected xor (settings.state.summariesGenerationType != SummariesGenerationType.NONE) - }.enabledIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible)) - .component - } - indent { - row("Javadoc comment style:") { - createCombo(JavaDocCommentStyle::class, JavaDocCommentStyle.values()) - }.enabledIf(enableSummarizationGenerationCheckBox.selected).bottomGap(BottomGap.MEDIUM) - } - - row { - forceMockCheckBox = checkBox("Force mocking static methods") - .onApply { - settings.state.forceStaticMocking = - if (forceMockCheckBox.isSelected) ForceStaticMocking.FORCE else ForceStaticMocking.DO_NOT_FORCE - } - .onReset { forceMockCheckBox.isSelected = settings.forceStaticMocking == ForceStaticMocking.FORCE } - .onIsModified { forceMockCheckBox.isSelected xor (settings.forceStaticMocking != ForceStaticMocking.DO_NOT_FORCE) } - .component - contextHelp("Overrides other mocking settings") - } - row("Classes to be forcedly mocked:") {} - row { - val updater = Runnable { - UIUtil.setEnabled(excludeTable.component, forceMockCheckBox.isSelected, true) + contextHelp("Overrides other mocking settings") } - cell(excludeTable.component) - .align(Align.FILL) - .onApply { excludeTable.apply() } - .onReset { - excludeTable.reset() - updater.run() + row("Classes to be forcedly mocked:") {} + row { + val updater = Runnable { + UIUtil.setEnabled(excludeTable.component, forceMockCheckBox.isSelected, true) } - .onIsModified { excludeTable.isModified() } + cell(excludeTable.component) + .align(Align.FILL) + .onApply { excludeTable.apply() } + .onReset { + excludeTable.reset() + updater.run() + } + .onIsModified { excludeTable.isModified() } - forceMockCheckBox.addActionListener { updater.run() } - }.bottomGap(BottomGap.MEDIUM) + forceMockCheckBox.addActionListener { updater.run() } + }.bottomGap(BottomGap.MEDIUM) - val fuzzLabel = JBLabel("Fuzzing") - val symLabel = JBLabel("Symbolic execution") - row { - cell(BorderLayoutPanel().apply { - topGap(TopGap.SMALL) - addToLeft(JBLabel("Test generation method:").apply { verticalAlignment = SwingConstants.TOP }) - addToCenter(BorderLayoutPanel().apply { - val granularity = 20 - val slider = object : JSlider() { - val updater = Runnable() { - val fuzzingPercent = 100.0 * (granularity - value) / granularity - fuzzLabel.text = "Fuzzing %.0f %%".format(fuzzingPercent) - symLabel.text = "%.0f %% Symbolic execution".format(100.0 - fuzzingPercent) - } + val fuzzLabel = JBLabel("Fuzzing") + val symLabel = JBLabel("Symbolic execution") + row { + cell(BorderLayoutPanel().apply { + topGap(TopGap.SMALL) + addToLeft(JBLabel("Test generation method:").apply { verticalAlignment = SwingConstants.TOP }) + addToCenter(BorderLayoutPanel().apply { + val granularity = 20 + val slider = object : JSlider() { + val updater = Runnable() { + val fuzzingPercent = 100.0 * (granularity - value) / granularity + fuzzLabel.text = "Fuzzing %.0f %%".format(fuzzingPercent) + symLabel.text = "%.0f %% Symbolic execution".format(100.0 - fuzzingPercent) + } - override fun getValue() = ((1 - settings.fuzzingValue) * granularity).toInt() + override fun getValue() = ((1 - settings.fuzzingValue) * granularity).toInt() - override fun setValue(n: Int) { - val tmp = value - settings.fuzzingValue = 1 - n / granularity.toDouble() - if (tmp != n) { - updater.run() + override fun setValue(n: Int) { + val tmp = value + settings.fuzzingValue = 1 - n / granularity.toDouble() + if (tmp != n) { + updater.run() + } } } - } - UIUtil.setSliderIsFilled(slider, true) - slider.minimum = 0 - slider.maximum = granularity - slider.minorTickSpacing = 1 - slider.majorTickSpacing = granularity / 4 - slider.paintTicks = true - slider.paintTrack = true - slider.paintLabels = false - slider.toolTipText = - "While fuzzer \"guesses\" the values to enter as much execution paths as possible, symbolic executor tries to \"deduce\" them. Choose the proportion of generation time allocated for each of these methods within Test generation timeout. The slide has no effect for Spring Projects." - slider.updater.run() - addToTop(slider) - addToBottom(BorderLayoutPanel().apply { - addToLeft(fuzzLabel) - addToRight(symLabel) + UIUtil.setSliderIsFilled(slider, true) + slider.minimum = 0 + slider.maximum = granularity + slider.minorTickSpacing = 1 + slider.majorTickSpacing = granularity / 4 + slider.paintTicks = true + slider.paintTrack = true + slider.paintLabels = false + slider.toolTipText = + "While fuzzer \"guesses\" the values to enter as much execution paths as possible, symbolic executor tries to \"deduce\" them. Choose the proportion of generation time allocated for each of these methods within Test generation timeout. The slide has no effect for Spring Projects." + slider.updater.run() + addToTop(slider) + addToBottom(BorderLayoutPanel().apply { + addToLeft(fuzzLabel) + addToRight(symLabel) + }) }) - }) - }).align(Align.FILL) - }.enabled(UtSettings.useFuzzing) - if (!UtSettings.useFuzzing) { - row { - comment("Fuzzing is disabled in configuration file.") - link("Edit configuration") { - UIUtil.getWindow(fuzzLabel)?.dispose() - showSettingsEditor(project, "useFuzzing") + }).align(Align.FILL) + }.enabled(UtSettings.useFuzzing) + if (!UtSettings.useFuzzing) { + row { + comment("Fuzzing is disabled in configuration file.") + link("Edit configuration") { + UIUtil.getWindow(fuzzLabel)?.dispose() + showSettingsEditor(project, "useFuzzing") + } } } } diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt index db1433d7a9..8e95275aaf 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/BaseSettingsWindow.kt @@ -25,49 +25,50 @@ class BaseSettingsWindow(val project: Project) { } val panel: JPanel = panel { - row("Tests with exceptions:") { - createCombo(RuntimeExceptionTestsBehaviour::class, RuntimeExceptionTestsBehaviour.values()) - } - - row("Hanging test timeout:") { - spinner( - range = IntRange( - HangingTestsTimeout.MIN_TIMEOUT_MS.toInt(), - HangingTestsTimeout.MAX_TIMEOUT_MS.toInt() - ), - step = 50 - ).bindIntValue( - getter = { - settings.hangingTestsTimeout.timeoutMs - .coerceIn(HangingTestsTimeout.MIN_TIMEOUT_MS, HangingTestsTimeout.MAX_TIMEOUT_MS).toInt() - }, - setter = { - settings.hangingTestsTimeout = HangingTestsTimeout(it.toLong()) - } - ) + group("Common Settings") { + row("Tests with exceptions:") { + createCombo(RuntimeExceptionTestsBehaviour::class, RuntimeExceptionTestsBehaviour.values()) + } - label("milliseconds per method") - contextHelp( - "Set this timeout to define which test is \"hanging\". Increase it to test the " + - "time-consuming method or decrease if the execution speed is critical for you." - ) - } + row("Hanging test timeout:") { + spinner( + range = IntRange( + HangingTestsTimeout.MIN_TIMEOUT_MS.toInt(), + HangingTestsTimeout.MAX_TIMEOUT_MS.toInt() + ), + step = 50 + ).bindIntValue( + getter = { + settings.hangingTestsTimeout.timeoutMs + .coerceIn(HangingTestsTimeout.MIN_TIMEOUT_MS, HangingTestsTimeout.MAX_TIMEOUT_MS).toInt() + }, + setter = { + settings.hangingTestsTimeout = HangingTestsTimeout(it.toLong()) + } + ) - row { - enableExperimentalLanguagesCheckBox = checkBox("Experimental languages support") - .onApply { - settings.state.enableExperimentalLanguagesSupport = - enableExperimentalLanguagesCheckBox.isSelected - } - .onReset { - enableExperimentalLanguagesCheckBox.isSelected = - settings.experimentalLanguagesSupport == true - } - .onIsModified { enableExperimentalLanguagesCheckBox.isSelected xor settings.experimentalLanguagesSupport } - .component - contextHelp("Enable JavaScript and Python if IDE supports them") - }.bottomGap(BottomGap.MEDIUM) + label("milliseconds per method") + contextHelp( + "Set this timeout to define which test is \"hanging\". Increase it to test the " + + "time-consuming method or decrease if the execution speed is critical for you." + ) + } + row { + enableExperimentalLanguagesCheckBox = checkBox("Experimental languages support") + .onApply { + settings.state.enableExperimentalLanguagesSupport = + enableExperimentalLanguagesCheckBox.isSelected + } + .onReset { + enableExperimentalLanguagesCheckBox.isSelected = + settings.experimentalLanguagesSupport == true + } + .onIsModified { enableExperimentalLanguagesCheckBox.isSelected xor settings.experimentalLanguagesSupport } + .component + contextHelp("Enable JavaScript and Python if IDE supports them") + }.bottomGap(BottomGap.MEDIUM) + } } fun isModified(): Boolean { From 204d172206a2eee191f1ca937cf9fbf4fe7aa9d9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 13 Oct 2023 13:54:11 +0300 Subject: [PATCH 36/43] Add enable experimental by default --- .../kotlin/org/utbot/intellij/plugin/settings/CommonSettings.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/CommonSettings.kt b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/CommonSettings.kt index e6ed028959..2fc63f8e77 100644 --- a/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/CommonSettings.kt +++ b/utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/CommonSettings.kt @@ -71,7 +71,7 @@ class Settings(val project: Project) : PersistentStateComponent var commentStyle: JavaDocCommentStyle = JavaDocCommentStyle.defaultItem, var summariesGenerationType: SummariesGenerationType = UtSettings.summaryGenerationType, var generationTimeoutInMillis: Long = UtSettings.utBotGenerationTimeoutInMillis, - var enableExperimentalLanguagesSupport: Boolean = false, + var enableExperimentalLanguagesSupport: Boolean = true, var isSpringHandled: Boolean = false, ) { From 5f7ca5d4993f6db36626f4bdada8fe1adc4fc6f7 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 20 Oct 2023 11:34:07 +0300 Subject: [PATCH 37/43] Add setup ideVersion --- .../workflows/publish-plugin-from-branch.yml | 2 +- gradle.properties | 10 +++-- utbot-intellij-go/build.gradle.kts | 37 ++++++++++++++---- utbot-intellij-js/build.gradle.kts | 37 ++++++++++++++---- utbot-intellij-main/build.gradle.kts | 31 ++++++++++----- utbot-intellij-python/build.gradle.kts | 37 ++++++++++++++---- utbot-intellij/build.gradle.kts | 39 +++++++++++++------ utbot-ui-commons/build.gradle.kts | 35 +++++++++++++++-- 8 files changed, 179 insertions(+), 49 deletions(-) diff --git a/.github/workflows/publish-plugin-from-branch.yml b/.github/workflows/publish-plugin-from-branch.yml index 0bfc04d289..b6c191deb9 100644 --- a/.github/workflows/publish-plugin-from-branch.yml +++ b/.github/workflows/publish-plugin-from-branch.yml @@ -49,7 +49,7 @@ jobs: - plugin_type: IU extra_options: "-PideType=IU -PprojectType=Ultimate" - plugin_type: PY - extra_options: "-PideType=PY -PprojectType=Ultimate -PideVersion=2023.2" + extra_options: "-PideType=PY -PprojectType=Ultimate" runs-on: ubuntu-20.04 container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 steps: diff --git a/gradle.properties b/gradle.properties index 4d5506cf69..559737210c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,7 @@ kotlin.code.style=official -#Project Type +# === IDE settings === +# Project Type # - Community: for Java + Spring + Python (IC supported features) # - Ultimate: for Java + Spring + Python (IU supported features) + JavaScript + Go projectType=Ultimate @@ -11,9 +12,8 @@ ultimateEdition=Ultimate # IU, IC, PC, PY # IC for AndroidStudio ideType=IC -ideVersion=232.8660.185 -#ideVersion=2023.2 -pycharmIdeVersion=2023.2 +ideaVersion=232.8660.185 +pycharmVersion=2023.2 # ALL, NOJS buildType=NOJS @@ -22,6 +22,7 @@ pythonIde=IC,IU,PC,PY jsIde=IU,PY jsBuild=ALL goIde=IU,GO +androidStudioIde=IC # In order to run Android Studio instead of IntelliJ Community, specify the path to your Android Studio installation #androidStudioPath=your_path_to_android_studio @@ -32,6 +33,7 @@ pythonCommunityPluginVersion=232.8660.185 pythonUltimatePluginVersion=232.8660.185 # Version numbers: https://plugins.jetbrains.com/plugin/9568-go/versions goPluginVersion=232.8660.142 +# === IDE settings === junit5Version=5.8.2 junit4Version=4.13.2 diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index 0124225da5..17d5bb616e 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -1,22 +1,45 @@ -val projectType: String by rootProject -val communityEdition: String by rootProject -val ultimateEdition: String by rootProject val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject val jacksonVersion: String? by rootProject -val ideType: String? by rootProject -val ideVersion: String by rootProject val kotlinPluginVersion: String by rootProject + +// === IDE settings === +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject + +val ideType: String by rootProject +val androidStudioPath: String? by rootProject + +val ideaVersion: String? by rootProject +val pycharmVersion: String? by rootProject +val goVersion: String? by rootProject + +val javaIde: String? by rootProject +val pythonIde: String? by rootProject +val jsIde: String? by rootProject +val goIde: String? by rootProject + +val ideVersion = when(ideType) { + "PC", "PY" -> pycharmVersion + "GO" -> goVersion + else -> ideaVersion +} + val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject val goPluginVersion: String? by rootProject -val androidStudioPath: String? by rootProject + +// https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file +val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" + +project.tasks.asMap["runIde"]?.enabled = false +// === IDE settings === plugins { id("org.jetbrains.intellij") version "1.13.1" } -project.tasks.asMap["runIde"]?.enabled = false tasks { compileKotlin { diff --git a/utbot-intellij-js/build.gradle.kts b/utbot-intellij-js/build.gradle.kts index e3d6474ca1..8a4ff7e969 100644 --- a/utbot-intellij-js/build.gradle.kts +++ b/utbot-intellij-js/build.gradle.kts @@ -1,21 +1,44 @@ -val projectType: String by rootProject -val communityEdition: String by rootProject -val ultimateEdition: String by rootProject val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject val jacksonVersion: String? by rootProject -val ideType: String? by rootProject -val ideVersion: String? by rootProject + +// === IDE settings === +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject + +val ideType: String by rootProject +val androidStudioPath: String? by rootProject + +val ideaVersion: String? by rootProject +val pycharmVersion: String? by rootProject +val goVersion: String? by rootProject + +val javaIde: String? by rootProject +val pythonIde: String? by rootProject +val jsIde: String? by rootProject +val goIde: String? by rootProject + +val ideVersion = when(ideType) { + "PC", "PY" -> pycharmVersion + "GO" -> goVersion + else -> ideaVersion +} + val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject val goPluginVersion: String? by rootProject -val androidStudioPath: String? by rootProject + +// https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file +val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" + +project.tasks.asMap["runIde"]?.enabled = false +// === IDE settings === plugins { id("org.jetbrains.intellij") version "1.13.1" } -project.tasks.asMap["runIde"]?.enabled = false tasks { compileKotlin { diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index 1461820031..25820bbf08 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -1,27 +1,40 @@ +val semVer: String? by rootProject +val junit5Version: String by rootProject +val junit4PlatformVersion: String by rootProject + +// === IDE settings === val projectType: String by rootProject val communityEdition: String by rootProject val ultimateEdition: String by rootProject -val ideType: String? by rootProject -val ideVersion: String? by rootProject -val pythonCommunityPluginVersion: String? by rootProject -val pythonUltimatePluginVersion: String? by rootProject -val goPluginVersion: String? by rootProject +val ideType: String by rootProject +val androidStudioPath: String? by rootProject + +val ideaVersion: String? by rootProject +val pycharmVersion: String? by rootProject +val goVersion: String? by rootProject val javaIde: String? by rootProject val pythonIde: String? by rootProject val jsIde: String? by rootProject val goIde: String? by rootProject -val semVer: String? by rootProject -val androidStudioPath: String? by rootProject +val ideVersion = when(ideType) { + "PC", "PY" -> pycharmVersion + "GO" -> goVersion + else -> ideaVersion +} -val junit5Version: String by rootProject -val junit4PlatformVersion: String by rootProject +val pythonCommunityPluginVersion: String? by rootProject +val pythonUltimatePluginVersion: String? by rootProject +val goPluginVersion: String? by rootProject // https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" +project.tasks.asMap["runIde"]?.enabled = false +// === IDE settings === + plugins { id("org.jetbrains.intellij") version "1.13.1" } diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index 2c91a5662c..fe655b97e2 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -1,21 +1,44 @@ -val projectType: String by rootProject -val communityEdition: String by rootProject -val ultimateEdition: String by rootProject val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject val jacksonVersion: String? by rootProject -val ideType: String? by rootProject -val ideVersion: String by rootProject + +// === IDE settings === +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject + +val ideType: String by rootProject +val androidStudioPath: String? by rootProject + +val ideaVersion: String? by rootProject +val pycharmVersion: String? by rootProject +val goVersion: String? by rootProject + +val javaIde: String? by rootProject +val pythonIde: String? by rootProject +val jsIde: String? by rootProject +val goIde: String? by rootProject + +val ideVersion = when(ideType) { + "PC", "PY" -> pycharmVersion + "GO" -> goVersion + else -> ideaVersion +} + val pythonCommunityPluginVersion: String? by rootProject val pythonUltimatePluginVersion: String? by rootProject val goPluginVersion: String? by rootProject -val androidStudioPath: String? by rootProject + +// https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file +val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" + +project.tasks.asMap["runIde"]?.enabled = false +// === IDE settings === plugins { id("org.jetbrains.intellij") version "1.13.1" } -project.tasks.asMap["runIde"]?.enabled = false tasks { compileKotlin { diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index 6763a526a0..ec42b9bab0 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -1,31 +1,48 @@ -val projectType: String by rootProject -val communityEdition: String by rootProject -val ultimateEdition: String by rootProject - val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject val jacksonVersion: String? by rootProject -val ideType: String? by rootProject -val ideVersion: String? by rootProject -val pythonCommunityPluginVersion: String? by rootProject -val pythonUltimatePluginVersion: String? by rootProject -val goPluginVersion: String? by rootProject - val sootVersion: String? by rootProject val kryoVersion: String? by rootProject val rdVersion: String? by rootProject val semVer: String? by rootProject -val androidStudioPath: String? by rootProject val junit5Version: String by rootProject val junit4PlatformVersion: String by rootProject +// === IDE settings === +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject + +val ideType: String by rootProject +val androidStudioPath: String? by rootProject + +val ideaVersion: String? by rootProject +val pycharmVersion: String? by rootProject +val goVersion: String? by rootProject + +val javaIde: String? by rootProject +val pythonIde: String? by rootProject +val jsIde: String? by rootProject +val goIde: String? by rootProject + +val ideVersion = when(ideType) { + "PC", "PY" -> pycharmVersion + "GO" -> goVersion + else -> ideaVersion +} + +val pythonCommunityPluginVersion: String? by rootProject +val pythonUltimatePluginVersion: String? by rootProject +val goPluginVersion: String? by rootProject + // https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" project.tasks.asMap["runIde"]?.enabled = false +// === IDE settings === plugins { id("org.jetbrains.intellij") version "1.13.1" diff --git a/utbot-ui-commons/build.gradle.kts b/utbot-ui-commons/build.gradle.kts index c0d622a353..434df817e2 100644 --- a/utbot-ui-commons/build.gradle.kts +++ b/utbot-ui-commons/build.gradle.kts @@ -1,14 +1,43 @@ val kotlinLoggingVersion: String by rootProject -val ideType: String by rootProject -val ideVersion: String by rootProject val semVer: String? by rootProject val slf4jVersion: String by rootProject + +// === IDE settings === +val projectType: String by rootProject +val communityEdition: String by rootProject +val ultimateEdition: String by rootProject + +val ideType: String by rootProject val androidStudioPath: String? by rootProject +val ideaVersion: String? by rootProject +val pycharmVersion: String? by rootProject +val goVersion: String? by rootProject + +val javaIde: String? by rootProject +val pythonIde: String? by rootProject +val jsIde: String? by rootProject +val goIde: String? by rootProject + +val ideVersion = when(ideType) { + "PC", "PY" -> pycharmVersion + "GO" -> goVersion + else -> ideaVersion +} + +val pythonCommunityPluginVersion: String? by rootProject +val pythonUltimatePluginVersion: String? by rootProject +val goPluginVersion: String? by rootProject + +// https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file +val ideTypeOrAndroidStudio = if (androidStudioPath == null) ideType else "IC" + +project.tasks.asMap["runIde"]?.enabled = false +// === IDE settings === + plugins { id("org.jetbrains.intellij") version "1.13.1" } -project.tasks.asMap["runIde"]?.enabled = false intellij { version.set(ideVersion) From e6da4675a4d4d90a4c1fcb79a7e28d4e337cafc5 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Mon, 23 Oct 2023 14:49:26 +0300 Subject: [PATCH 38/43] Remove unused test files, change combined-projects-matrix.json --- .../workflows/combined-projects-matrix.json | 2 +- utbot-intellij-main/src/test/java/Bar.java | 3 --- utbot-intellij-main/src/test/java/Foo.java | 20 ------------------- 3 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 utbot-intellij-main/src/test/java/Bar.java delete mode 100644 utbot-intellij-main/src/test/java/Foo.java diff --git a/.github/workflows/combined-projects-matrix.json b/.github/workflows/combined-projects-matrix.json index adbcb967c6..83130dd191 100644 --- a/.github/workflows/combined-projects-matrix.json +++ b/.github/workflows/combined-projects-matrix.json @@ -1,7 +1,7 @@ { "projects": [ { - "FIRST": "utbot-intellij-main", + "FIRST": "utbot-intellij", "SECOND": "utbot-cli" }, { diff --git a/utbot-intellij-main/src/test/java/Bar.java b/utbot-intellij-main/src/test/java/Bar.java deleted file mode 100644 index e4d7ed9b9f..0000000000 --- a/utbot-intellij-main/src/test/java/Bar.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Bar { - public int c; -} diff --git a/utbot-intellij-main/src/test/java/Foo.java b/utbot-intellij-main/src/test/java/Foo.java deleted file mode 100644 index 5dd9ce9112..0000000000 --- a/utbot-intellij-main/src/test/java/Foo.java +++ /dev/null @@ -1,20 +0,0 @@ -public class Foo { - public int a; - public int b; - public Bar c; - - public Foo() { - } - - public int getA() { - return a; - } - - public int getB() { - return b; - } - - public Bar getC() { - return c; - } -} From 5f3ac6fbbc93ea23e900c48f1e05d95b7f4331c9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Mon, 23 Oct 2023 15:16:26 +0300 Subject: [PATCH 39/43] Fix repositories in utbot-intellij --- utbot-intellij-main/build.gradle.kts | 5 ----- utbot-intellij/build.gradle.kts | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index 25820bbf08..b97160e524 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -122,11 +122,6 @@ tasks { } } -repositories { - maven("https://jitpack.io") - maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") -} - dependencies { implementation(project(":utbot-ui-commons")) diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index ec42b9bab0..fd7ecfda71 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -157,6 +157,11 @@ tasks { } } +repositories { + maven("https://jitpack.io") + maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") +} + dependencies { implementation(group ="com.jetbrains.rd", name = "rd-framework", version = rdVersion) implementation(group ="com.jetbrains.rd", name = "rd-core", version = rdVersion) From 28be8be51ccbf46dee47bcdf17aa98c829ada2ea Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 25 Oct 2023 16:28:10 +0300 Subject: [PATCH 40/43] Add ide version for goland --- utbot-intellij-go/build.gradle.kts | 4 ++-- utbot-intellij-js/build.gradle.kts | 4 ++-- utbot-intellij-main/build.gradle.kts | 4 ++-- utbot-intellij-python/build.gradle.kts | 4 ++-- utbot-intellij/build.gradle.kts | 4 ++-- utbot-ui-commons/build.gradle.kts | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/utbot-intellij-go/build.gradle.kts b/utbot-intellij-go/build.gradle.kts index 17d5bb616e..fff30caba1 100644 --- a/utbot-intellij-go/build.gradle.kts +++ b/utbot-intellij-go/build.gradle.kts @@ -14,7 +14,7 @@ val androidStudioPath: String? by rootProject val ideaVersion: String? by rootProject val pycharmVersion: String? by rootProject -val goVersion: String? by rootProject +val golandVersion: String? by rootProject val javaIde: String? by rootProject val pythonIde: String? by rootProject @@ -23,7 +23,7 @@ val goIde: String? by rootProject val ideVersion = when(ideType) { "PC", "PY" -> pycharmVersion - "GO" -> goVersion + "GO" -> golandVersion else -> ideaVersion } diff --git a/utbot-intellij-js/build.gradle.kts b/utbot-intellij-js/build.gradle.kts index 8a4ff7e969..916c540eed 100644 --- a/utbot-intellij-js/build.gradle.kts +++ b/utbot-intellij-js/build.gradle.kts @@ -13,7 +13,7 @@ val androidStudioPath: String? by rootProject val ideaVersion: String? by rootProject val pycharmVersion: String? by rootProject -val goVersion: String? by rootProject +val golandVersion: String? by rootProject val javaIde: String? by rootProject val pythonIde: String? by rootProject @@ -22,7 +22,7 @@ val goIde: String? by rootProject val ideVersion = when(ideType) { "PC", "PY" -> pycharmVersion - "GO" -> goVersion + "GO" -> golandVersion else -> ideaVersion } diff --git a/utbot-intellij-main/build.gradle.kts b/utbot-intellij-main/build.gradle.kts index b97160e524..30e728a74d 100644 --- a/utbot-intellij-main/build.gradle.kts +++ b/utbot-intellij-main/build.gradle.kts @@ -12,7 +12,7 @@ val androidStudioPath: String? by rootProject val ideaVersion: String? by rootProject val pycharmVersion: String? by rootProject -val goVersion: String? by rootProject +val golandVersion: String? by rootProject val javaIde: String? by rootProject val pythonIde: String? by rootProject @@ -21,7 +21,7 @@ val goIde: String? by rootProject val ideVersion = when(ideType) { "PC", "PY" -> pycharmVersion - "GO" -> goVersion + "GO" -> golandVersion else -> ideaVersion } diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index fe655b97e2..cf1e5ea9f1 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -13,7 +13,7 @@ val androidStudioPath: String? by rootProject val ideaVersion: String? by rootProject val pycharmVersion: String? by rootProject -val goVersion: String? by rootProject +val golandVersion: String? by rootProject val javaIde: String? by rootProject val pythonIde: String? by rootProject @@ -22,7 +22,7 @@ val goIde: String? by rootProject val ideVersion = when(ideType) { "PC", "PY" -> pycharmVersion - "GO" -> goVersion + "GO" -> golandVersion else -> ideaVersion } diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index fd7ecfda71..8f0520b4a9 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -21,7 +21,7 @@ val androidStudioPath: String? by rootProject val ideaVersion: String? by rootProject val pycharmVersion: String? by rootProject -val goVersion: String? by rootProject +val golandVersion: String? by rootProject val javaIde: String? by rootProject val pythonIde: String? by rootProject @@ -30,7 +30,7 @@ val goIde: String? by rootProject val ideVersion = when(ideType) { "PC", "PY" -> pycharmVersion - "GO" -> goVersion + "GO" -> golandVersion else -> ideaVersion } diff --git a/utbot-ui-commons/build.gradle.kts b/utbot-ui-commons/build.gradle.kts index 434df817e2..10ab87140d 100644 --- a/utbot-ui-commons/build.gradle.kts +++ b/utbot-ui-commons/build.gradle.kts @@ -12,7 +12,7 @@ val androidStudioPath: String? by rootProject val ideaVersion: String? by rootProject val pycharmVersion: String? by rootProject -val goVersion: String? by rootProject +val golandVersion: String? by rootProject val javaIde: String? by rootProject val pythonIde: String? by rootProject @@ -21,7 +21,7 @@ val goIde: String? by rootProject val ideVersion = when(ideType) { "PC", "PY" -> pycharmVersion - "GO" -> goVersion + "GO" -> golandVersion else -> ideaVersion } From 4e6fd48bb207d3571e17198b134b96e0e370d43c Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 25 Oct 2023 16:28:37 +0300 Subject: [PATCH 41/43] Rename test module --- .github/workflows/run-chosen-tests-from-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-chosen-tests-from-branch.yml b/.github/workflows/run-chosen-tests-from-branch.yml index d59a68b03c..ea5dec9ac5 100644 --- a/.github/workflows/run-chosen-tests-from-branch.yml +++ b/.github/workflows/run-chosen-tests-from-branch.yml @@ -18,7 +18,7 @@ on: - utbot-gradle - utbot-instrumentation-tests - utbot-instrumentation - - utbot-intellij-main + - utbot-intellij - utbot-sample - utbot-summary - utbot-summary-tests From 5e5970f35c39fc3bded4d54ee6eab1ebd4891963 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Wed, 25 Oct 2023 16:30:17 +0300 Subject: [PATCH 42/43] Move java dependencies --- .../src/main/resources/META-INF/plugin.xml | 17 ----------------- .../src/main/resources/META-INF/withJava.xml | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/utbot-intellij-main/src/main/resources/META-INF/plugin.xml b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml index 024c39dc04..89f84572f4 100644 --- a/utbot-intellij-main/src/main/resources/META-INF/plugin.xml +++ b/utbot-intellij-main/src/main/resources/META-INF/plugin.xml @@ -31,13 +31,7 @@ displayName="UnitTestBot"/> - - - - - - @@ -89,15 +83,4 @@ ]]> - - - - diff --git a/utbot-intellij-main/src/main/resources/META-INF/withJava.xml b/utbot-intellij-main/src/main/resources/META-INF/withJava.xml index fafe2e683d..eafe833bc7 100644 --- a/utbot-intellij-main/src/main/resources/META-INF/withJava.xml +++ b/utbot-intellij-main/src/main/resources/META-INF/withJava.xml @@ -4,5 +4,19 @@ + + + + + + + \ No newline at end of file From 70a524fb79154c59ceedd81829f3f7a35ec080b8 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Thu, 26 Oct 2023 15:55:46 +0300 Subject: [PATCH 43/43] Add golandversion --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 559737210c..d67d7f007d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,6 +14,7 @@ ultimateEdition=Ultimate ideType=IC ideaVersion=232.8660.185 pycharmVersion=2023.2 +golandVersion=2023.2 # ALL, NOJS buildType=NOJS @@ -22,7 +23,6 @@ pythonIde=IC,IU,PC,PY jsIde=IU,PY jsBuild=ALL goIde=IU,GO -androidStudioIde=IC # In order to run Android Studio instead of IntelliJ Community, specify the path to your Android Studio installation #androidStudioPath=your_path_to_android_studio