diff --git a/compiler/tests/org/jetbrains/kotlin/test/InnerTestClasses.java b/compiler/tests/org/jetbrains/kotlin/test/InnerTestClasses.java deleted file mode 100644 index 8886c495500..00000000000 --- a/compiler/tests/org/jetbrains/kotlin/test/InnerTestClasses.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.test; - -import junit.framework.TestCase; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface InnerTestClasses { - Class[] value() default {}; -} diff --git a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java index fb19b3e5b41..5a45bed3e2e 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java @@ -34,7 +34,6 @@ import com.intellij.psi.impl.PsiFileFactoryImpl; import com.intellij.rt.execution.junit.FileComparisonFailure; import com.intellij.testFramework.LightVirtualFile; import com.intellij.testFramework.TestDataFile; -import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; @@ -87,9 +86,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.jetbrains.kotlin.cli.jvm.config.ConfigPackage.addJavaSourceRoots; -import static org.jetbrains.kotlin.cli.jvm.config.ConfigPackage.addJvmClasspathRoot; -import static org.jetbrains.kotlin.cli.jvm.config.ConfigPackage.addJvmClasspathRoots; +import static org.jetbrains.kotlin.cli.jvm.config.ConfigPackage.*; import static org.jetbrains.kotlin.cli.jvm.config.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY; import static org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil.compileKotlinToDirAndGetAnalysisResult; import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory; @@ -236,9 +233,6 @@ public class JetTestUtils { } }; - @SuppressWarnings("unchecked") - private static final Class[] NO_INNER_CLASSES = ArrayUtil.EMPTY_CLASS_ARRAY; - // We suspect sequences of eight consecutive hexadecimal digits to be a package part hash code private static final Pattern STRIP_PACKAGE_PART_HASH_PATTERN = Pattern.compile("\\$([0-9a-f]{8})"); @@ -849,14 +843,9 @@ public class JetTestUtils { return false; } - private static void assertTestClassPresentByMetadata( - @NotNull Class outerClass, - @NotNull File testDataDir - ) { - InnerTestClasses innerClassesAnnotation = outerClass.getAnnotation(InnerTestClasses.class); - Class[] innerClasses = innerClassesAnnotation == null ? NO_INNER_CLASSES : innerClassesAnnotation.value(); - for (Class innerClass : innerClasses) { - TestMetadata testMetadata = innerClass.getAnnotation(TestMetadata.class); + private static void assertTestClassPresentByMetadata(@NotNull Class outerClass, @NotNull File testDataDir) { + for (Class nestedClass : outerClass.getDeclaredClasses()) { + TestMetadata testMetadata = nestedClass.getAnnotation(TestMetadata.class); if (testMetadata != null && testMetadata.value().equals(getFilePath(testDataDir))) { return; } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java index 6daf7241d0f..90534172903 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java @@ -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 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 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\")"); }