Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Attempts to improve the logic
  • Loading branch information
EgorkaKulikov committed Aug 23, 2022
commit 9d0880503558655a8ac5b0a4c696a14bfb323850
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ class TestFolderComboWithBrowseButton(private val model: GenerateTestsModel) : C
}
}

val testRoots = if (model.project.isGradle()) {
val allRoots = mutableSetOf<VirtualFile>()
model.project.allModules().map { it.suitableTestSourceRoots() }.forEach(allRoots::addAll)
allRoots.toMutableList()
} else {
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