[TEST] Invert dependency between :test-generator and :tests-common modules

This is needed to provide ability for declaring new implementations of
  test generators, based on existing infrastructure, which won't add
  dependency on :compiler:tests-common

Also this commit removes implicit dependency on :compiler:tests-common
  from :compiler:tests-common-new
This commit is contained in:
Dmitriy Novozhilov
2020-12-14 13:37:33 +03:00
parent bc7e18fb8a
commit d15c7861b2
27 changed files with 59 additions and 88 deletions
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
@Nested
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/diagnostics/tests/javac")
@TestDataPath("$PROJECT_ROOT")
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
@Nested
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosticTest {
@Nested
@@ -36,3 +36,5 @@ fun main(args: Array<String>) {
}
}
}
const val TEST_GENERATOR_NAME = "GenerateNewCompilerTests.kt"
@@ -8,10 +8,11 @@ package org.jetbrains.kotlin.test.generators
import org.jetbrains.kotlin.generators.MethodGenerator
import org.jetbrains.kotlin.generators.TestGenerator
import org.jetbrains.kotlin.generators.TestGroup
import org.jetbrains.kotlin.generators.impl.*
import org.jetbrains.kotlin.generators.impl.SimpleTestClassModelTestAllFilesPresentMethodGenerator
import org.jetbrains.kotlin.generators.impl.SimpleTestMethodGenerator
import org.jetbrains.kotlin.generators.impl.SingleClassTestModelAllFilesPresentedMethodGenerator
import org.jetbrains.kotlin.generators.model.*
import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestMetadata
import org.jetbrains.kotlin.test.util.KtTestUtil
import org.jetbrains.kotlin.utils.Printer
@@ -22,7 +23,6 @@ import java.io.IOException
import java.util.*
private val METHOD_GENERATORS = listOf(
RunTestMethodGenerator,
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
SimpleTestMethodGenerator,
SingleClassTestModelAllFilesPresentedMethodGenerator
@@ -82,15 +82,8 @@ object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
suiteTestClassFqName: String,
baseTestClassFqName: String,
private val testClassModels: Collection<TestClassModel>,
methodGenerators: Map<MethodModel.Kind, MethodGenerator<*>>
private val methodGenerators: Map<MethodModel.Kind, MethodGenerator<*>>
) {
private val methodGenerators = methodGenerators.toMutableMap().apply {
val newGenerator = this.computeIfPresent(CoroutinesTestMethodModel.Kind) { _, _ ->
SimpleTestMethodGenerator
} ?: return@apply
this[CoroutinesTestMethodModel.Kind] = newGenerator
}
private val baseTestClassPackage: String = baseTestClassFqName.substringBeforeLast('.', "")
private val baseTestClassName: String = baseTestClassFqName.substringAfterLast('.', baseTestClassFqName)
private val suiteClassPackage: String = suiteTestClassFqName.substringBeforeLast('.', baseTestClassPackage)
@@ -148,7 +141,7 @@ object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
p.println("import java.io.File;")
p.println("import java.util.regex.Pattern;")
p.println()
p.println("/** This class is generated by {@link ", KotlinTestUtils.TEST_GENERATOR_NAME, "}. DO NOT MODIFY MANUALLY */")
p.println("/** This class is generated by {@link ", TEST_GENERATOR_NAME, "}. DO NOT MODIFY MANUALLY */")
p.generateSuppressAllWarnings()