Extract plugins tests to separate module with JDK 1.8

This commit is contained in:
Nikolay Krasko
2015-12-18 20:21:15 +03:00
parent 46b5305666
commit f80aaa97a6
20 changed files with 41 additions and 25 deletions
@@ -13,7 +13,6 @@
<orderEntry type="module" module-name="frontend" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="frontend.java" />
<orderEntry type="module" module-name="compiler-tests" scope="TEST" />
<orderEntry type="module" module-name="cli" />
<orderEntry type="module" module-name="light-classes" />
</component>
@@ -1,74 +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.annotation
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.codegen.CodegenTestCase
import org.jetbrains.kotlin.codegen.CodegenTestUtil
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
import java.io.File
import java.io.StringWriter
abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() {
override fun doTest(path: String) {
val testName = getTestName(true)
val fileName = path + testName + ".kt"
val supportInheritedAnnotations = testName.startsWith("inherited")
val collectorExtension = createTestEnvironment(supportInheritedAnnotations)
loadFileByFullPath(fileName)
CodegenTestUtil.generateFiles(myEnvironment, myFiles)
val actualAnnotations = KotlinTestUtils.replaceHashWithStar(collectorExtension.stringWriter.toString())
val expectedAnnotationsFile = File(path + "annotations.txt")
KotlinTestUtils.assertEqualsToFile(expectedAnnotationsFile, actualAnnotations)
}
override fun codegenTestBasePath(): String {
return "plugins/annotation-collector/testData/codegen/"
}
private fun createTestEnvironment(supportInheritedAnnotations: Boolean): AnnotationCollectorExtensionForTests {
val configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
val environment = KotlinCoreEnvironment.createForTests(testRootDisposable!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
val project = environment.project
val collectorExtension = AnnotationCollectorExtensionForTests(supportInheritedAnnotations)
ClassBuilderInterceptorExtension.registerExtension(project, collectorExtension)
myEnvironment = environment
return collectorExtension
}
private class AnnotationCollectorExtensionForTests(
supportInheritedAnnotations: Boolean
) : AnnotationCollectorExtensionBase(supportInheritedAnnotations) {
val stringWriter = StringWriter()
override fun getWriter(diagnostic: DiagnosticSink) = stringWriter
override fun closeWriter() {}
override val annotationFilterList = listOf<String>()
}
}
@@ -1,115 +0,0 @@
/*
* Copyright 2010-2016 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.annotation;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
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 */
@SuppressWarnings("all")
@TestMetadata("plugins/annotation-collector/testData/collectToFile")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProcessorBoxTest {
public void testAllFilesPresentInCollectToFile() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/annotation-collector/testData/collectToFile"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("annotatedGettersSetters")
public void testAnnotatedGettersSetters() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/");
doTest(fileName);
}
@TestMetadata("annotationInSameFile")
public void testAnnotationInSameFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/annotationInSameFile/");
doTest(fileName);
}
@TestMetadata("anonymousClasses")
public void testAnonymousClasses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/anonymousClasses/");
doTest(fileName);
}
@TestMetadata("classAnnotations")
public void testClassAnnotations() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/classAnnotations/");
doTest(fileName);
}
@TestMetadata("constructors")
public void testConstructors() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/constructors/");
doTest(fileName);
}
@TestMetadata("defaultPackage")
public void testDefaultPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/defaultPackage/");
doTest(fileName);
}
@TestMetadata("fieldAnnotations")
public void testFieldAnnotations() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/fieldAnnotations/");
doTest(fileName);
}
@TestMetadata("inheritedSimple")
public void testInheritedSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedSimple/");
doTest(fileName);
}
@TestMetadata("inheritedTopLevel")
public void testInheritedTopLevel() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/");
doTest(fileName);
}
@TestMetadata("localClasses")
public void testLocalClasses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/localClasses/");
doTest(fileName);
}
@TestMetadata("methodAnnotations")
public void testMethodAnnotations() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/methodAnnotations/");
doTest(fileName);
}
@TestMetadata("nestedClasses")
public void testNestedClasses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/nestedClasses/");
doTest(fileName);
}
@TestMetadata("platformStatic")
public void testPlatformStatic() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/platformStatic/");
doTest(fileName);
}
}