From d473d22d8c5525d68bdecd33877f6294f4a234da Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 5 Jul 2021 10:30:09 +0300 Subject: [PATCH] [Test] Migrate SpecTestsConsistencyTest to JUnit5 --- compiler/tests-spec/build.gradle.kts | 8 +++--- .../consistency/SpecTestsConsistencyTest.kt | 27 +++++++------------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/compiler/tests-spec/build.gradle.kts b/compiler/tests-spec/build.gradle.kts index 8d56880c262..c5a38c7ac3e 100644 --- a/compiler/tests-spec/build.gradle.kts +++ b/compiler/tests-spec/build.gradle.kts @@ -7,10 +7,8 @@ dependencies { testCompile(projectTests(":compiler")) testImplementation(projectTests(":compiler:test-infrastructure")) 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) } testCompile(intellijDep()) { @@ -21,6 +19,8 @@ dependencies { compile("org.jsoup:jsoup:1.10.3") if (isIdeaActive) testRuntimeOnly(files("${rootProject.projectDir}/dist/kotlinc/lib/kotlin-reflect.jar")) testRuntime(project(":kotlin-reflect")) + + testApiJUnit5(vintageEngine = true) } sourceSets { @@ -42,10 +42,10 @@ val printSpecTestsStatistic by generator("org.jetbrains.kotlin.spec.utils.tasks. val specConsistencyTests by task { workingDir = rootDir - filter { includeTestsMatching("org.jetbrains.kotlin.spec.consistency.SpecTestsConsistencyTest") } + useJUnitPlatform() } tasks.named("test") { diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt index ab3f122b0d5..6c94f84de98 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt @@ -12,27 +12,19 @@ import org.jetbrains.kotlin.spec.utils.SpecTestLinkedType import org.jetbrains.kotlin.spec.utils.TestArea import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.parseLinkedSpecTest import org.jetbrains.kotlin.spec.utils.spec.SpecSentencesStorage -import org.junit.Test -import org.junit.runner.RunWith +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.MethodSource import java.io.File +import java.util.stream.Stream @TestDataPath("\$PROJECT_ROOT/compiler/tests-spec/testData/") -@RunWith(com.intellij.testFramework.Parameterized::class) class SpecTestsConsistencyTest : TestCase() { - @org.junit.runners.Parameterized.Parameter - lateinit var testFilePath: String - companion object { private val specSentencesStorage = SpecSentencesStorage() - @org.junit.runners.Parameterized.Parameters(name = "{0}") @JvmStatic - fun getTestFiles() = emptyList>() - - @com.intellij.testFramework.Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getTestFiles(@Suppress("UNUSED_PARAMETER") klass: Class<*>): List> { - val testFiles = mutableListOf>() + fun getTestFiles(): Stream { + val testFiles = mutableListOf() TestArea.values().forEach { testArea -> val testDataPath = @@ -40,17 +32,18 @@ class SpecTestsConsistencyTest : TestCase() { testFiles += File(testDataPath).let { testsDir -> 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() } } - return testFiles + return testFiles.stream() } } - @Test - fun doTest() { + @ParameterizedTest + @MethodSource("getTestFiles") + fun doTest(testFilePath: String) { val file = File("${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testFilePath.replace("$", "/")}") val specSentences = specSentencesStorage.getLatest() ?: return val test = parseLinkedSpecTest(file.canonicalPath, mapOf("main" to file.readText()))