Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

UI. Gradle project. Suggest all Test sources roots for test generatio… #705

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ import org.utbot.intellij.plugin.ui.utils.addSourceRootIfAbsent
import org.utbot.intellij.plugin.ui.utils.allLibraries
import org.utbot.intellij.plugin.ui.utils.findFrameworkLibrary
import org.utbot.intellij.plugin.ui.utils.getOrCreateTestResourcesPath
import org.utbot.intellij.plugin.ui.utils.isGradle
import org.utbot.intellij.plugin.ui.utils.kotlinTargetPlatform
import org.utbot.intellij.plugin.ui.utils.parseVersion
import org.utbot.intellij.plugin.ui.utils.testResourceRootTypes
Expand Down Expand Up @@ -435,7 +436,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
val testRoot = getTestRoot()
?: return ValidationInfo("Test source root is not configured", testSourceFolderField.childComponent)

if (findReadOnlyContentEntry(testRoot) == null) {
if (!model.project.isGradle() && findReadOnlyContentEntry(testRoot) == null) {
return ValidationInfo("Test source root is located out of content entry", testSourceFolderField.childComponent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.intellij.util.ArrayUtil
import java.io.File
import javax.swing.DefaultComboBoxModel
import javax.swing.JList
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
import org.utbot.common.PathUtil
import org.utbot.intellij.plugin.models.GenerateTestsModel
import org.utbot.intellij.plugin.ui.utils.addDedicatedTestRoot
Expand Down Expand Up @@ -50,7 +51,9 @@ class TestFolderComboWithBrowseButton(private val model: GenerateTestsModel) : C
}
}

val testRoots = model.potentialTestModules.flatMap { it.suitableTestSourceRoots().toMutableList() }.toMutableList()
val testRoots = model.potentialTestModules
.flatMap { it.suitableTestSourceRoots().toList() }
.toMutableList()

// this method is blocked for Gradle, where multiple test modules can exist
model.testModule.addDedicatedTestRoot(testRoots)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.jetbrains.android.sdk.AndroidSdkType
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
import org.jetbrains.kotlin.config.TestResourceKotlinRootType
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
import org.jetbrains.kotlin.platform.TargetPlatformVersion

private val logger = KotlinLogging.logger {}
Expand Down Expand Up @@ -86,6 +87,10 @@ fun Module.getOrCreateSarifReportsPath(testSourceRoot: VirtualFile?): Path {
* Find test modules by current source module.
*/
fun Module.testModules(project: Project): List<Module> {
if (project.isGradle()) {
return project.allModules()
}

var testModules = findPotentialModulesForTests(project, this)
val testRootUrls = testModules.flatMap { it.suitableTestSourceRoots() }

Expand Down