[Test] Migrate SpecTestsConsistencyTest to JUnit5
This commit is contained in:
@@ -7,10 +7,8 @@ dependencies {
|
|||||||
testCompile(projectTests(":compiler"))
|
testCompile(projectTests(":compiler"))
|
||||||
testImplementation(projectTests(":compiler:test-infrastructure"))
|
testImplementation(projectTests(":compiler:test-infrastructure"))
|
||||||
testImplementation(projectTests(":compiler:tests-common-new"))
|
testImplementation(projectTests(":compiler:tests-common-new"))
|
||||||
testRuntimeOnly(platform("org.junit:junit-bom:5.7.0"))
|
|
||||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter")
|
|
||||||
|
|
||||||
testCompileOnly(intellijDep()) {
|
testCompile(intellijDep()) {
|
||||||
includeJars("groovy", "groovy-xml", rootProject = rootProject)
|
includeJars("groovy", "groovy-xml", rootProject = rootProject)
|
||||||
}
|
}
|
||||||
testCompile(intellijDep()) {
|
testCompile(intellijDep()) {
|
||||||
@@ -21,6 +19,8 @@ dependencies {
|
|||||||
compile("org.jsoup:jsoup:1.10.3")
|
compile("org.jsoup:jsoup:1.10.3")
|
||||||
if (isIdeaActive) testRuntimeOnly(files("${rootProject.projectDir}/dist/kotlinc/lib/kotlin-reflect.jar"))
|
if (isIdeaActive) testRuntimeOnly(files("${rootProject.projectDir}/dist/kotlinc/lib/kotlin-reflect.jar"))
|
||||||
testRuntime(project(":kotlin-reflect"))
|
testRuntime(project(":kotlin-reflect"))
|
||||||
|
|
||||||
|
testApiJUnit5(vintageEngine = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -42,10 +42,10 @@ val printSpecTestsStatistic by generator("org.jetbrains.kotlin.spec.utils.tasks.
|
|||||||
|
|
||||||
val specConsistencyTests by task<Test> {
|
val specConsistencyTests by task<Test> {
|
||||||
workingDir = rootDir
|
workingDir = rootDir
|
||||||
|
|
||||||
filter {
|
filter {
|
||||||
includeTestsMatching("org.jetbrains.kotlin.spec.consistency.SpecTestsConsistencyTest")
|
includeTestsMatching("org.jetbrains.kotlin.spec.consistency.SpecTestsConsistencyTest")
|
||||||
}
|
}
|
||||||
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<Test>("test") {
|
tasks.named<Test>("test") {
|
||||||
|
|||||||
+10
-17
@@ -12,27 +12,19 @@ import org.jetbrains.kotlin.spec.utils.SpecTestLinkedType
|
|||||||
import org.jetbrains.kotlin.spec.utils.TestArea
|
import org.jetbrains.kotlin.spec.utils.TestArea
|
||||||
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.parseLinkedSpecTest
|
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.parseLinkedSpecTest
|
||||||
import org.jetbrains.kotlin.spec.utils.spec.SpecSentencesStorage
|
import org.jetbrains.kotlin.spec.utils.spec.SpecSentencesStorage
|
||||||
import org.junit.Test
|
import org.junit.jupiter.params.ParameterizedTest
|
||||||
import org.junit.runner.RunWith
|
import org.junit.jupiter.params.provider.MethodSource
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.stream.Stream
|
||||||
|
|
||||||
@TestDataPath("\$PROJECT_ROOT/compiler/tests-spec/testData/")
|
@TestDataPath("\$PROJECT_ROOT/compiler/tests-spec/testData/")
|
||||||
@RunWith(com.intellij.testFramework.Parameterized::class)
|
|
||||||
class SpecTestsConsistencyTest : TestCase() {
|
class SpecTestsConsistencyTest : TestCase() {
|
||||||
@org.junit.runners.Parameterized.Parameter
|
|
||||||
lateinit var testFilePath: String
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val specSentencesStorage = SpecSentencesStorage()
|
private val specSentencesStorage = SpecSentencesStorage()
|
||||||
|
|
||||||
@org.junit.runners.Parameterized.Parameters(name = "{0}")
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getTestFiles() = emptyList<Array<Any>>()
|
fun getTestFiles(): Stream<String> {
|
||||||
|
val testFiles = mutableListOf<String>()
|
||||||
@com.intellij.testFramework.Parameterized.Parameters(name = "{0}")
|
|
||||||
@JvmStatic
|
|
||||||
fun getTestFiles(@Suppress("UNUSED_PARAMETER") klass: Class<*>): List<Array<String>> {
|
|
||||||
val testFiles = mutableListOf<Array<String>>()
|
|
||||||
|
|
||||||
TestArea.values().forEach { testArea ->
|
TestArea.values().forEach { testArea ->
|
||||||
val testDataPath =
|
val testDataPath =
|
||||||
@@ -40,17 +32,18 @@ class SpecTestsConsistencyTest : TestCase() {
|
|||||||
|
|
||||||
testFiles += File(testDataPath).let { testsDir ->
|
testFiles += File(testDataPath).let { testsDir ->
|
||||||
testsDir.walkTopDown().filter { it.extension == "kt" }.map {
|
testsDir.walkTopDown().filter { it.extension == "kt" }.map {
|
||||||
arrayOf(it.relativeTo(File(GeneralConfiguration.SPEC_TESTDATA_PATH)).path.replace("/", "$"))
|
it.relativeTo(File(GeneralConfiguration.SPEC_TESTDATA_PATH)).path.replace("/", "$")
|
||||||
}.toList()
|
}.toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return testFiles
|
return testFiles.stream()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
fun doTest() {
|
@MethodSource("getTestFiles")
|
||||||
|
fun doTest(testFilePath: String) {
|
||||||
val file = File("${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testFilePath.replace("$", "/")}")
|
val file = File("${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testFilePath.replace("$", "/")}")
|
||||||
val specSentences = specSentencesStorage.getLatest() ?: return
|
val specSentences = specSentencesStorage.getLatest() ?: return
|
||||||
val test = parseLinkedSpecTest(file.canonicalPath, mapOf("main" to file.readText()))
|
val test = parseLinkedSpecTest(file.canonicalPath, mapOf("main" to file.readText()))
|
||||||
|
|||||||
Reference in New Issue
Block a user