[Test] Migrate FIR diagnostic spec tests to new infrastructure
This commit includes a lot of minor changes in testdata: new infrastructure requires that each test file in one testdata file in one module must have unique name, but a lot of existing spec tests didn't satisfy this requirement
This commit is contained in:
+7
@@ -37,4 +37,11 @@ object AdditionalFilesDirectives : SimpleDirectivesContainer() {
|
||||
See file ./compiler/testData/diagnostics/helpers/coroutines/TailCallOptimizationChecker.kt
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val SPEC_HELPERS by directive(
|
||||
description = """
|
||||
Adds util functions from `test-spec` modules
|
||||
See directory ./compiler/tests-spec/helpers/
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test.runners
|
||||
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.SPEC_HELPERS
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.WITH_STDLIB
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirFailingTestSuppressor
|
||||
import org.jetbrains.kotlin.test.frontend.fir.handlers.FirIdenticalChecker
|
||||
import org.jetbrains.kotlin.test.services.fir.FirOldFrontendMetaConfigurator
|
||||
import org.jetbrains.kotlin.test.services.sourceProviders.SpecHelpersSourceFilesProvider
|
||||
|
||||
abstract class AbstractFirDiagnosticTestSpec : AbstractFirDiagnosticTest() {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
with(builder) {
|
||||
defaultDirectives {
|
||||
+SPEC_HELPERS
|
||||
+WITH_STDLIB
|
||||
}
|
||||
|
||||
useAdditionalSourceProviders(::SpecHelpersSourceFilesProvider)
|
||||
|
||||
useAfterAnalysisCheckers(
|
||||
::FirIdenticalChecker,
|
||||
::FirFailingTestSuppressor,
|
||||
)
|
||||
|
||||
useMetaTestConfigurators(::FirOldFrontendMetaConfigurator)
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test.services.sourceProviders
|
||||
|
||||
import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives
|
||||
import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.SPEC_HELPERS
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.AdditionalSourceProvider
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import java.io.File
|
||||
|
||||
class SpecHelpersSourceFilesProvider(testServices: TestServices) : AdditionalSourceProvider(testServices) {
|
||||
companion object {
|
||||
const val HELPERS_DIR_PATH = "compiler/tests-spec/testData/diagnostics/helpers"
|
||||
}
|
||||
|
||||
override val directives: List<DirectivesContainer> =
|
||||
listOf(AdditionalFilesDirectives)
|
||||
|
||||
override fun produceAdditionalFiles(globalDirectives: RegisteredDirectives, module: TestModule): List<TestFile> {
|
||||
if (SPEC_HELPERS !in module.directives) return emptyList()
|
||||
return File(HELPERS_DIR_PATH).walkTopDown().mapNotNull {
|
||||
if (it.isDirectory) return@mapNotNull null
|
||||
it.toTestFile()
|
||||
}.toList()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user