[TEST] Extract compiler-specific test utils from :tests-common to new module

This commit is contained in:
Dmitriy Novozhilov
2020-12-14 15:20:28 +03:00
parent d15c7861b2
commit 1fe5148f0d
43 changed files with 412 additions and 199 deletions
+25 -1
View File
@@ -22,6 +22,7 @@ dependencies {
testImplementation("org.junit.platform:junit-platform-commons:1.7.0")
testApi(projectTests(":compiler:test-infrastructure"))
testImplementation(projectTests(":compiler:test-infrastructure-utils"))
testImplementation(projectTests(":compiler:tests-compiler-utils"))
testImplementation(intellijDep()) {
// This dependency is needed only for FileComparisonFailure
@@ -32,7 +33,30 @@ dependencies {
// This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes
testRuntimeOnly(commonDep("junit:junit"))
testRuntimeOnly(intellijDep()) {
includeJars("jna", rootProject = rootProject)
includeJars(
"jps-model",
"extensions",
"util",
"platform-api",
"platform-impl",
"idea",
"guava",
"trove4j",
"asm-all",
"log4j",
"jdom",
"streamex",
"bootstrap",
"jna",
rootProject = rootProject
)
}
Platform[202] {
testRuntimeOnly(intellijDep()) { includeJars("intellij-deps-fastutil-8.3.1-1") }
}
Platform[203].orHigher {
testRuntimeOnly(intellijDep()) { includeJars("intellij-deps-fastutil-8.3.1-3") }
}
testRuntimeOnly(toolsJar())
}
@@ -16,7 +16,7 @@ typealias Constructor<T> = (TestServices) -> T
@DefaultsDsl
class TestConfigurationBuilder {
val defaultsProviderBuilder: DefaultsProviderBuilder = DefaultsProviderBuilder()
lateinit var assertions: Assertions
lateinit var assertions: AssertionsService
private val facades: MutableList<Constructor<AbstractTestFacade<*, *>>> = mutableListOf()
@@ -5,14 +5,14 @@
package org.jetbrains.kotlin.test.frontend.fir.handlers
import org.jetbrains.kotlin.fir.AbstractFirDiagnosticsTest
import org.jetbrains.kotlin.fir.FirCfgConsistencyChecker
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices
class FirCfgConsistencyHandler(testServices: TestServices) : FirAnalysisHandler(testServices) {
override fun processModule(module: TestModule, info: FirOutputArtifact) {
info.firFiles.values.forEach { it.accept(AbstractFirDiagnosticsTest.CfgConsistencyChecker) }
info.firFiles.values.forEach { it.accept(FirCfgConsistencyChecker(assertions)) }
}
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.test.utils.TestDisposable
class TestConfigurationImpl(
defaultsProvider: DefaultsProvider,
assertions: Assertions,
assertions: AssertionsService,
facades: List<Constructor<AbstractTestFacade<*, *>>>,
@@ -86,7 +86,7 @@ class TestConfigurationImpl(
)
register(CompilerConfigurationProvider::class, environmentProvider)
register(Assertions::class, assertions)
register(AssertionsService::class, assertions)
register(DefaultsProvider::class, defaultsProvider)
register(DefaultRegisteredDirectivesProvider::class, DefaultRegisteredDirectivesProvider(defaultRegisteredDirectives))
@@ -14,7 +14,7 @@ import java.io.File
import java.io.IOException
import org.junit.jupiter.api.Assertions as JUnit5PlatformAssertions
object JUnit5Assertions : Assertions() {
object JUnit5Assertions : AssertionsService() {
override fun assertEqualsToFile(expectedFile: File, actual: String, sanitizer: (String) -> String, message: () -> String) {
try {
val actualText = actual.trim { it <= ' ' }.convertLineSeparators().trimTrailingWhitespacesAndAddNewlineAtEOF()
@@ -56,6 +56,14 @@ object JUnit5Assertions : Assertions() {
JUnit5PlatformAssertions.assertAll(exceptions.map { Executable { throw it } })
}
override fun assertNotNull(value: Any?, message: (() -> String)?) {
JUnit5PlatformAssertions.assertNotNull(value, message)
}
override fun <T> assertSameElements(expected: Collection<T>, actual: Collection<T>, message: (() -> String)?) {
JUnit5PlatformAssertions.assertIterableEquals(expected, actual, message)
}
override fun fail(message: () -> String): Nothing {
org.junit.jupiter.api.fail(message)
}
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.js.JsPlatforms
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.platform.konan.NativePlatforms
import org.jetbrains.kotlin.test.Assertions
import org.jetbrains.kotlin.test.builders.LanguageVersionSettingsBuilder
import org.jetbrains.kotlin.test.directives.ModuleStructureDirectives
import org.jetbrains.kotlin.test.directives.model.ComposedRegisteredDirectives