Skip to content

Commit 5a97ffa

Browse files
authored
Add Enabled Summaries Generation to the UI Settings (#1162)
* Added checkbox for the enableSummariesGeneration * Added checkbox for the enableSummariesGeneration * Added checkbox for the enableSummariesGeneration * Fixed wrong setting saving
1 parent 0c5374e commit 5a97ffa

File tree

9 files changed

+35
-7
lines changed

9 files changed

+35
-7
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ object UtSettings : AbstractSettings(
133133
var useCustomJavaDocTags by getBooleanProperty(true)
134134

135135
/**
136-
* Enable the machine learning module to generate summaries for methods under test.
136+
* Enable the Summarization module to generate summaries for methods under test.
137137
* True by default.
138138
*
139139
* Note: if it is false, all the execution for a particular method will be stored at the same nameless region.
140140
*/
141-
var enableMachineLearningModule by getBooleanProperty(true)
141+
var enableSummariesGeneration by getBooleanProperty(true)
142142

143143
/**
144144
* Options below regulate which [NullPointerException] check should be performed.

utbot-framework/src/main/kotlin/org/utbot/tests/infrastructure/UtValueTestCaseChecker.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ abstract class UtValueTestCaseChecker(
8888
UtSettings.saveRemainingStatesForConcreteExecution = false
8989
UtSettings.useFuzzing = false
9090
UtSettings.useCustomJavaDocTags = false
91+
UtSettings.enableSummariesGeneration = true
9192
}
9293

9394
// checks paramsBefore and result

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import mu.KotlinLogging
2727
import org.jetbrains.kotlin.idea.util.module
2828
import org.utbot.framework.UtSettings
2929
import org.utbot.framework.plugin.api.ClassId
30-
import org.utbot.framework.plugin.api.ExecutableId
3130
import org.utbot.framework.plugin.api.JavaDocCommentStyle
3231
import org.utbot.framework.plugin.api.util.withStaticsSubstitutionRequired
3332
import org.utbot.framework.plugin.services.JdkInfoService
@@ -192,6 +191,8 @@ object UtTestsDialogProcessor {
192191
UtSettings.useCustomJavaDocTags =
193192
model.commentStyle == JavaDocCommentStyle.CUSTOM_JAVADOC_TAGS
194193

194+
UtSettings.enableSummariesGeneration = model.enableSummariesGeneration
195+
195196
val searchDirectory = ReadAction
196197
.nonBlocking<Path> {
197198
project.basePath?.let { Paths.get(it) }

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ data class GenerateTestsModel(
7777
srcClasses.map { it.packageName }.distinct().size != 1
7878
}
7979
var runGeneratedTestsWithCoverage : Boolean = false
80+
var enableSummariesGeneration : Boolean = true
8081

8182
val jdkVersion: JavaSdkVersion?
8283
get() = try {

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Settings.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
5555
var classesToMockAlways: Array<String> = Mocker.defaultSuperClassesToMockAlwaysNames.toTypedArray(),
5656
var fuzzingValue: Double = 0.05,
5757
var runGeneratedTestsWithCoverage: Boolean = false,
58-
var commentStyle: JavaDocCommentStyle = JavaDocCommentStyle.defaultItem
58+
var commentStyle: JavaDocCommentStyle = JavaDocCommentStyle.defaultItem,
59+
var enableSummariesGeneration: Boolean = true
5960
) {
6061
constructor(model: GenerateTestsModel) : this(
6162
codegenLanguage = model.codegenLanguage,
@@ -70,7 +71,8 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
7071
classesToMockAlways = model.chosenClassesToMockAlways.mapTo(mutableSetOf()) { it.name }.toTypedArray(),
7172
fuzzingValue = model.fuzzingValue,
7273
runGeneratedTestsWithCoverage = model.runGeneratedTestsWithCoverage,
73-
commentStyle = model.commentStyle
74+
commentStyle = model.commentStyle,
75+
enableSummariesGeneration = model.enableSummariesGeneration
7476
)
7577

7678
override fun equals(other: Any?): Boolean {
@@ -92,6 +94,8 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
9294
if (!classesToMockAlways.contentEquals(other.classesToMockAlways)) return false
9395
if (fuzzingValue != other.fuzzingValue) return false
9496
if (runGeneratedTestsWithCoverage != other.runGeneratedTestsWithCoverage) return false
97+
if (commentStyle != other.commentStyle) return false
98+
if (enableSummariesGeneration != other.enableSummariesGeneration) return false
9599

96100
return true
97101
}
@@ -109,6 +113,7 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
109113
result = 31 * result + classesToMockAlways.contentHashCode()
110114
result = 31 * result + fuzzingValue.hashCode()
111115
result = 31 * result + if (runGeneratedTestsWithCoverage) 1 else 0
116+
result = 31 * result + if (enableSummariesGeneration) 1 else 0
112117

113118
return result
114119
}
@@ -149,6 +154,8 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
149154
}
150155
var runGeneratedTestsWithCoverage = state.runGeneratedTestsWithCoverage
151156

157+
var enableSummariesGeneration = state.enableSummariesGeneration
158+
152159
fun setClassesToMockAlways(classesToMockAlways: List<String>) {
153160
state.classesToMockAlways = classesToMockAlways.distinct().toTypedArray()
154161
}

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class SettingsWindow(val project: Project) {
3636
// TODO it is better to use something like SearchEverywhere for classes but it is complicated to implement
3737
private val excludeTable = MockAlwaysClassesTable(project)
3838
private lateinit var forceMockCheckBox: JCheckBox
39+
private lateinit var enableSummarizationGenerationCheckBox: JCheckBox
3940

4041
val panel: JPanel = panel {
4142
val valuesComboBox: LayoutBuilder.(KClass<*>, Array<*>) -> Unit = { loader, values ->
@@ -98,6 +99,22 @@ class SettingsWindow(val project: Project) {
9899
valuesComboBox(loader, values)
99100
}
100101

102+
row {
103+
cell {
104+
enableSummarizationGenerationCheckBox = checkBox("Enable Summaries Generation")
105+
.onApply {
106+
settings.state.enableSummariesGeneration = enableSummarizationGenerationCheckBox.isSelected
107+
}
108+
.onReset {
109+
enableSummarizationGenerationCheckBox.isSelected = settings.state.enableSummariesGeneration
110+
}
111+
.onIsModified {
112+
enableSummarizationGenerationCheckBox.isSelected xor settings.state.enableSummariesGeneration
113+
}
114+
.component
115+
}
116+
}
117+
101118
row {
102119
cell {
103120
forceMockCheckBox = checkBox("Force mocking static methods")

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
514514
model.chosenClassesToMockAlways = chosenClassesToMockAlways()
515515
model.fuzzingValue = fuzzingValue
516516
model.commentStyle = javaDocCommentStyle
517+
model.enableSummariesGeneration = state.enableSummariesGeneration
517518
UtSettings.treatOverflowAsError = treatOverflowAsError == TreatOverflowAsError.AS_ERROR
518519
}
519520

utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fun setOptions() {
149149
UtSettings.useFuzzing = true
150150
UtSettings.classfilesCanChange = false
151151
UtSettings.useAssembleModelGenerator = false
152-
UtSettings.enableMachineLearningModule = false
152+
UtSettings.enableSummariesGeneration = false
153153
UtSettings.preferredCexOption = false
154154
UtSettings.warmupConcreteExecution = true
155155
UtSettings.testMinimizationStrategyType = TestSelectionStrategyType.COVERAGE_STRATEGY

utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import soot.SootMethod
4343
private val logger = KotlinLogging.logger {}
4444

4545
fun UtMethodTestSet.summarize(sourceFile: File?, searchDirectory: Path = Paths.get("")): UtMethodTestSet {
46-
if (!UtSettings.enableMachineLearningModule) return this
46+
if (!UtSettings.enableSummariesGeneration) return this
4747

4848
return try {
4949
makeDiverseExecutions(this)

0 commit comments

Comments
 (0)