Add 'not linked' kind of spec tests
This commit is contained in:
+35
-21
@@ -9,8 +9,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.spec.DiagnosticSpecTestValidator
|
||||
import org.jetbrains.kotlin.spec.SpecTestValidationException
|
||||
import org.jetbrains.kotlin.spec.validators.*
|
||||
import org.jetbrains.kotlin.test.*
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
@@ -19,38 +18,50 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() {
|
||||
companion object {
|
||||
// map of pairs: source helper filename - target helper filename
|
||||
private val directives = mapOf(
|
||||
"WITH_BASIC_TYPES" to Pair("basicTypes.kt", "BASIC_TYPES.kt"),
|
||||
"WITH_CLASSES" to Pair("classes.kt", "CLASSES.kt"),
|
||||
"WITH_ENUM_CLASSES" to Pair("enumClasses.kt", "ENUM_CLASSES.kt"),
|
||||
"WITH_SEALED_CLASSES" to Pair("sealedClasses.kt", "SEALED_CLASSES.kt"),
|
||||
"WITH_FUNS" to Pair("funs.kt", "FUNS.kt"),
|
||||
"WITH_OBJECTS" to Pair("objects.kt", "OBJECTS.kt"),
|
||||
"WITH_TYPEALIASES" to Pair("typeAliases.kt", "TYPE_ALIASES.kt")
|
||||
"WITH_BASIC_TYPES" to "basicTypes.kt",
|
||||
"WITH_CLASSES" to "classes.kt",
|
||||
"WITH_ENUM_CLASSES" to "enumClasses.kt",
|
||||
"WITH_SEALED_CLASSES" to "sealedClasses.kt",
|
||||
"WITH_FUNCTIONS" to "functions.kt",
|
||||
"WITH_OBJECTS" to "objects.kt",
|
||||
"WITH_TYPEALIASES" to "typeAliases.kt",
|
||||
"WITH_CONTRACT_FUNCTIONS" to "contractFunctions.kt"
|
||||
)
|
||||
|
||||
private const val MODULE_PATH = "./compiler/tests-spec"
|
||||
private const val HELPERS_PATH = "$MODULE_PATH/testData/helpers/diagnostics"
|
||||
private val withoutDescriptorsTestGroups = listOf(
|
||||
"linked/when-expression"
|
||||
)
|
||||
|
||||
private const val MODULE_PATH = "compiler/tests-spec"
|
||||
private const val DIAGNOSTICS_TESTDATA_PATH = "$MODULE_PATH/testData/diagnostics"
|
||||
private const val HELPERS_PATH = "$DIAGNOSTICS_TESTDATA_PATH/helpers"
|
||||
}
|
||||
|
||||
private lateinit var testValidator: DiagnosticSpecTestValidator
|
||||
private lateinit var testValidator: AbstractSpecTestValidator<out AbstractSpecTest>
|
||||
private var skipDescriptors = true
|
||||
|
||||
private fun checkDirective(directive: String, testFiles: List<TestFile>) =
|
||||
testFiles.any { it.directives.contains(directive) }
|
||||
|
||||
private fun enableDescriptorsGenerationIfNeeded(testDataFile: File) {
|
||||
skipDescriptors = withoutDescriptorsTestGroups.any {
|
||||
val testGroupAbsolutePath = File("$DIAGNOSTICS_TESTDATA_PATH/$it").absolutePath
|
||||
testDataFile.absolutePath.startsWith(testGroupAbsolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getConfigurationKind() = ConfigurationKind.ALL
|
||||
|
||||
override fun skipDescriptorsValidation(): Boolean = true
|
||||
override fun skipDescriptorsValidation() = skipDescriptors
|
||||
|
||||
override fun getKtFiles(testFiles: List<TestFile>, includeExtras: Boolean): List<KtFile> {
|
||||
val ktFiles = super.getKtFiles(testFiles, includeExtras) as ArrayList
|
||||
|
||||
if (includeExtras) {
|
||||
for ((name, filenames) in directives) {
|
||||
for ((name, filename) in directives) {
|
||||
if (checkDirective(name, testFiles)) {
|
||||
val (sourceFilename, targetFilename) = filenames
|
||||
val declarations = File("$HELPERS_PATH/$sourceFilename").readText()
|
||||
|
||||
ktFiles.add(KotlinTestUtils.createFile(targetFilename, declarations, project))
|
||||
val declarations = File("$HELPERS_PATH/$filename").readText()
|
||||
ktFiles.add(KotlinTestUtils.createFile(filename, declarations, project))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +70,9 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() {
|
||||
}
|
||||
|
||||
override fun analyzeAndCheck(testDataFile: File, files: List<TestFile>) {
|
||||
testValidator = DiagnosticSpecTestValidator(testDataFile)
|
||||
enableDescriptorsGenerationIfNeeded(testDataFile)
|
||||
|
||||
testValidator = AbstractSpecTestValidator.getInstanceByType(testDataFile)
|
||||
|
||||
try {
|
||||
testValidator.parseTestInfo()
|
||||
@@ -80,12 +93,13 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() {
|
||||
moduleBindings: Map<TestModule?, BindingContext>,
|
||||
languageVersionSettingsByModule: Map<TestModule?, LanguageVersionSettings>
|
||||
) {
|
||||
val diagnosticValidator = DiagnosticTestTypeValidator(testFiles)
|
||||
try {
|
||||
testValidator.validateTestType(testFiles)
|
||||
testValidator.validateTestType(computedTestType = diagnosticValidator.computeTestType())
|
||||
} catch (e: SpecTestValidationException) {
|
||||
Assert.fail(e.description)
|
||||
} finally {
|
||||
testValidator.printDiagnosticStatistic()
|
||||
diagnosticValidator.printDiagnosticStatistic()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+432
-419
@@ -26,547 +26,560 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDiagnostics() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true, "helpers");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class S_16_30_when_expression extends AbstractDiagnosticsTestSpec {
|
||||
public static class Linked extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInS_16_30_when_expression() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
public void testAllFilesPresentInLinked() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_11 extends AbstractDiagnosticsTestSpec {
|
||||
public static class When_expression extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_11() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
public void testAllFilesPresentInWhen_expression() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
public static class P_11 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/1.1.kt");
|
||||
public void testAllFilesPresentInP_11() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/1.2.kt");
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/3.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("6.1.kt")
|
||||
public void test6_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/6.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/7.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.1.kt")
|
||||
public void test8_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.2.kt")
|
||||
public void test8_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.3.kt")
|
||||
public void test8_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.3.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/3.1.kt");
|
||||
}
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("6.1.kt")
|
||||
public void test6_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/6.1.kt");
|
||||
}
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/7.1.kt");
|
||||
}
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.1.kt")
|
||||
public void test8_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/8.1.kt");
|
||||
}
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.2.kt")
|
||||
public void test8_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/8.2.kt");
|
||||
}
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/3.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.3.kt")
|
||||
public void test8_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/8.3.kt");
|
||||
}
|
||||
@TestMetadata("6.1.kt")
|
||||
public void test6_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/6.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/7.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.1.kt")
|
||||
public void test8_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.2.kt")
|
||||
public void test8_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.3.kt")
|
||||
public void test8_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.3.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
public static class P_2 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/1.1.kt");
|
||||
public void testAllFilesPresentInP_2() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/1.2.kt");
|
||||
}
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/1.3.kt");
|
||||
}
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/3.1.kt");
|
||||
}
|
||||
@TestMetadata("3.2.kt")
|
||||
public void test3_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("6.1.kt")
|
||||
public void test6_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/6.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/7.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.1.kt")
|
||||
public void test8_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/8.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.2.kt")
|
||||
public void test8_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/8.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("8.3.kt")
|
||||
public void test8_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/8.3.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_2 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_2() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
public static class P_3 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos/3.1.kt");
|
||||
public void testAllFilesPresentInP_3() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("3.2.kt")
|
||||
public void test3_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos/3.2.kt");
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("2.1.kt")
|
||||
public void test2_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("2.2.kt")
|
||||
public void test2_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.2.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("2.1.kt")
|
||||
public void test2_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("2.2.kt")
|
||||
public void test2_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("2.3.kt")
|
||||
public void test2_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.3.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_3 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_3() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
public static class P_5 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg/1.1.kt");
|
||||
public void testAllFilesPresentInP_5() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("2.1.kt")
|
||||
public void test2_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg/2.1.kt");
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg/1.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("2.2.kt")
|
||||
public void test2_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg/2.2.kt");
|
||||
}
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos/1.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
public static class P_6 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/1.1.kt");
|
||||
public void testAllFilesPresentInP_6() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("2.1.kt")
|
||||
public void test2_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/2.1.kt");
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg/1.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("2.2.kt")
|
||||
public void test2_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/2.2.kt");
|
||||
}
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("2.3.kt")
|
||||
public void test2_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/2.3.kt");
|
||||
}
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos/1.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_5 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_5() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/neg")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
public static class P_7 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/neg/1.1.kt");
|
||||
public void testAllFilesPresentInP_7() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.2.kt")
|
||||
public void test3_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.1.kt")
|
||||
public void test5_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.2.kt")
|
||||
public void test5_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/7.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.4.kt")
|
||||
public void test1_4() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.4.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.2.kt")
|
||||
public void test3_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.1.kt")
|
||||
public void test5_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.2.kt")
|
||||
public void test5_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/7.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/pos")
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
public static class P_9 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/pos/1.1.kt");
|
||||
public void testAllFilesPresentInP_9() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_6 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_6() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.4.kt")
|
||||
public void test1_4() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.4.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/neg/1.1.kt");
|
||||
}
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/pos/1.1.kt");
|
||||
}
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.3.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@TestMetadata("1.4.kt")
|
||||
public void test1_4() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.4.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_7 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_7() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/3.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.2.kt")
|
||||
public void test3_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/3.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.1.kt")
|
||||
public void test5_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/5.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.2.kt")
|
||||
public void test5_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/5.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/7.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.4.kt")
|
||||
public void test1_4() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.4.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.1.kt")
|
||||
public void test3_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/3.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("3.2.kt")
|
||||
public void test3_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/3.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.1.kt")
|
||||
public void test5_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/5.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("5.2.kt")
|
||||
public void test5_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/5.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("7.1.kt")
|
||||
public void test7_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/7.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_9 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_9() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.4.kt")
|
||||
public void test1_4() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.4.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.2.kt")
|
||||
public void test1_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.3.kt")
|
||||
public void test1_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("1.4.kt")
|
||||
public void test1_4() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.4.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.checkers.AbstractDiagnosticsTestSpec
|
||||
fun main(args: Array<String>) {
|
||||
testGroup("compiler/tests-spec/tests", "compiler/tests-spec/testData") {
|
||||
testClass<AbstractDiagnosticsTestSpec> {
|
||||
model("diagnostics")
|
||||
model("diagnostics", excludeDirs = listOf("helpers"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.spec
|
||||
|
||||
import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import java.io.File
|
||||
|
||||
class DiagnosticSpecTestValidator(testDataFile: File) : SpecTestValidator(testDataFile, TestArea.DIAGNOSTICS) {
|
||||
private lateinit var diagnostics: MutableList<Diagnostic>
|
||||
private lateinit var diagnosticStats: MutableMap<String, Int>
|
||||
private lateinit var diagnosticSeverityStats: MutableMap<Severity, Int>
|
||||
|
||||
private fun collectDiagnosticStatistic() {
|
||||
diagnosticSeverityStats = mutableMapOf()
|
||||
|
||||
diagnostics.forEach {
|
||||
val severity = it.factory.severity
|
||||
|
||||
if (diagnosticSeverityStats.contains(severity)) {
|
||||
diagnosticSeverityStats[severity] = diagnosticSeverityStats[severity]!! + 1
|
||||
} else {
|
||||
diagnosticSeverityStats[severity] = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeTestType(): TestType {
|
||||
return if (Severity.ERROR in diagnosticSeverityStats) TestType.NEGATIVE else TestType.POSITIVE
|
||||
}
|
||||
|
||||
private fun collectDiagnostics(files: List<BaseDiagnosticsTest.TestFile>) {
|
||||
diagnostics = mutableListOf()
|
||||
diagnosticStats = mutableMapOf()
|
||||
|
||||
files.forEach {
|
||||
it.actualDiagnostics.forEach {
|
||||
val diagnosticName = it.diagnostic.factory.name
|
||||
|
||||
if (diagnosticStats.contains(diagnosticName)) {
|
||||
diagnosticStats[diagnosticName] = diagnosticStats[diagnosticName]!! + 1
|
||||
} else {
|
||||
diagnosticStats[diagnosticName] = 1
|
||||
}
|
||||
|
||||
diagnostics.add(it.diagnostic)
|
||||
}
|
||||
}
|
||||
|
||||
collectDiagnosticStatistic()
|
||||
}
|
||||
|
||||
fun validateTestType(files: List<BaseDiagnosticsTest.TestFile>) {
|
||||
if (!this::diagnostics.isInitialized) this.collectDiagnostics(files)
|
||||
|
||||
validateTestType(computeTestType())
|
||||
}
|
||||
|
||||
fun printDiagnosticStatistic() {
|
||||
val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain"
|
||||
|
||||
println("DIAGNOSTICS: $diagnostics")
|
||||
}
|
||||
}
|
||||
@@ -1,323 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.spec
|
||||
|
||||
import java.io.File
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
enum class TestType(val type: String) {
|
||||
POSITIVE("pos"),
|
||||
NEGATIVE("neg");
|
||||
|
||||
companion object {
|
||||
private val map = TestType.values().associateBy(TestType::type)
|
||||
fun fromValue(type: String) = map[type]
|
||||
}
|
||||
}
|
||||
|
||||
enum class TestArea {
|
||||
PSI,
|
||||
DIAGNOSTICS,
|
||||
CODEGEN
|
||||
}
|
||||
|
||||
interface SpecTestInfoElementType {
|
||||
val valuePattern: Pattern?
|
||||
val required: Boolean
|
||||
}
|
||||
|
||||
enum class SpecTestFileInfoElementType(
|
||||
override val valuePattern: Pattern? = null,
|
||||
override val required: Boolean = false
|
||||
) : SpecTestInfoElementType {
|
||||
SECTION(
|
||||
valuePattern = Pattern.compile("""(?<number>(?:${SpecTestValidator.INTEGER_REGEX})(?:\.${SpecTestValidator.INTEGER_REGEX})*)(?<name>.*?)"""),
|
||||
required = true
|
||||
),
|
||||
PARAGRAPH(required = true),
|
||||
SENTENCE(
|
||||
valuePattern = Pattern.compile("""\[(?<number>${SpecTestValidator.INTEGER_REGEX})\](?<text>.*?)"""),
|
||||
required = true
|
||||
),
|
||||
NUMBER(required = true),
|
||||
DESCRIPTION(required = true),
|
||||
ISSUES(valuePattern = Pattern.compile("""(KT-[1-9]\d*)(,\s*KT-[1-9]\d*)*""")),
|
||||
UNEXPECTED_BEHAVIOUR,
|
||||
DISCUSSION,
|
||||
NOTE
|
||||
}
|
||||
|
||||
enum class SpecTestCaseInfoElementType(
|
||||
override val valuePattern: Pattern? = null,
|
||||
override val required: Boolean = false
|
||||
) : SpecTestInfoElementType {
|
||||
CASE_DESCRIPTION(required = true),
|
||||
ISSUES(valuePattern = SpecTestFileInfoElementType.ISSUES.valuePattern),
|
||||
UNEXPECTED_BEHAVIOUR,
|
||||
DISCUSSION,
|
||||
NOTE
|
||||
}
|
||||
|
||||
data class SpecTestInfoElementContent(
|
||||
val content: String,
|
||||
val additionalMatcher: Matcher? = null
|
||||
)
|
||||
|
||||
data class SpecTestCase(
|
||||
val number: Int,
|
||||
val description: String,
|
||||
val unexpectedBehavior: Boolean,
|
||||
val issues: List<String>?
|
||||
)
|
||||
|
||||
class SpecTest(
|
||||
val testArea: TestArea,
|
||||
val testType: TestType,
|
||||
val sectionNumber: String,
|
||||
val sectionName: String,
|
||||
val paragraphNumber: Int,
|
||||
val sentenceNumber: Int,
|
||||
val sentence: String? = null,
|
||||
val testNumber: Int,
|
||||
val description: String? = null,
|
||||
val cases: List<SpecTestCase>? = null,
|
||||
val unexpectedBehavior: Boolean? = null,
|
||||
val issues: Set<String>? = null
|
||||
) {
|
||||
fun checkConsistency(other: SpecTest): Boolean {
|
||||
return this.testArea == other.testArea
|
||||
&& this.testType == other.testType
|
||||
&& this.sectionNumber == other.sectionNumber
|
||||
&& this.testNumber == other.testNumber
|
||||
&& this.paragraphNumber == other.paragraphNumber
|
||||
&& this.sentenceNumber == other.sentenceNumber
|
||||
}
|
||||
}
|
||||
|
||||
enum class SpecTestValidationFailedReason(val description: String) {
|
||||
FILENAME_NOT_VALID(
|
||||
"Incorrect test filename or folder name.${SpecTestValidator.lineSeparator}" +
|
||||
"It must match the following path pattern: " +
|
||||
"testsData/<diagnostic|psi|codegen>/s<sectionNumber>_<sectionName>/p-<paragraph>/<pos|neg>/<sentence>_<testNumber>.kt " +
|
||||
"(example: testsData/diagnostic/s-16.30_when-expression/p-3/pos/1.3.kt)"
|
||||
),
|
||||
TESTINFO_NOT_VALID("Test info is incorrect."),
|
||||
FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY("Test info from filepath and file content is not consistency"),
|
||||
TEST_IS_NOT_POSITIVE("Test is not positive because it contains error elements (PsiErrorElement or diagnostic with error severity)."),
|
||||
TEST_IS_NOT_NEGATIVE("Test is not negative because it not contains error type elements (PsiErrorElement or diagnostic with error severity)."),
|
||||
UNKNOWN("Unknown validation error.")
|
||||
}
|
||||
|
||||
class SpecTestValidationException(reason: SpecTestValidationFailedReason, details: String = "") : Exception() {
|
||||
val description = "${reason.description} $details"
|
||||
}
|
||||
|
||||
typealias SpecTestInfoElements<T> = Map<T, SpecTestInfoElementContent>
|
||||
|
||||
abstract class SpecTestValidator(private val testDataFile: File, private val testArea: TestArea) {
|
||||
private lateinit var testInfoByFilename: SpecTest
|
||||
private lateinit var testInfoByContent: SpecTest
|
||||
private val testInfo by lazy { testInfoByContent }
|
||||
|
||||
companion object {
|
||||
const val INTEGER_REGEX = """[1-9]\d*"""
|
||||
private const val SINGLELINE_COMMENT_REGEX = """\/\/\s*%s"""
|
||||
private const val MULTILINE_COMMENT_REGEX = """\/\*\s*%s\s+\*\/"""
|
||||
|
||||
val lineSeparator: String = System.lineSeparator()
|
||||
private val testCaseInfoRegex = """(?<infoElements>CASE DESCRIPTION:[\s\S]*?$lineSeparator)"""
|
||||
private val testAreaRegex = """(?<testArea>${TestArea.values().joinToString("|")})"""
|
||||
private val testTypeRegex = """(?<testType>${TestType.values().joinToString("|")})"""
|
||||
private val testInfoElementPattern: Pattern = Pattern.compile("""\s*(?<name>[A-Z ]*?):\s*(?<value>.*?)$lineSeparator""")
|
||||
private val pathSeparator = Pattern.quote(File.separator)
|
||||
|
||||
val testPathPattern: Pattern =
|
||||
Pattern.compile("""^.*?$pathSeparator(?<testArea>diagnostics|psi|codegen)${pathSeparator}s-(?<sectionNumber>(?:$INTEGER_REGEX)(?:\.$INTEGER_REGEX)*)_(?<sectionName>[\w-]+)${pathSeparator}p-(?<paragraphNumber>$INTEGER_REGEX)$pathSeparator(?<testType>pos|neg)$pathSeparator(?<sentenceNumber>$INTEGER_REGEX)\.(?<testNumber>$INTEGER_REGEX)\.kt$""")
|
||||
val testInfoPattern: Pattern =
|
||||
Pattern.compile(MULTILINE_COMMENT_REGEX.format("""KOTLIN $testAreaRegex SPEC TEST \($testTypeRegex\)$lineSeparator(?<infoElements>[\s\S]*?$lineSeparator)"""))
|
||||
val testCaseInfoSinglelinePattern: Pattern = Pattern.compile(SINGLELINE_COMMENT_REGEX.format(testCaseInfoRegex))
|
||||
val testCaseInfoMultilinePattern: Pattern = Pattern.compile(MULTILINE_COMMENT_REGEX.format(testCaseInfoRegex))
|
||||
|
||||
private fun getTestInfo(
|
||||
testInfoMatcher: Matcher,
|
||||
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
|
||||
testCases: List<SpecTestCase>,
|
||||
unexpectedBehavior: Boolean = false,
|
||||
issues: Set<String>? = null
|
||||
): SpecTest {
|
||||
val sectionMatcher = testInfoElements[SpecTestFileInfoElementType.SECTION]!!.additionalMatcher!!
|
||||
val sentenceMatcher = testInfoElements[SpecTestFileInfoElementType.SENTENCE]!!.additionalMatcher!!
|
||||
|
||||
return SpecTest(
|
||||
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
|
||||
TestType.valueOf(testInfoMatcher.group("testType")),
|
||||
sectionMatcher.group("number"),
|
||||
sectionMatcher.group("name"),
|
||||
testInfoElements[SpecTestFileInfoElementType.PARAGRAPH]!!.content.toInt(),
|
||||
sentenceMatcher.group("number").toInt(),
|
||||
sentenceMatcher.group("text"),
|
||||
testInfoElements[SpecTestFileInfoElementType.NUMBER]!!.content.toInt(),
|
||||
testInfoElements[SpecTestFileInfoElementType.DESCRIPTION]!!.content,
|
||||
testCases,
|
||||
unexpectedBehavior,
|
||||
issues
|
||||
)
|
||||
}
|
||||
|
||||
private fun getTestInfo(testInfoMatcher: Matcher): SpecTest {
|
||||
return SpecTest(
|
||||
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
|
||||
TestType.fromValue(testInfoMatcher.group("testType"))!!,
|
||||
testInfoMatcher.group("sectionNumber"),
|
||||
testInfoMatcher.group("sectionName"),
|
||||
testInfoMatcher.group("paragraphNumber").toInt(),
|
||||
testInfoMatcher.group("sentenceNumber").toInt(),
|
||||
testNumber = testInfoMatcher.group("testNumber").toInt()
|
||||
)
|
||||
}
|
||||
|
||||
private fun parseIssues(issues: SpecTestInfoElementContent?) = issues?.content?.split(",")
|
||||
|
||||
private fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) = SpecTestCase(
|
||||
1,
|
||||
description = testInfoElements[SpecTestFileInfoElementType.DESCRIPTION]!!.content,
|
||||
unexpectedBehavior = testInfoElements.contains(SpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR),
|
||||
issues = parseIssues(testInfoElements[SpecTestFileInfoElementType.ISSUES])
|
||||
)
|
||||
|
||||
private fun getTestCasesInfo(testCaseInfoMatcher: Matcher, infoElements: SpecTestInfoElements<SpecTestInfoElementType>): List<SpecTestCase> {
|
||||
val testCases = mutableListOf<SpecTestCase>()
|
||||
var testCasesCounter = 1
|
||||
|
||||
while (testCaseInfoMatcher.find()) {
|
||||
val caseInfoElements = getTestInfoElements<SpecTestCaseInfoElementType>(testCaseInfoMatcher.group("infoElements"))
|
||||
|
||||
testCases.add(
|
||||
SpecTestCase(
|
||||
testCasesCounter++,
|
||||
caseInfoElements[SpecTestCaseInfoElementType.CASE_DESCRIPTION]!!.content,
|
||||
caseInfoElements.contains(SpecTestCaseInfoElementType.UNEXPECTED_BEHAVIOUR),
|
||||
parseIssues(caseInfoElements[SpecTestCaseInfoElementType.ISSUES])
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (testCases.isEmpty()) testCases.add(getSingleTestCase(infoElements))
|
||||
|
||||
return testCases
|
||||
}
|
||||
|
||||
private inline fun <reified T : Enum<T>> getTestInfoElements(testInfoElements: String): SpecTestInfoElements<SpecTestInfoElementType> {
|
||||
val testInfoElementsMap = mutableMapOf<SpecTestInfoElementType, SpecTestInfoElementContent>()
|
||||
val testInfoElementMatcher = testInfoElementPattern.matcher(testInfoElements)
|
||||
|
||||
while (testInfoElementMatcher.find()) {
|
||||
val testInfoOriginalElementName = testInfoElementMatcher.group("name")
|
||||
val testInfoElementName: SpecTestInfoElementType
|
||||
try {
|
||||
testInfoElementName = enumValueOf<T>(testInfoOriginalElementName.replace(" ", "_")) as SpecTestInfoElementType
|
||||
} catch (e: IllegalArgumentException) {
|
||||
throw SpecTestValidationException(
|
||||
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
|
||||
"Unknown '$testInfoOriginalElementName' test info element name."
|
||||
)
|
||||
}
|
||||
val testInfoElementValue = testInfoElementMatcher.group("value")
|
||||
val testInfoElementValueMatcher = testInfoElementName.valuePattern?.matcher(testInfoElementValue)
|
||||
|
||||
if (testInfoElementValueMatcher != null && !testInfoElementValueMatcher.find())
|
||||
throw SpecTestValidationException(
|
||||
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
|
||||
"'$testInfoElementValue' in '$testInfoElementName' is not parsed."
|
||||
)
|
||||
|
||||
testInfoElementsMap[testInfoElementName] = SpecTestInfoElementContent(testInfoElementValue, testInfoElementValueMatcher)
|
||||
}
|
||||
|
||||
enumValues<T>().forEach {
|
||||
it as SpecTestInfoElementType
|
||||
if (it.required && !testInfoElementsMap.contains(it)) {
|
||||
throw SpecTestValidationException(
|
||||
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
|
||||
"$it in case or test info is required."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return testInfoElementsMap
|
||||
}
|
||||
|
||||
private fun getIssues(testCases: List<SpecTestCase>, testIssues: List<String>?): Set<String> {
|
||||
val issues = mutableSetOf<String>()
|
||||
|
||||
testCases.forEach {
|
||||
if (it.issues != null) issues.addAll(it.issues)
|
||||
}
|
||||
|
||||
if (testIssues != null) issues.addAll(testIssues)
|
||||
|
||||
return issues
|
||||
}
|
||||
}
|
||||
|
||||
fun parseTestInfo() {
|
||||
val testInfoByFilenameMatcher = testPathPattern.matcher(testDataFile.path)
|
||||
|
||||
if (!testInfoByFilenameMatcher.find())
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID)
|
||||
|
||||
val fileContent = testDataFile.readText()
|
||||
val testInfoByContentMatcher = testInfoPattern.matcher(fileContent)
|
||||
|
||||
if (!testInfoByContentMatcher.find())
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID)
|
||||
|
||||
val testInfoElements = getTestInfoElements<SpecTestFileInfoElementType>(testInfoByContentMatcher.group("infoElements"))
|
||||
val testCases = getTestCasesInfo(testCaseInfoSinglelinePattern.matcher(fileContent), testInfoElements) +
|
||||
getTestCasesInfo(testCaseInfoMultilinePattern.matcher(fileContent), testInfoElements)
|
||||
|
||||
testInfoByFilename = getTestInfo(testInfoByFilenameMatcher)
|
||||
testInfoByContent = getTestInfo(
|
||||
testInfoByContentMatcher,
|
||||
testInfoElements,
|
||||
testCases = testCases,
|
||||
unexpectedBehavior = testInfoElements.contains(SpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR) || testCases.any { it.unexpectedBehavior },
|
||||
issues = getIssues(testCases, parseIssues(testInfoElements[SpecTestFileInfoElementType.ISSUES]))
|
||||
)
|
||||
|
||||
if (!testInfoByFilename.checkConsistency(testInfoByContent))
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY)
|
||||
}
|
||||
|
||||
protected fun validateTestType(computedTestType: TestType) {
|
||||
if (computedTestType != testInfo.testType) {
|
||||
val isNotNegative = computedTestType == TestType.POSITIVE && testInfo.testType == TestType.NEGATIVE
|
||||
val isNotPositive = computedTestType == TestType.NEGATIVE && testInfo.testType == TestType.POSITIVE
|
||||
val reason = when {
|
||||
isNotNegative -> SpecTestValidationFailedReason.TEST_IS_NOT_NEGATIVE
|
||||
isNotPositive -> SpecTestValidationFailedReason.TEST_IS_NOT_POSITIVE
|
||||
else -> SpecTestValidationFailedReason.UNKNOWN
|
||||
}
|
||||
throw SpecTestValidationException(reason)
|
||||
}
|
||||
}
|
||||
|
||||
fun printTestInfo() {
|
||||
println("--------------------------------------------------")
|
||||
if (testInfoByContent.unexpectedBehavior!!)
|
||||
println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)")
|
||||
println("$testArea ${testInfoByFilename.testType} SPEC TEST")
|
||||
println("SECTION: ${testInfoByFilename.sectionNumber} ${testInfoByContent.sectionName} (paragraph: ${testInfoByFilename.paragraphNumber})")
|
||||
println("SENTENCE ${testInfoByContent.sentenceNumber}: ${testInfoByContent.sentence}")
|
||||
println("TEST NUMBER: ${testInfoByContent.testNumber}")
|
||||
println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}")
|
||||
println("DESCRIPTION: ${testInfoByContent.description}")
|
||||
if (testInfoByContent.issues!!.isNotEmpty()) {
|
||||
println("LINKED ISSUES: ${testInfoByContent.issues!!.joinToString(", ")}")
|
||||
}
|
||||
}
|
||||
}
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
|
||||
|
||||
import java.io.File
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
enum class TestType(val type: String) {
|
||||
POSITIVE("pos"),
|
||||
NEGATIVE("neg");
|
||||
|
||||
companion object {
|
||||
private val map = TestType.values().associateBy(TestType::type)
|
||||
fun fromValue(type: String) = map[type]
|
||||
}
|
||||
}
|
||||
|
||||
enum class TestArea {
|
||||
PSI,
|
||||
DIAGNOSTICS,
|
||||
CODEGEN
|
||||
}
|
||||
|
||||
enum class SpecTestLinkedType {
|
||||
LINKED,
|
||||
NOT_LINKED
|
||||
}
|
||||
|
||||
interface SpecTestInfoElementType {
|
||||
val valuePattern: Pattern?
|
||||
val required: Boolean
|
||||
}
|
||||
|
||||
enum class SpecTestCaseInfoElementType(
|
||||
override val valuePattern: Pattern? = null,
|
||||
override val required: Boolean = false
|
||||
) : SpecTestInfoElementType {
|
||||
CASE_DESCRIPTION(required = true),
|
||||
ISSUES(valuePattern = LinkedSpecTestFileInfoElementType.ISSUES.valuePattern),
|
||||
UNEXPECTED_BEHAVIOUR,
|
||||
DISCUSSION,
|
||||
NOTE
|
||||
}
|
||||
|
||||
data class SpecTestInfoElementContent(
|
||||
val content: String,
|
||||
val additionalMatcher: Matcher? = null
|
||||
)
|
||||
|
||||
data class SpecTestCase(
|
||||
val number: Int,
|
||||
val description: String,
|
||||
val unexpectedBehavior: Boolean,
|
||||
val issues: List<String>?
|
||||
)
|
||||
|
||||
enum class SpecTestValidationFailedReason(val description: String) {
|
||||
FILENAME_NOT_VALID("Incorrect test filename or folder name."),
|
||||
TESTINFO_NOT_VALID("Test info is incorrect."),
|
||||
FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY("Test info from filepath and file content is not consistency"),
|
||||
TEST_IS_NOT_POSITIVE("Test is not positive because it contains error elements (PsiErrorElement or diagnostic with error severity)."),
|
||||
TEST_IS_NOT_NEGATIVE("Test is not negative because it not contains error type elements (PsiErrorElement or diagnostic with error severity)."),
|
||||
UNKNOWN("Unknown validation error.")
|
||||
}
|
||||
|
||||
class SpecTestValidationException(reason: SpecTestValidationFailedReason, details: String = "") : Exception() {
|
||||
val description = "${reason.description} $details"
|
||||
}
|
||||
|
||||
typealias SpecTestInfoElements<T> = Map<T, SpecTestInfoElementContent>
|
||||
|
||||
interface SpecTestValidatorHelperObject {
|
||||
val pathPartRegex: String
|
||||
val filenameRegex: String
|
||||
fun getPathPattern(): Pattern
|
||||
}
|
||||
|
||||
abstract class AbstractSpecTest(
|
||||
val testArea: TestArea,
|
||||
val testType: TestType,
|
||||
val section: String,
|
||||
val testNumber: Int,
|
||||
val description: String? = null,
|
||||
val cases: List<SpecTestCase>? = null,
|
||||
val unexpectedBehavior: Boolean? = null,
|
||||
val issues: Set<String>? = null
|
||||
) {
|
||||
abstract fun checkConsistency(other: AbstractSpecTest): Boolean
|
||||
}
|
||||
|
||||
abstract class AbstractSpecTestValidator<T : AbstractSpecTest>(private val testDataFile: File) {
|
||||
val testInfo by lazy { testInfoByContent }
|
||||
|
||||
protected lateinit var testInfoByFilename: T
|
||||
protected lateinit var testInfoByContent: T
|
||||
abstract val testPathPattern: Pattern
|
||||
abstract val testInfoPattern: Pattern
|
||||
|
||||
companion object {
|
||||
const val ISSUE_TRACKER = "https://youtrack.jetbrains.com/issue/"
|
||||
const val INTEGER_REGEX = """[1-9]\d*"""
|
||||
const val MULTILINE_COMMENT_REGEX = """\/\*\s*%s\s+\*\/\n*"""
|
||||
private const val SINGLELINE_COMMENT_REGEX = """\/\/\s*%s\n*"""
|
||||
|
||||
val pathSeparator: String = Pattern.quote(File.separator)
|
||||
val lineSeparator: String = System.lineSeparator()
|
||||
val testAreaRegex = """(?<testArea>${TestArea.values().joinToString("|")})"""
|
||||
val testTypeRegex = """(?<testType>${TestType.values().joinToString("|")})"""
|
||||
val dirsByLinkedType = mapOf(
|
||||
SpecTestLinkedType.LINKED to "linked",
|
||||
SpecTestLinkedType.NOT_LINKED to "notLinked"
|
||||
)
|
||||
private val testInfoElementPattern: Pattern = Pattern.compile("""\s*(?<name>[A-Z ]+?)(?::\s*(?<value>.*?))?$lineSeparator""")
|
||||
private val testCaseInfoRegex = """(?<infoElements>CASE DESCRIPTION:[\s\S]*?$lineSeparator)$lineSeparator*"""
|
||||
private val testPathBaseRegexTemplate = """^.*?$pathSeparator(?<testArea>diagnostics|psi|codegen)$pathSeparator%s"""
|
||||
val testPathRegexTemplate = """$testPathBaseRegexTemplate$pathSeparator(?<testType>pos|neg)/%s$"""
|
||||
val testCaseInfoSingleLinePattern: Pattern = Pattern.compile(SINGLELINE_COMMENT_REGEX.format(testCaseInfoRegex))
|
||||
val testCaseInfoMultilinePattern: Pattern = Pattern.compile(MULTILINE_COMMENT_REGEX.format(testCaseInfoRegex))
|
||||
|
||||
fun getInstanceByType(testFile: File) = when {
|
||||
Pattern.compile(testPathBaseRegexTemplate.format(LinkedSpecTestValidator.pathPartRegex)).matcher(testFile.absolutePath).find() ->
|
||||
LinkedSpecTestValidator(testFile)
|
||||
Pattern.compile(testPathBaseRegexTemplate.format(NotLinkedSpecTestValidator.pathPartRegex)).matcher(testFile.absolutePath).find() ->
|
||||
NotLinkedSpecTestValidator(testFile)
|
||||
else -> throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID)
|
||||
}
|
||||
|
||||
fun getInstanceByType(testPath: String) = getInstanceByType(File(testPath))
|
||||
|
||||
private fun getTestInfoElements(
|
||||
testInfoElementRules: Array<out SpecTestInfoElementType>,
|
||||
testInfoElements: String
|
||||
): SpecTestInfoElements<SpecTestInfoElementType> {
|
||||
val testInfoElementsMap = mutableMapOf<SpecTestInfoElementType, SpecTestInfoElementContent>()
|
||||
val testInfoElementMatcher = testInfoElementPattern.matcher(testInfoElements)
|
||||
|
||||
while (testInfoElementMatcher.find()) {
|
||||
val testInfoOriginalElementName = testInfoElementMatcher.group("name")
|
||||
val testInfoElementName = testInfoElementRules.find {
|
||||
it as Enum<*>
|
||||
it.name == testInfoOriginalElementName.replace(" ", "_")
|
||||
} ?: throw SpecTestValidationException(
|
||||
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
|
||||
"Unknown '$testInfoOriginalElementName' test info element name."
|
||||
)
|
||||
val testInfoElementValue = testInfoElementMatcher.group("value")
|
||||
val testInfoElementValueMatcher = testInfoElementName.valuePattern?.matcher(testInfoElementValue)
|
||||
|
||||
if (testInfoElementValueMatcher != null && !testInfoElementValueMatcher.find())
|
||||
throw SpecTestValidationException(
|
||||
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
|
||||
"'$testInfoElementValue' in '$testInfoElementName' is not parsed."
|
||||
)
|
||||
|
||||
testInfoElementsMap[testInfoElementName] =
|
||||
SpecTestInfoElementContent(testInfoElementValue ?: "", testInfoElementValueMatcher)
|
||||
}
|
||||
|
||||
testInfoElementRules.forEach {
|
||||
if (it.required && !testInfoElementsMap.contains(it)) {
|
||||
throw SpecTestValidationException(
|
||||
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
|
||||
"$it in case or test info is required."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return testInfoElementsMap
|
||||
}
|
||||
|
||||
private fun getIssues(testCases: List<SpecTestCase>, testIssues: List<String>?): Set<String> {
|
||||
val issues = mutableSetOf<String>()
|
||||
|
||||
testCases.forEach {
|
||||
if (it.issues != null) issues.addAll(it.issues)
|
||||
}
|
||||
|
||||
if (testIssues != null) issues.addAll(testIssues)
|
||||
|
||||
return issues
|
||||
}
|
||||
|
||||
fun parseIssues(issues: SpecTestInfoElementContent?) = issues?.content?.split(",")
|
||||
}
|
||||
|
||||
private fun getTestCasesInfo(
|
||||
testCaseInfoMatcher: Matcher,
|
||||
infoElements: SpecTestInfoElements<SpecTestInfoElementType>
|
||||
): List<SpecTestCase> {
|
||||
val testCases = mutableListOf<SpecTestCase>()
|
||||
var testCasesCounter = 1
|
||||
|
||||
while (testCaseInfoMatcher.find()) {
|
||||
val caseInfoElements = getTestInfoElements(
|
||||
SpecTestCaseInfoElementType.values(),
|
||||
testCaseInfoMatcher.group("infoElements")
|
||||
)
|
||||
|
||||
testCases.add(
|
||||
SpecTestCase(
|
||||
testCasesCounter++,
|
||||
caseInfoElements[SpecTestCaseInfoElementType.CASE_DESCRIPTION]!!.content,
|
||||
caseInfoElements.contains(SpecTestCaseInfoElementType.UNEXPECTED_BEHAVIOUR),
|
||||
parseIssues(caseInfoElements[SpecTestCaseInfoElementType.ISSUES])
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (testCases.isEmpty())
|
||||
testCases.add(getSingleTestCase(infoElements))
|
||||
|
||||
return testCases
|
||||
}
|
||||
|
||||
abstract fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) : SpecTestCase
|
||||
|
||||
fun testInfoFilter(fileContent: String): String =
|
||||
testInfoPattern.matcher(fileContent).replaceAll("").let {
|
||||
testCaseInfoSingleLinePattern.matcher(it).replaceAll("").let {
|
||||
testCaseInfoMultilinePattern.matcher(it).replaceAll("")
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun getTestInfo(
|
||||
testInfoMatcher: Matcher,
|
||||
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
|
||||
testCases: List<SpecTestCase>,
|
||||
unexpectedBehavior: Boolean = false,
|
||||
issues: Set<String>? = null
|
||||
): T
|
||||
|
||||
abstract fun getTestInfo(testInfoMatcher: Matcher): T
|
||||
|
||||
abstract fun parseTestInfo()
|
||||
|
||||
abstract fun printTestInfo()
|
||||
|
||||
fun parseTestInfo(testInfoElementsRules: Array<out SpecTestInfoElementType>) {
|
||||
val testInfoByFilenameMatcher = testPathPattern.matcher(testDataFile.canonicalPath)
|
||||
|
||||
if (!testInfoByFilenameMatcher.find())
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID)
|
||||
|
||||
val fileContent = testDataFile.readText()
|
||||
val testInfoByContentMatcher = testInfoPattern.matcher(fileContent)
|
||||
|
||||
if (!testInfoByContentMatcher.find())
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID)
|
||||
|
||||
val testInfoElements = getTestInfoElements(
|
||||
testInfoElementsRules,
|
||||
testInfoByContentMatcher.group("infoElements")
|
||||
)
|
||||
val testCases = getTestCasesInfo(testCaseInfoSingleLinePattern.matcher(fileContent), testInfoElements) +
|
||||
getTestCasesInfo(testCaseInfoMultilinePattern.matcher(fileContent), testInfoElements)
|
||||
|
||||
testInfoByFilename = getTestInfo(testInfoByFilenameMatcher)
|
||||
testInfoByContent = getTestInfo(
|
||||
testInfoByContentMatcher,
|
||||
testInfoElements,
|
||||
testCases = testCases,
|
||||
unexpectedBehavior = testInfoElements.contains(LinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR) || testCases.any { it.unexpectedBehavior },
|
||||
issues = getIssues(
|
||||
testCases,
|
||||
parseIssues(
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.ISSUES]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if (!testInfoByFilename.checkConsistency(testInfoByContent))
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY)
|
||||
}
|
||||
|
||||
fun validateTestType(computedTestType: TestType) {
|
||||
if (computedTestType != testInfo.testType) {
|
||||
val isNotNegative = computedTestType == TestType.POSITIVE && testInfo.testType == TestType.NEGATIVE
|
||||
val isNotPositive = computedTestType == TestType.NEGATIVE && testInfo.testType == TestType.POSITIVE
|
||||
val reason = when {
|
||||
isNotNegative -> SpecTestValidationFailedReason.TEST_IS_NOT_NEGATIVE
|
||||
isNotPositive -> SpecTestValidationFailedReason.TEST_IS_NOT_POSITIVE
|
||||
else -> SpecTestValidationFailedReason.UNKNOWN
|
||||
}
|
||||
throw SpecTestValidationException(reason)
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
|
||||
|
||||
import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
|
||||
class DiagnosticTestTypeValidator(testFiles: List<BaseDiagnosticsTest.TestFile>) {
|
||||
private val diagnostics = mutableListOf<Diagnostic>()
|
||||
private val diagnosticStats = mutableMapOf<String, Int>()
|
||||
private val diagnosticSeverityStats = mutableMapOf<Severity, Int>()
|
||||
|
||||
init {
|
||||
collectDiagnostics(testFiles)
|
||||
}
|
||||
|
||||
private fun collectDiagnosticStatistic() {
|
||||
diagnostics.forEach {
|
||||
val severity = it.factory.severity
|
||||
diagnosticSeverityStats.run { put(severity, getOrDefault(severity, 0) + 1) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun collectDiagnostics(files: List<BaseDiagnosticsTest.TestFile>) {
|
||||
files.forEach {
|
||||
it.actualDiagnostics.forEach {
|
||||
val diagnosticName = it.diagnostic.factory.name
|
||||
diagnosticStats.run { put(diagnosticName, getOrDefault(diagnosticName, 0) + 1) }
|
||||
diagnostics.add(it.diagnostic)
|
||||
}
|
||||
}
|
||||
collectDiagnosticStatistic()
|
||||
}
|
||||
|
||||
fun computeTestType() =
|
||||
if (Severity.ERROR in diagnosticSeverityStats) TestType.NEGATIVE else TestType.POSITIVE
|
||||
|
||||
fun printDiagnosticStatistic() {
|
||||
val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain"
|
||||
println("DIAGNOSTICS: $diagnostics")
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
|
||||
|
||||
import java.io.File
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
enum class LinkedSpecTestFileInfoElementType(
|
||||
override val valuePattern: Pattern? = null,
|
||||
override val required: Boolean = false
|
||||
) : SpecTestInfoElementType {
|
||||
SECTION(required = true),
|
||||
PARAGRAPH(required = true),
|
||||
SENTENCE(
|
||||
valuePattern = Pattern.compile("""\[(?<number>${AbstractSpecTestValidator.INTEGER_REGEX})\](?<text>.*?)"""),
|
||||
required = true
|
||||
),
|
||||
NUMBER(required = true),
|
||||
DESCRIPTION(required = true),
|
||||
ISSUES(valuePattern = Pattern.compile("""(KT-[1-9]\d*)(,\s*KT-[1-9]\d*)*""")),
|
||||
UNEXPECTED_BEHAVIOUR,
|
||||
DISCUSSION,
|
||||
NOTE
|
||||
}
|
||||
|
||||
class LinkedSpecTest(
|
||||
testArea: TestArea,
|
||||
testType: TestType,
|
||||
section: String,
|
||||
val paragraphNumber: Int,
|
||||
val sentenceNumber: Int,
|
||||
val sentence: String? = null,
|
||||
testNumber: Int,
|
||||
description: String? = null,
|
||||
cases: List<SpecTestCase>? = null,
|
||||
unexpectedBehavior: Boolean? = null,
|
||||
issues: Set<String>? = null
|
||||
) : AbstractSpecTest(testArea, testType, section, testNumber, description, cases, unexpectedBehavior, issues) {
|
||||
override fun checkConsistency(other: AbstractSpecTest) =
|
||||
other is LinkedSpecTest
|
||||
&& this.section == other.section
|
||||
&& this.testArea == other.testArea
|
||||
&& this.testType == other.testType
|
||||
&& this.testNumber == other.testNumber
|
||||
&& this.paragraphNumber == other.paragraphNumber
|
||||
&& this.sentenceNumber == other.sentenceNumber
|
||||
}
|
||||
|
||||
class LinkedSpecTestValidator(testDataFile: File) : AbstractSpecTestValidator<LinkedSpecTest>(testDataFile) {
|
||||
override val testPathPattern = getPathPattern()
|
||||
override val testInfoPattern: Pattern =
|
||||
Pattern.compile(MULTILINE_COMMENT_REGEX.format("""KOTLIN $testAreaRegex SPEC TEST \($testTypeRegex\)$lineSeparator(?<infoElements>[\s\S]*?$lineSeparator)"""))
|
||||
|
||||
companion object : SpecTestValidatorHelperObject {
|
||||
override val pathPartRegex =
|
||||
"""${dirsByLinkedType[SpecTestLinkedType.LINKED]}$pathSeparator(?<section>[\w-]+)${pathSeparator}p-(?<paragraphNumber>$INTEGER_REGEX)"""
|
||||
override val filenameRegex = """(?<sentenceNumber>$INTEGER_REGEX)\.(?<testNumber>$INTEGER_REGEX)\.kt"""
|
||||
override fun getPathPattern(): Pattern = Pattern.compile(testPathRegexTemplate.format(pathPartRegex, filenameRegex))
|
||||
}
|
||||
|
||||
override fun getTestInfo(
|
||||
testInfoMatcher: Matcher,
|
||||
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
|
||||
testCases: List<SpecTestCase>,
|
||||
unexpectedBehavior: Boolean,
|
||||
issues: Set<String>?
|
||||
): LinkedSpecTest {
|
||||
val sentenceMatcher = testInfoElements[LinkedSpecTestFileInfoElementType.SENTENCE]!!.additionalMatcher!!
|
||||
|
||||
return LinkedSpecTest(
|
||||
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
|
||||
TestType.valueOf(testInfoMatcher.group("testType")),
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.SECTION]!!.content,
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.PARAGRAPH]!!.content.toInt(),
|
||||
sentenceMatcher.group("number").toInt(),
|
||||
sentenceMatcher.group("text"),
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.NUMBER]!!.content.toInt(),
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
|
||||
testCases,
|
||||
unexpectedBehavior,
|
||||
issues
|
||||
)
|
||||
}
|
||||
|
||||
override fun getTestInfo(testInfoMatcher: Matcher) =
|
||||
LinkedSpecTest(
|
||||
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
|
||||
TestType.fromValue(testInfoMatcher.group("testType"))!!,
|
||||
testInfoMatcher.group("section"),
|
||||
testInfoMatcher.group("paragraphNumber").toInt(),
|
||||
testInfoMatcher.group("sentenceNumber").toInt(),
|
||||
testNumber = testInfoMatcher.group("testNumber").toInt()
|
||||
)
|
||||
|
||||
override fun parseTestInfo() = parseTestInfo(LinkedSpecTestFileInfoElementType.values())
|
||||
|
||||
override fun printTestInfo() {
|
||||
println("--------------------------------------------------")
|
||||
if (testInfoByContent.unexpectedBehavior!!)
|
||||
println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)")
|
||||
println("${testInfoByFilename.testArea} ${testInfoByFilename.testType} SPEC TEST")
|
||||
println("SECTION: ${testInfoByContent.section} (paragraph: ${testInfoByFilename.paragraphNumber})")
|
||||
println("SENTENCE ${testInfoByContent.sentenceNumber}: ${testInfoByContent.sentence}")
|
||||
println("TEST NUMBER: ${testInfoByContent.testNumber}")
|
||||
println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}")
|
||||
println("DESCRIPTION: ${testInfoByContent.description}")
|
||||
if (testInfoByContent.issues!!.isNotEmpty())
|
||||
println("LINKED ISSUES: ${testInfoByContent.issues!!.map { ISSUE_TRACKER + it }.joinToString(", ")}")
|
||||
}
|
||||
|
||||
override fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) =
|
||||
SpecTestCase(
|
||||
1,
|
||||
description = testInfoElements[LinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
|
||||
unexpectedBehavior = testInfoElements.contains(LinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR),
|
||||
issues = parseIssues(testInfoElements[LinkedSpecTestFileInfoElementType.ISSUES])
|
||||
)
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
|
||||
|
||||
import java.io.File
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
enum class NotLinkedSpecTestFileInfoElementType(
|
||||
override val valuePattern: Pattern? = null,
|
||||
override val required: Boolean = false
|
||||
) : SpecTestInfoElementType {
|
||||
SECTION(required = true),
|
||||
CATEGORY(
|
||||
valuePattern = Pattern.compile("""\w+(,\s+\w+)*"""),
|
||||
required = true
|
||||
),
|
||||
NUMBER(required = true),
|
||||
DESCRIPTION(required = true),
|
||||
ISSUES(valuePattern = LinkedSpecTestFileInfoElementType.ISSUES.valuePattern),
|
||||
UNEXPECTED_BEHAVIOUR,
|
||||
DISCUSSION,
|
||||
NOTE
|
||||
}
|
||||
|
||||
class NotLinkedSpecTest(
|
||||
testArea: TestArea,
|
||||
testType: TestType,
|
||||
section: String,
|
||||
val categories: List<String>,
|
||||
testNumber: Int,
|
||||
description: String? = null,
|
||||
cases: List<SpecTestCase>? = null,
|
||||
unexpectedBehavior: Boolean? = null,
|
||||
issues: Set<String>? = null
|
||||
) : AbstractSpecTest(testArea, testType, section, testNumber, description, cases, unexpectedBehavior, issues) {
|
||||
override fun checkConsistency(other: AbstractSpecTest) =
|
||||
other is NotLinkedSpecTest
|
||||
&& this.section == other.section
|
||||
&& this.testArea == other.testArea
|
||||
&& this.testType == other.testType
|
||||
&& this.categories.joinToString(",") == other.categories.joinToString(",")
|
||||
&& this.testNumber == other.testNumber
|
||||
}
|
||||
|
||||
class NotLinkedSpecTestValidator(testDataFile: File) : AbstractSpecTestValidator<NotLinkedSpecTest>(testDataFile) {
|
||||
override val testPathPattern = getPathPattern()
|
||||
override val testInfoPattern: Pattern =
|
||||
Pattern.compile(MULTILINE_COMMENT_REGEX.format("""KOTLIN $testAreaRegex NOT LINKED SPEC TEST \($testTypeRegex\)$lineSeparator(?<infoElements>[\s\S]*?$lineSeparator)"""))
|
||||
|
||||
companion object : SpecTestValidatorHelperObject {
|
||||
override val pathPartRegex =
|
||||
"""${dirsByLinkedType[SpecTestLinkedType.NOT_LINKED]}$pathSeparator(?<section>[\w-]+)$pathSeparator(?<categories>(?:[\w-]+)(?:/[\w-]+)*?)"""
|
||||
override val filenameRegex = """(?<testNumber>$INTEGER_REGEX)\.kt"""
|
||||
override fun getPathPattern(): Pattern = Pattern.compile(testPathRegexTemplate.format(pathPartRegex, filenameRegex))
|
||||
}
|
||||
|
||||
override fun getTestInfo(
|
||||
testInfoMatcher: Matcher,
|
||||
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
|
||||
testCases: List<SpecTestCase>,
|
||||
unexpectedBehavior: Boolean,
|
||||
issues: Set<String>?
|
||||
) =
|
||||
NotLinkedSpecTest(
|
||||
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
|
||||
TestType.valueOf(testInfoMatcher.group("testType")),
|
||||
testInfoElements[NotLinkedSpecTestFileInfoElementType.SECTION]!!.content,
|
||||
testInfoElements[NotLinkedSpecTestFileInfoElementType.CATEGORY]!!.content.split(Regex(""",\s*""")),
|
||||
testInfoElements[NotLinkedSpecTestFileInfoElementType.NUMBER]!!.content.toInt(),
|
||||
testInfoElements[NotLinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
|
||||
testCases,
|
||||
unexpectedBehavior,
|
||||
issues
|
||||
)
|
||||
|
||||
override fun getTestInfo(testInfoMatcher: Matcher) =
|
||||
NotLinkedSpecTest(
|
||||
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
|
||||
TestType.fromValue(testInfoMatcher.group("testType"))!!,
|
||||
testInfoMatcher.group("section"),
|
||||
testInfoMatcher.group("categories").split("/"),
|
||||
testNumber = testInfoMatcher.group("testNumber").toInt()
|
||||
)
|
||||
|
||||
override fun parseTestInfo() = parseTestInfo(NotLinkedSpecTestFileInfoElementType.values())
|
||||
|
||||
override fun printTestInfo() {
|
||||
println("--------------------------------------------------")
|
||||
if (testInfoByContent.unexpectedBehavior!!)
|
||||
println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)")
|
||||
println("${testInfoByFilename.testArea} ${testInfoByFilename.testType} NOT LINKED SPEC TEST")
|
||||
println("SECTION: ${testInfoByContent.section}")
|
||||
println("CATEGORIES: ${testInfoByContent.categories.joinToString(", ")}")
|
||||
println("TEST NUMBER: ${testInfoByContent.testNumber}")
|
||||
println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}")
|
||||
println("DESCRIPTION: ${testInfoByContent.description}")
|
||||
if (testInfoByContent.issues!!.isNotEmpty())
|
||||
println("LINKED ISSUES: ${testInfoByContent.issues!!.map { ISSUE_TRACKER + it }.joinToString(", ")}")
|
||||
}
|
||||
|
||||
override fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) =
|
||||
SpecTestCase(
|
||||
1,
|
||||
description = testInfoElements[NotLinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
|
||||
unexpectedBehavior = testInfoElements.contains(NotLinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR),
|
||||
issues = parseIssues(testInfoElements[NotLinkedSpecTestFileInfoElementType.ISSUES])
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user