[JS Tests] Prepare JS tests for testing backend diagnostics
- Introducing a backend diagnostic handler. - Moving JS diagnostic tests from test-common to js.test to avoid circular module dependencies. ^KT-61886 Fixed
This commit is contained in:
committed by
Space Team
parent
b672ba8eaf
commit
be4f6beddb
@@ -191,7 +191,39 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractFirPsiJsDiagnosticTest>(suiteTestClassName = "FirPsiJsOldFrontendDiagnosticsTestGenerated") {
|
||||
model("diagnostics/testsWithJsStdLib", pattern = "^([^_](.+))\\.kt$", excludedPattern = excludedFirTestdataPattern)
|
||||
model(
|
||||
relativeRootPath = "diagnostics/testsWithJsStdLib",
|
||||
pattern = "^([^_](.+))\\.kt$",
|
||||
excludedPattern = excludedFirTestdataPattern,
|
||||
targetBackend = TargetBackend.JS_IR
|
||||
)
|
||||
}
|
||||
|
||||
testClass<AbstractFirPsiJsDiagnosticWithBackendTest>(suiteTestClassName = "FirPsiJsOldFrontendDiagnosticsWithBackendTestGenerated") {
|
||||
model(
|
||||
relativeRootPath = "diagnostics/testsWithJsStdLibAndBackendCompilation",
|
||||
pattern = "^([^_](.+))\\.kt$",
|
||||
excludedPattern = excludedFirTestdataPattern,
|
||||
targetBackend = TargetBackend.JS_IR
|
||||
)
|
||||
}
|
||||
|
||||
testClass<AbstractDiagnosticsTestWithJsStdLib>(suiteTestClassName = "DiagnosticsWithJsStdLibTestGenerated") {
|
||||
model(
|
||||
relativeRootPath = "diagnostics/testsWithJsStdLib",
|
||||
pattern = "^([^_](.+))\\.kt$",
|
||||
excludedPattern = excludedFirTestdataPattern,
|
||||
targetBackend = TargetBackend.JS_IR
|
||||
)
|
||||
}
|
||||
|
||||
testClass<AbstractDiagnosticsTestWithJsStdLibWithBackend>(suiteTestClassName = "DiagnosticsWithJsStdLibAndBackendTestGenerated") {
|
||||
model(
|
||||
relativeRootPath = "diagnostics/testsWithJsStdLibAndBackendCompilation",
|
||||
pattern = "^([^_](.+))\\.kt$",
|
||||
excludedPattern = excludedFirTestdataPattern,
|
||||
targetBackend = TargetBackend.JS_IR
|
||||
)
|
||||
}
|
||||
|
||||
testClass<AbstractClassicJsIrTextTest> {
|
||||
|
||||
@@ -102,6 +102,6 @@ class FirJsKlibBackendFacade(
|
||||
}
|
||||
testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib)
|
||||
|
||||
return BinaryArtifacts.KLib(File(outputFile))
|
||||
return BinaryArtifacts.KLib(File(outputFile), inputArtifact.diagnosticReporter)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,6 @@ class JsKlibBackendFacade(
|
||||
}
|
||||
testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib)
|
||||
|
||||
return BinaryArtifacts.KLib(File(outputFile))
|
||||
return BinaryArtifacts.KLib(File(outputFile), inputArtifact.diagnosticReporter)
|
||||
}
|
||||
}
|
||||
|
||||
+33
-1
@@ -6,13 +6,19 @@
|
||||
package org.jetbrains.kotlin.js.test.fir
|
||||
|
||||
import org.jetbrains.kotlin.js.test.JsAdditionalSourceProvider
|
||||
import org.jetbrains.kotlin.js.test.converters.FirJsKlibBackendFacade
|
||||
import org.jetbrains.kotlin.js.test.handlers.JsBackendDiagnosticsHandler
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.builders.firHandlersStep
|
||||
import org.jetbrains.kotlin.test.builders.klibArtifactsHandlersStep
|
||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives
|
||||
import org.jetbrains.kotlin.test.directives.configureFirParser
|
||||
import org.jetbrains.kotlin.test.frontend.fir.Fir2IrJsResultsConverter
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
|
||||
import org.jetbrains.kotlin.test.frontend.fir.handlers.*
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
@@ -25,13 +31,16 @@ import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurato
|
||||
import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider
|
||||
|
||||
abstract class AbstractFirJsDiagnosticTestBase(val parser: FirParser) : AbstractKotlinCompilerTest() {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
protected open fun configureTestBuilder(builder: TestConfigurationBuilder) = builder.apply {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.FIR
|
||||
targetPlatform = JsPlatforms.defaultJsPlatform
|
||||
targetBackend = TargetBackend.JS_IR
|
||||
dependencyKind = DependencyKind.Source
|
||||
}
|
||||
|
||||
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
|
||||
|
||||
defaultDirectives {
|
||||
+ConfigurationDirectives.WITH_STDLIB
|
||||
DiagnosticsDirectives.DIAGNOSTICS with listOf("-warnings", "-infos")
|
||||
@@ -67,6 +76,29 @@ abstract class AbstractFirJsDiagnosticTestBase(val parser: FirParser) : Abstract
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
final override fun TestConfigurationBuilder.configuration() {
|
||||
configureTestBuilder(this@configuration)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractFirJsDiagnosticWithBackendTestBase(parser: FirParser) : AbstractFirJsDiagnosticTestBase(parser) {
|
||||
override fun configureTestBuilder(builder: TestConfigurationBuilder) = builder.apply {
|
||||
super.configureTestBuilder(builder)
|
||||
|
||||
facadeStep(::Fir2IrJsResultsConverter)
|
||||
facadeStep { FirJsKlibBackendFacade(it, true) }
|
||||
|
||||
// TODO: Currently do not run lowerings, because they don't report anything;
|
||||
// see KT-61881, KT-61882
|
||||
// facadeStep { JsIrBackendFacade(it, firstTimeCompilation = true) }
|
||||
|
||||
klibArtifactsHandlersStep {
|
||||
useHandlers(::JsBackendDiagnosticsHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractFirPsiJsDiagnosticTest : AbstractFirJsDiagnosticTestBase(FirParser.Psi)
|
||||
|
||||
abstract class AbstractFirPsiJsDiagnosticWithBackendTest : AbstractFirJsDiagnosticWithBackendTestBase(FirParser.Psi)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.js.test.handlers
|
||||
|
||||
import org.jetbrains.kotlin.test.backend.handlers.KlibArtifactHandler
|
||||
import org.jetbrains.kotlin.test.backend.handlers.reportKtDiagnostics
|
||||
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
|
||||
class JsBackendDiagnosticsHandler(testServices: TestServices) : KlibArtifactHandler(testServices) {
|
||||
override fun processModule(module: TestModule, info: BinaryArtifacts.KLib) {
|
||||
reportKtDiagnostics(module, info.reporter)
|
||||
}
|
||||
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.js.test.ir
|
||||
|
||||
import org.jetbrains.kotlin.js.test.converters.JsIrBackendFacade
|
||||
import org.jetbrains.kotlin.js.test.converters.JsKlibBackendFacade
|
||||
import org.jetbrains.kotlin.js.test.handlers.JsBackendDiagnosticsHandler
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
|
||||
import org.jetbrains.kotlin.test.builders.*
|
||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticsHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.DeclarationsDumpHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.DynamicCallsDumpHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.OldNewInferenceMetaInfoProcessor
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
|
||||
import org.jetbrains.kotlin.test.services.LibraryProvider
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.sourceProviders.AdditionalDiagnosticsSourceFilesProvider
|
||||
import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
|
||||
abstract class AbstractDiagnosticsTestWithJsStdLib : AbstractKotlinCompilerTest() {
|
||||
protected open fun configureTestBuilder(builder: TestConfigurationBuilder) = builder.apply {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.ClassicFrontend
|
||||
targetPlatform = JsPlatforms.defaultJsPlatform
|
||||
targetBackend = TargetBackend.JS_IR
|
||||
dependencyKind = DependencyKind.Source
|
||||
}
|
||||
|
||||
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
|
||||
|
||||
defaultDirectives {
|
||||
+ConfigurationDirectives.WITH_STDLIB
|
||||
+JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
|
||||
}
|
||||
|
||||
useAdditionalService(::LibraryProvider)
|
||||
|
||||
enableMetaInfoHandler()
|
||||
|
||||
useConfigurators(
|
||||
::CommonEnvironmentConfigurator,
|
||||
::JsEnvironmentConfigurator,
|
||||
)
|
||||
|
||||
useMetaInfoProcessors(::OldNewInferenceMetaInfoProcessor)
|
||||
useAdditionalSourceProviders(
|
||||
::AdditionalDiagnosticsSourceFilesProvider,
|
||||
::CoroutineHelpersSourceFilesProvider,
|
||||
)
|
||||
|
||||
classicFrontendStep()
|
||||
classicFrontendHandlersStep {
|
||||
useHandlers(
|
||||
::DeclarationsDumpHandler,
|
||||
::ClassicDiagnosticsHandler,
|
||||
::DynamicCallsDumpHandler,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
final override fun TestConfigurationBuilder.configuration() {
|
||||
configureTestBuilder(this@configuration)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractDiagnosticsTestWithJsStdLibWithBackend : AbstractDiagnosticsTestWithJsStdLib() {
|
||||
override fun configureTestBuilder(builder: TestConfigurationBuilder) = builder.apply {
|
||||
super.configureTestBuilder(builder)
|
||||
|
||||
psi2IrStep()
|
||||
facadeStep { JsKlibBackendFacade(it, true) }
|
||||
|
||||
// TODO: Currently do not run lowerings, because they don't report anything;
|
||||
// see KT-61881, KT-61882
|
||||
// facadeStep { JsIrBackendFacade(it, firstTimeCompilation = true) }
|
||||
|
||||
klibArtifactsHandlersStep {
|
||||
useHandlers(::JsBackendDiagnosticsHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user