diff --git a/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java b/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java index da4ef68e65b..2b06ef465ec 100644 --- a/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java +++ b/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java @@ -33,6 +33,7 @@ public class SimpleTestClassModel implements TestClassModel { private final String doTestMethodName; @NotNull private final String testClassName; + private final Integer deep; @NotNull private final TargetBackend targetBackend; @NotNull @@ -56,7 +57,8 @@ public class SimpleTestClassModel implements TestClassModel { @NotNull TargetBackend targetBackend, @NotNull Collection excludeDirs, boolean skipIgnored, - String testRunnerMethodName + String testRunnerMethodName, + Integer deep ) { this.rootFile = rootFile; this.recursive = recursive; @@ -69,12 +71,13 @@ public class SimpleTestClassModel implements TestClassModel { this.excludeDirs = excludeDirs.isEmpty() ? Collections.emptySet() : new LinkedHashSet<>(excludeDirs); this.skipIgnored = skipIgnored; this.testRunnerMethodName = testRunnerMethodName; + this.deep = deep; } @NotNull @Override public Collection getInnerTestClasses() { - if (!rootFile.isDirectory() || !recursive) { + if (!rootFile.isDirectory() || !recursive || deep != null && deep < 1) { return Collections.emptyList(); } @@ -88,7 +91,7 @@ public class SimpleTestClassModel implements TestClassModel { children.add(new SimpleTestClassModel( file, true, excludeParentDirs, filenamePattern, checkFilenameStartsLowerCase, doTestMethodName, innerTestClassName, targetBackend, excludesStripOneDirectory(file.getName()), - skipIgnored, testRunnerMethodName) + skipIgnored, testRunnerMethodName, deep != null ? deep - 1 : null) ); } } @@ -158,7 +161,7 @@ public class SimpleTestClassModel implements TestClassModel { boolean hasCoroutines = false; - if (listFiles != null) { + if (listFiles != null && (deep == null || deep == 0)) { for (File file : listFiles) { if (filenamePattern.matcher(file.getName()).matches()) { @@ -234,7 +237,8 @@ public class SimpleTestClassModel implements TestClassModel { } String assertTestsPresentStr = String.format( "KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File(\"%s\"), Pattern.compile(\"%s\"), %s.%s, %s%s);", - KotlinTestUtils.getFilePath(rootFile), StringUtil.escapeStringCharacters(filenamePattern.pattern()), TargetBackend.class.getSimpleName(), targetBackend.toString(), recursive, exclude + KotlinTestUtils.getFilePath(rootFile), StringUtil.escapeStringCharacters(filenamePattern.pattern()), + TargetBackend.class.getSimpleName(), targetBackend.toString(), recursive, exclude ); p.println(assertTestsPresentStr); } diff --git a/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/TestGenerationDSL.kt b/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/TestGenerationDSL.kt index f04b41b6f81..56044dd032a 100644 --- a/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/TestGenerationDSL.kt +++ b/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/TestGenerationDSL.kt @@ -47,7 +47,8 @@ class TestGroup(private val testsRoot: String, val testDataRoot: String, val tes targetBackend: TargetBackend = TargetBackend.ANY, excludeDirs: List = listOf(), filenameStartsLowerCase: Boolean? = null, - skipIgnored: Boolean = false + skipIgnored: Boolean = false, + deep: Int? = null ) { val rootFile = File("$testDataRoot/$relativeRootPath") val compiledPattern = Pattern.compile(pattern) @@ -63,7 +64,7 @@ class TestGroup(private val testsRoot: String, val testDataRoot: String, val tes SimpleTestClassModel( rootFile, recursive, excludeParentDirs, compiledPattern, filenameStartsLowerCase, testMethod, className, - targetBackend, excludeDirs, skipIgnored, testRunnerMethodName + targetBackend, excludeDirs, skipIgnored, testRunnerMethodName, deep ) } )