Drop InnerTestClasses annotation, use Java reflection

This commit is contained in:
Alexander Udalov
2015-04-10 02:37:56 +03:00
parent 5c06204658
commit 69e7a25b08
3 changed files with 14 additions and 73 deletions
@@ -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<? extends TestCase>[] value() default {};
}
@@ -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<? extends TestCase>[] 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<? extends TestCase>[] 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;
}