JSpecify: implement tests generator and test runner with checking compliance of kotlin diagnostics and jspecify marks

This commit is contained in:
Victor Petukhov
2020-10-09 14:57:18 +03:00
parent f39e2d4a2d
commit 9dab052266
8 changed files with 349 additions and 245 deletions
@@ -25,7 +25,7 @@ public class ForeignJava8AnnotationsTestGenerated extends AbstractForeignJava8An
}
public void testAllFilesPresentInTests() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true);
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true, "jspecify");
}
@TestMetadata("checkerFramework.kt")
@@ -43,122 +43,6 @@ public class ForeignJava8AnnotationsTestGenerated extends AbstractForeignJava8An
runTest("compiler/testData/foreignAnnotationsJava8/tests/typeUseOnObject.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Jspecify extends AbstractForeignJava8AnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInJspecify() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/defaults.kt");
}
@TestMetadata("ignoreAnnotations.kt")
public void testIgnoreAnnotations() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/ignoreAnnotations.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/nonPlatformTypeParameter.kt");
}
@TestMetadata("selfType.kt")
public void testSelfType() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/selfType.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/wildcardsWithDefault.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Warnings extends AbstractForeignJava8AnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInWarnings() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/defaults.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/nonPlatformTypeParameter.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/wildcardsWithDefault.kt");
}
}
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -0,0 +1,156 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.checkers;
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("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class JspecifyAnnotationsTestGenerated extends AbstractJspecifyAnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInKotlin() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class StrictMode extends AbstractJspecifyAnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInStrictMode() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("AnnotatedBoundsOfWildcard.kt")
public void testAnnotatedBoundsOfWildcard() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/AnnotatedBoundsOfWildcard.kt");
}
@TestMetadata("Defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/Defaults.kt");
}
@TestMetadata("IgnoreAnnotations.kt")
public void testIgnoreAnnotations() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/IgnoreAnnotations.kt");
}
@TestMetadata("NonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/NonPlatformTypeParameter.kt");
}
@TestMetadata("NullnessUnspecifiedTypeParameter.kt")
public void testNullnessUnspecifiedTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/NullnessUnspecifiedTypeParameter.kt");
}
@TestMetadata("SelfType.kt")
public void testSelfType() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/SelfType.kt");
}
@TestMetadata("Simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/Simple.kt");
}
@TestMetadata("TypeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/TypeArgumentsFromParameterBounds.kt");
}
@TestMetadata("TypeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/TypeParameterBounds.kt");
}
@TestMetadata("WildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/strictMode/WildcardsWithDefault.kt");
}
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class WarnMode extends AbstractJspecifyAnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInWarnMode() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("AnnotatedBoundsOfWildcard.kt")
public void testAnnotatedBoundsOfWildcard() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/AnnotatedBoundsOfWildcard.kt");
}
@TestMetadata("Defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/Defaults.kt");
}
@TestMetadata("IgnoreAnnotations.kt")
public void testIgnoreAnnotations() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/IgnoreAnnotations.kt");
}
@TestMetadata("NonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/NonPlatformTypeParameter.kt");
}
@TestMetadata("NullnessUnspecifiedTypeParameter.kt")
public void testNullnessUnspecifiedTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/NullnessUnspecifiedTypeParameter.kt");
}
@TestMetadata("SelfType.kt")
public void testSelfType() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/SelfType.kt");
}
@TestMetadata("Simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/Simple.kt");
}
@TestMetadata("TypeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/TypeArgumentsFromParameterBounds.kt");
}
@TestMetadata("TypeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/TypeParameterBounds.kt");
}
@TestMetadata("WildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin/warnMode/WildcardsWithDefault.kt");
}
}
}
@@ -25,7 +25,7 @@ public class JavacForeignJava8AnnotationsTestGenerated extends AbstractJavacFore
}
public void testAllFilesPresentInTests() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true);
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true, "jspecify");
}
@TestMetadata("checkerFramework.kt")
@@ -43,122 +43,6 @@ public class JavacForeignJava8AnnotationsTestGenerated extends AbstractJavacFore
runTest("compiler/testData/foreignAnnotationsJava8/tests/typeUseOnObject.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Jspecify extends AbstractJavacForeignJava8AnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInJspecify() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/defaults.kt");
}
@TestMetadata("ignoreAnnotations.kt")
public void testIgnoreAnnotations() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/ignoreAnnotations.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/nonPlatformTypeParameter.kt");
}
@TestMetadata("selfType.kt")
public void testSelfType() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/selfType.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/wildcardsWithDefault.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Warnings extends AbstractJavacForeignJava8AnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInWarnings() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/defaults.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/nonPlatformTypeParameter.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/wildcardsWithDefault.kt");
}
}
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.generators.tests
import org.jetbrains.kotlin.checkers.AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest
import org.jetbrains.kotlin.checkers.AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithPsiClassReadingTest
import org.jetbrains.kotlin.checkers.AbstractForeignJava8AnnotationsTest
import org.jetbrains.kotlin.checkers.AbstractJspecifyAnnotationsTest
import org.jetbrains.kotlin.checkers.javac.AbstractJavacForeignJava8AnnotationsTest
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
import org.jetbrains.kotlin.jvm.compiler.AbstractLoadJava8Test
@@ -32,11 +33,11 @@ fun main(args: Array<String>) {
testGroupSuite(args) {
testGroup("compiler/tests-java8/tests", "compiler/testData") {
testClass<AbstractForeignJava8AnnotationsTest> {
model("foreignAnnotationsJava8/tests")
model("foreignAnnotationsJava8/tests", excludeDirs = listOf("jspecify"))
}
testClass<AbstractJavacForeignJava8AnnotationsTest> {
model("foreignAnnotationsJava8/tests")
model("foreignAnnotationsJava8/tests", excludeDirs = listOf("jspecify"))
}
testClass<AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest> {
@@ -47,6 +48,10 @@ fun main(args: Array<String>) {
model("foreignAnnotationsJava8/tests", excludeDirs = listOf("jspecify"))
}
testClass<AbstractJspecifyAnnotationsTest> {
model("foreignAnnotationsJava8/tests/jspecify/kotlin")
}
testClass<AbstractLoadJava8Test> {
model("loadJava8/compiledJava", extension = "java", testMethod = "doTestCompiledJava")
model("loadJava8/sourceJava", extension = "java", testMethod = "doTestSourceJava")