Drop InnerTestClasses annotation, use Java reflection
This commit is contained in:
@@ -23,7 +23,6 @@ import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.generators.di.GeneratorsFileUtil;
|
||||
import org.jetbrains.kotlin.test.InnerTestClasses;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
@@ -37,6 +36,8 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import static kotlin.KotlinPackage.single;
|
||||
|
||||
public class TestGenerator {
|
||||
|
||||
public static enum TargetBackend {
|
||||
@@ -83,7 +84,6 @@ public class TestGenerator {
|
||||
p.println("package ", suiteClassPackage, ";");
|
||||
p.println();
|
||||
p.println("import com.intellij.testFramework.TestDataPath;");
|
||||
p.println("import " + InnerTestClasses.class.getCanonicalName() + ";");
|
||||
p.println("import ", RUNNER.getCanonicalName(), ";");
|
||||
p.println("import " + JetTestUtils.class.getCanonicalName() + ";");
|
||||
if (!suiteClassPackage.equals(baseTestClassPackage)) {
|
||||
@@ -98,17 +98,18 @@ public class TestGenerator {
|
||||
p.println("/** This class is generated by {@link ", JetTestUtils.TEST_GENERATOR_NAME, "}. DO NOT MODIFY MANUALLY */");
|
||||
|
||||
generateSuppressAllWarnings(p);
|
||||
|
||||
TestClassModel model;
|
||||
if (testClassModels.size() == 1) {
|
||||
TestClassModel theOnlyTestClass = testClassModels.iterator().next();
|
||||
generateTestClass(p, new DelegatingTestClassModel(theOnlyTestClass) {
|
||||
model = new DelegatingTestClassModel(single(testClassModels)) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return suiteClassName;
|
||||
}
|
||||
}, false);
|
||||
};
|
||||
}
|
||||
else {
|
||||
generateTestClass(p, new TestClassModel() {
|
||||
model = new TestClassModel() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<TestClassModel> getInnerTestClasses() {
|
||||
@@ -141,9 +142,11 @@ public class TestGenerator {
|
||||
public String getDataPathRoot() {
|
||||
return null;
|
||||
}
|
||||
}, false);
|
||||
};
|
||||
}
|
||||
|
||||
generateTestClass(p, model, false);
|
||||
|
||||
File testSourceFile = new File(testSourceFilePath);
|
||||
GeneratorsFileUtil.writeFileIfContentChanged(testSourceFile, out.toString(), false);
|
||||
}
|
||||
@@ -153,7 +156,6 @@ public class TestGenerator {
|
||||
|
||||
generateMetadata(p, testClassModel);
|
||||
generateTestDataPath(p, testClassModel);
|
||||
generateInnerClassesAnnotation(p, testClassModel);
|
||||
p.println("@RunWith(", RUNNER.getSimpleName(), ".class)");
|
||||
|
||||
p.println("public " + staticModifier + "class ", testClassModel.getName(), " extends ", baseTestClassName, " {");
|
||||
@@ -209,26 +211,6 @@ public class TestGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateInnerClassesAnnotation(Printer p, TestClassModel testClassModel) {
|
||||
Collection<TestClassModel> innerTestClasses = testClassModel.getInnerTestClasses();
|
||||
if (innerTestClasses.isEmpty()) return;
|
||||
p.println("@InnerTestClasses({");
|
||||
|
||||
p.pushIndent();
|
||||
p.pushIndent();
|
||||
|
||||
for (TestClassModel innerTestClass : innerTestClasses) {
|
||||
if (!innerTestClass.isEmpty()) {
|
||||
p.println(testClassModel.getName(), ".", innerTestClass.getName(), ".class,");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
p.popIndent();
|
||||
p.popIndent();
|
||||
p.println("})");
|
||||
}
|
||||
|
||||
private static void generateSuppressAllWarnings(Printer p) {
|
||||
p.println("@SuppressWarnings(\"all\")");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user