File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -569,7 +569,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
569
569
try {
570
570
val contentEntry = modifiableModel.contentEntries
571
571
.filterNot { it.file == null }
572
- .firstOrNull { VfsUtil .isAncestor(it.file!! , testSourceRoot, true ) }
572
+ .firstOrNull { VfsUtil .isAncestor(it.file!! , testSourceRoot, false ) }
573
573
? : return false
574
574
575
575
contentEntry.addSourceRootIfAbsent(
Original file line number Diff line number Diff line change @@ -16,13 +16,18 @@ import javax.swing.JList
16
16
import org.utbot.common.PathUtil
17
17
import org.utbot.intellij.plugin.models.GenerateTestsModel
18
18
import org.utbot.intellij.plugin.ui.utils.addDedicatedTestRoot
19
+ import org.utbot.intellij.plugin.ui.utils.isGradle
19
20
import org.utbot.intellij.plugin.ui.utils.suitableTestSourceRoots
20
21
21
22
class TestFolderComboWithBrowseButton (private val model : GenerateTestsModel ) : ComboboxWithBrowseButton() {
22
23
23
24
private val SET_TEST_FOLDER = " set test folder"
24
25
25
26
init {
27
+ if (model.project.isGradle()) {
28
+ setButtonEnabled(false )
29
+ button.toolTipText = " Please define custom test source root via Gradle"
30
+ }
26
31
childComponent.isEditable = false
27
32
childComponent.renderer = object : ColoredListCellRenderer <Any ?>() {
28
33
override fun customizeCellRenderer (
Original file line number Diff line number Diff line change 1
1
package org.utbot.intellij.plugin.ui.utils
2
2
3
+ import com.android.tools.idea.gradle.project.GradleProjectInfo
3
4
import org.utbot.common.PathUtil.toPath
4
5
import org.utbot.common.WorkaroundReason
5
6
import org.utbot.common.workaround
@@ -144,14 +145,14 @@ private fun Module.suitableTestSourceFolders(codegenLanguage: CodegenLanguage):
144
145
// Heuristics: User is more likely to choose the shorter path
145
146
.sortedBy { it.url.length }
146
147
}
148
+ fun Project.isGradle () = GradleProjectInfo .getInstance(this ).isBuildWithGradle
147
149
148
150
private const val dedicatedTestSourceRootName = " utbot_tests"
149
151
fun Module.addDedicatedTestRoot (testSourceRoots : MutableList <VirtualFile >): VirtualFile ? {
152
+ // Don't suggest new test source roots for Gradle project where 'unexpected' test roots won't work
153
+ if (project.isGradle()) return null
150
154
// Dedicated test root already exists
151
- // OR it looks like standard structure of Gradle project where 'unexpected' test roots won't work
152
- if (testSourceRoots.any { file ->
153
- file.name == dedicatedTestSourceRootName || file.path.endsWith(" src/test/java" )
154
- }) return null
155
+ if (testSourceRoots.any { file -> file.name == dedicatedTestSourceRootName }) return null
155
156
156
157
val moduleInstance = ModuleRootManager .getInstance(this )
157
158
val testFolder = moduleInstance.contentEntries.flatMap { it.sourceFolders.toList() }
You can’t perform that action at this time.
0 commit comments