mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Fix directory exclusion
#KTIJ-29752 GitOrigin-RevId: b785f44a90b14bc5759d4c268bf58570140bab52
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b921cf4559
commit
28927af215
+20
-10
@@ -17,12 +17,9 @@ import java.io.File
|
||||
import java.util.*
|
||||
import javax.lang.model.element.Modifier
|
||||
|
||||
fun File.toRelativeStringSystemIndependent(base: File): String {
|
||||
val path = this.toRelativeString(base)
|
||||
return if (File.separatorChar == '\\') {
|
||||
path.replace('\\', '/')
|
||||
} else path
|
||||
}
|
||||
fun File.toRelativeStringSystemIndependent(base: File): String = toRelativeString(base).toStringSystemIndependent()
|
||||
|
||||
fun String.toStringSystemIndependent(): String = if (File.separatorChar == '\\') this.replace('\\', '/') else this
|
||||
|
||||
interface TestMethod : RenderElement {
|
||||
val methodName: String
|
||||
@@ -56,7 +53,7 @@ class SuiteElement private constructor(
|
||||
val nestedSuites = mutableListOf<SuiteElement>()
|
||||
|
||||
for (file in rootFile.listFiles().orEmpty()) {
|
||||
if (depth > 0 && file.isDirectory && file.name !in model.excludedDirectories) {
|
||||
if (depth > 0 && !file.isExcluded(model)) {
|
||||
val nestedClassName = file.toJavaIdentifier().capitalizeAsciiOnly()
|
||||
val nestedModel = model.copy(
|
||||
path = file.toRelativeStringSystemIndependent(group.testDataRoot),
|
||||
@@ -74,10 +71,9 @@ class SuiteElement private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
val match = model.matcher(file.name) ?: continue
|
||||
if (file.isExcluded(model)) continue
|
||||
|
||||
// Don't generate a directory-based test if the directory is excluded.
|
||||
if (file.isDirectory && file.name in model.excludedDirectories) continue
|
||||
val match = model.matcher(file.name) ?: continue
|
||||
|
||||
val methodNameBase = getTestMethodNameBase(match.methodName)
|
||||
val path = file.toRelativeStringSystemIndependent(group.moduleRoot)
|
||||
@@ -147,6 +143,20 @@ class SuiteElement private constructor(
|
||||
return createElement(className, isNested, methods, nestedSuites)
|
||||
}
|
||||
|
||||
private fun File.isExcluded(model: TModel): Boolean {
|
||||
if (model.excludedDirectories.isNotEmpty()) {
|
||||
// Don't generate a directory-based test if the directory is excluded.
|
||||
if (isDirectory && name in model.excludedDirectories) return true
|
||||
|
||||
// Don't generate a file-based test if its parent directory is excluded.
|
||||
if (isFile) {
|
||||
val p = parentFile.path.toStringSystemIndependent()
|
||||
if (model.excludedDirectories.any { p.contains(it) }) return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun createStatements(
|
||||
group: TGroup,
|
||||
model: TModel,
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ private fun assembleWorkspace(): TWorkspace = workspace(KotlinPluginMode.K2) {
|
||||
|
||||
testClass<AbstractFirParameterInfoTest> {
|
||||
model(
|
||||
"parameterInfo", pattern = Patterns.forRegex("^([\\w\\-_]+)\\.kt$"), isRecursive = true,
|
||||
"parameterInfo", pattern = Patterns.forRegex("^([\\w\\-_]+)\\.(kt|java)$"), isRecursive = true,
|
||||
excludedDirectories = listOf("withLib1/sharedLib", "withLib2/sharedLib", "withLib3/sharedLib")
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user