[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
Vendored
+4
-1
@@ -1,7 +1,10 @@
|
|||||||
|
// IGNORE_BACKEND: JS_IR
|
||||||
|
// TODO: fix in KT-61881
|
||||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||||
|
|
||||||
inline fun g(): Unit = <!INLINE_CALL_CYCLE!>h()<!>
|
inline fun g(): Unit = <!INLINE_CALL_CYCLE!>h()<!>
|
||||||
|
|
||||||
inline fun h(): Unit = <!INLINE_CALL_CYCLE!>f()<!>
|
inline fun h(): Unit = <!INLINE_CALL_CYCLE!>f()<!>
|
||||||
|
|||||||
Vendored
+4
-1
@@ -1,7 +1,10 @@
|
|||||||
|
// IGNORE_BACKEND: JS_IR
|
||||||
|
// TODO: fix in KT-61881
|
||||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||||
|
|
||||||
inline fun g(): Unit = h { <!INLINE_CALL_CYCLE!>f()<!> }
|
inline fun g(): Unit = h { <!INLINE_CALL_CYCLE!>f()<!> }
|
||||||
|
|
||||||
inline fun h(fn: ()->Unit): Unit = fn()
|
inline fun h(fn: ()->Unit): Unit = fn()
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,10 @@
|
|||||||
|
// IGNORE_BACKEND: JS_IR
|
||||||
|
// TODO: fix in KT-61881
|
||||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
public inline fun f():Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
public inline fun f():Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||||
|
|
||||||
public inline fun g(): Unit = <!INLINE_CALL_CYCLE!>h()<!>
|
public inline fun g(): Unit = <!INLINE_CALL_CYCLE!>h()<!>
|
||||||
|
|
||||||
public inline fun h(): Unit = <!INLINE_CALL_CYCLE!>f()<!>
|
public inline fun h(): Unit = <!INLINE_CALL_CYCLE!>f()<!>
|
||||||
|
|||||||
+3
@@ -1,4 +1,7 @@
|
|||||||
|
// IGNORE_BACKEND: JS_IR
|
||||||
|
// TODO: fix in KT-61881
|
||||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||||
|
|
||||||
|
|||||||
+3
@@ -1,5 +1,8 @@
|
|||||||
|
// IGNORE_BACKEND: JS_IR
|
||||||
|
// TODO: fix in KT-61882
|
||||||
// !LANGUAGE: -RestrictRetentionForExpressionAnnotations
|
// !LANGUAGE: -RestrictRetentionForExpressionAnnotations
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
|
|||||||
+35
-1
@@ -5,9 +5,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.test.backend.handlers
|
package org.jetbrains.kotlin.test.backend.handlers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||||
|
import org.jetbrains.kotlin.test.FirParser
|
||||||
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
|
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
|
||||||
|
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
||||||
|
import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue
|
||||||
|
import org.jetbrains.kotlin.test.frontend.fir.handlers.toMetaInfos
|
||||||
|
import org.jetbrains.kotlin.test.model.BinaryArtifactHandler
|
||||||
import org.jetbrains.kotlin.test.model.TestModule
|
import org.jetbrains.kotlin.test.model.TestModule
|
||||||
|
import org.jetbrains.kotlin.test.services.dependencyProvider
|
||||||
|
import org.jetbrains.kotlin.test.services.globalMetadataInfoHandler
|
||||||
|
|
||||||
inline fun IrBackendInput.processAllIrModuleFragments(
|
inline fun IrBackendInput.processAllIrModuleFragments(
|
||||||
module: TestModule,
|
module: TestModule,
|
||||||
@@ -15,4 +23,30 @@ inline fun IrBackendInput.processAllIrModuleFragments(
|
|||||||
) {
|
) {
|
||||||
dependentIrModuleFragments.forEach { processor(it, it.name.asString()) }
|
dependentIrModuleFragments.forEach { processor(it, it.name.asString()) }
|
||||||
processor(irModuleFragment, module.name)
|
processor(irModuleFragment, module.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun BinaryArtifactHandler<*>.reportKtDiagnostics(module: TestModule, ktDiagnosticReporter: BaseDiagnosticsCollector) {
|
||||||
|
val globalMetadataInfoHandler = testServices.globalMetadataInfoHandler
|
||||||
|
val firParser = module.directives.singleOrZeroValue(FirDiagnosticsDirectives.FIR_PARSER)
|
||||||
|
val lightTreeComparingModeEnabled = firParser != null && FirDiagnosticsDirectives.COMPARE_WITH_LIGHT_TREE in module.directives
|
||||||
|
val lightTreeEnabled = firParser == FirParser.LightTree
|
||||||
|
|
||||||
|
val processedModules = mutableSetOf<TestModule>()
|
||||||
|
|
||||||
|
fun processModule(module: TestModule) {
|
||||||
|
if (!processedModules.add(module)) return
|
||||||
|
for (testFile in module.files) {
|
||||||
|
val ktDiagnostics = ktDiagnosticReporter.diagnosticsByFilePath["/${testFile.name}"] ?: continue
|
||||||
|
ktDiagnostics.forEach {
|
||||||
|
val metaInfos = it.toMetaInfos(module, testFile, globalMetadataInfoHandler, lightTreeEnabled, lightTreeComparingModeEnabled)
|
||||||
|
globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ((moduleName, _, _) in module.dependsOnDependencies) {
|
||||||
|
val dependantModule = testServices.dependencyProvider.getTestModule(moduleName)
|
||||||
|
processModule(dependantModule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processModule(module)
|
||||||
|
}
|
||||||
|
|||||||
+1
-28
@@ -15,16 +15,11 @@ import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
|
|||||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.KtDefaultJvmErrorMessages
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.KtDefaultJvmErrorMessages
|
||||||
import org.jetbrains.kotlin.test.FirParser
|
|
||||||
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives
|
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
|
||||||
import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue
|
|
||||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticReporter
|
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticReporter
|
||||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.withNewInferenceModeEnabled
|
import org.jetbrains.kotlin.test.frontend.classic.handlers.withNewInferenceModeEnabled
|
||||||
import org.jetbrains.kotlin.test.frontend.fir.handlers.FirDiagnosticCodeMetaInfo
|
import org.jetbrains.kotlin.test.frontend.fir.handlers.FirDiagnosticCodeMetaInfo
|
||||||
import org.jetbrains.kotlin.test.frontend.fir.handlers.toMetaInfos
|
|
||||||
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
||||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
|
||||||
import org.jetbrains.kotlin.test.model.TestModule
|
import org.jetbrains.kotlin.test.model.TestModule
|
||||||
import org.jetbrains.kotlin.test.services.*
|
import org.jetbrains.kotlin.test.services.*
|
||||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||||
@@ -57,29 +52,7 @@ class JvmBackendDiagnosticsHandler(testServices: TestServices) : JvmBinaryArtifa
|
|||||||
|
|
||||||
private fun reportKtDiagnostics(module: TestModule, info: BinaryArtifacts.Jvm) {
|
private fun reportKtDiagnostics(module: TestModule, info: BinaryArtifacts.Jvm) {
|
||||||
val ktDiagnosticReporter = info.classFileFactory.generationState.diagnosticReporter as BaseDiagnosticsCollector
|
val ktDiagnosticReporter = info.classFileFactory.generationState.diagnosticReporter as BaseDiagnosticsCollector
|
||||||
val globalMetadataInfoHandler = testServices.globalMetadataInfoHandler
|
reportKtDiagnostics(module, ktDiagnosticReporter)
|
||||||
val firParser = module.directives.singleOrZeroValue(FirDiagnosticsDirectives.FIR_PARSER)
|
|
||||||
val lightTreeComparingModeEnabled = firParser != null && FirDiagnosticsDirectives.COMPARE_WITH_LIGHT_TREE in module.directives
|
|
||||||
val lightTreeEnabled = firParser == FirParser.LightTree
|
|
||||||
|
|
||||||
val processedModules = mutableSetOf<TestModule>()
|
|
||||||
|
|
||||||
fun processModule(module: TestModule) {
|
|
||||||
if (!processedModules.add(module)) return
|
|
||||||
for (testFile in module.files) {
|
|
||||||
val ktDiagnostics = ktDiagnosticReporter.diagnosticsByFilePath["/${testFile.name}"] ?: continue
|
|
||||||
ktDiagnostics.forEach {
|
|
||||||
val metaInfos = it.toMetaInfos(module, testFile, globalMetadataInfoHandler, lightTreeEnabled, lightTreeComparingModeEnabled)
|
|
||||||
globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ((moduleName, _, _) in module.dependsOnDependencies) {
|
|
||||||
val dependantModule = testServices.dependencyProvider.getTestModule(moduleName)
|
|
||||||
processModule(dependantModule)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processModule(module)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkFullDiagnosticRender(module: TestModule) {
|
private fun checkFullDiagnosticRender(module: TestModule) {
|
||||||
|
|||||||
+2
-1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test.model
|
|||||||
import org.jetbrains.kotlin.KtSourceFile
|
import org.jetbrains.kotlin.KtSourceFile
|
||||||
import org.jetbrains.kotlin.backend.wasm.WasmCompilerResult
|
import org.jetbrains.kotlin.backend.wasm.WasmCompilerResult
|
||||||
import org.jetbrains.kotlin.codegen.ClassFileFactory
|
import org.jetbrains.kotlin.codegen.ClassFileFactory
|
||||||
|
import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
|
||||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo
|
||||||
import org.jetbrains.kotlin.ir.backend.js.CompilerResult
|
import org.jetbrains.kotlin.ir.backend.js.CompilerResult
|
||||||
import org.jetbrains.kotlin.js.facade.TranslationResult
|
import org.jetbrains.kotlin.js.facade.TranslationResult
|
||||||
@@ -58,7 +59,7 @@ object BinaryArtifacts {
|
|||||||
get() = ArtifactKinds.Wasm
|
get() = ArtifactKinds.Wasm
|
||||||
}
|
}
|
||||||
|
|
||||||
class KLib(val outputFile: File) : ResultingArtifact.Binary<KLib>() {
|
class KLib(val outputFile: File, val reporter: BaseDiagnosticsCollector) : ResultingArtifact.Binary<KLib>() {
|
||||||
override val kind: BinaryKind<KLib>
|
override val kind: BinaryKind<KLib>
|
||||||
get() = ArtifactKinds.KLib
|
get() = ArtifactKinds.KLib
|
||||||
}
|
}
|
||||||
|
|||||||
-100
@@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.checkers
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.text.StringUtil
|
|
||||||
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
|
||||||
import org.jetbrains.kotlin.cli.js.klib.TopDownAnalyzerFacadeForJSIR
|
|
||||||
import org.jetbrains.kotlin.cli.js.klib.TopDownAnalyzerFacadeForWasm
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
|
||||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
|
||||||
import org.jetbrains.kotlin.context.ModuleContext
|
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.ir.backend.js.prepareAnalyzedSourceModule
|
|
||||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
|
|
||||||
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult
|
|
||||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.js.config.JsConfig
|
|
||||||
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
|
|
||||||
import org.jetbrains.kotlin.js.resolve.MODULE_KIND
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
|
||||||
import org.jetbrains.kotlin.resolve.CompilerEnvironment
|
|
||||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@ObsoleteTestInfrastructure("org.jetbrains.kotlin.test.runners.AbstractDiagnosticsTestWithJsStdLib")
|
|
||||||
abstract class AbstractDiagnosticsTestWithJsStdLib : AbstractDiagnosticsTest() {
|
|
||||||
private var lazyConfig: Lazy<JsConfig>? = lazy(LazyThreadSafetyMode.NONE) {
|
|
||||||
JsConfig(project, environment.configuration.copy().apply {
|
|
||||||
put(CommonConfigurationKeys.MODULE_NAME, KotlinTestUtils.TEST_MODULE_NAME)
|
|
||||||
put(JSConfigurationKeys.LIBRARIES, JsConfig.JS_STDLIB)
|
|
||||||
}, CompilerEnvironment)
|
|
||||||
}
|
|
||||||
|
|
||||||
protected val config: JsConfig get() = lazyConfig!!.value
|
|
||||||
|
|
||||||
override fun tearDown() {
|
|
||||||
lazyConfig = null
|
|
||||||
super.tearDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getEnvironmentConfigFiles(): EnvironmentConfigFiles = EnvironmentConfigFiles.JS_CONFIG_FILES
|
|
||||||
|
|
||||||
override fun analyzeModuleContents(
|
|
||||||
moduleContext: ModuleContext,
|
|
||||||
files: List<KtFile>,
|
|
||||||
moduleTrace: BindingTrace,
|
|
||||||
languageVersionSettings: LanguageVersionSettings,
|
|
||||||
separateModules: Boolean,
|
|
||||||
jvmTarget: JvmTarget
|
|
||||||
): JsAnalysisResult {
|
|
||||||
config.configuration.languageVersionSettings = languageVersionSettings
|
|
||||||
|
|
||||||
val sourceModule = prepareAnalyzedSourceModule(
|
|
||||||
config.project,
|
|
||||||
files,
|
|
||||||
config.configuration,
|
|
||||||
config.configuration[JSConfigurationKeys.LIBRARIES]!!.toList(),
|
|
||||||
emptyList(),
|
|
||||||
AnalyzerWithCompilerReport(config.configuration),
|
|
||||||
analyzerFacade = TopDownAnalyzerFacadeForJSIR
|
|
||||||
)
|
|
||||||
|
|
||||||
return sourceModule.jsFrontEndResult.jsAnalysisResult as JsAnalysisResult
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAdditionalDependencies(module: ModuleDescriptorImpl): List<ModuleDescriptorImpl> =
|
|
||||||
config.moduleDescriptors
|
|
||||||
|
|
||||||
override fun shouldSkipJvmSignatureDiagnostics(groupedByModule: Map<TestModule?, List<TestFile>>): Boolean = true
|
|
||||||
|
|
||||||
override fun createModule(moduleName: String, storageManager: StorageManager): ModuleDescriptorImpl =
|
|
||||||
ModuleDescriptorImpl(Name.special("<$moduleName>"), storageManager, JsPlatformAnalyzerServices.builtIns)
|
|
||||||
|
|
||||||
override fun createSealedModule(storageManager: StorageManager): ModuleDescriptorImpl {
|
|
||||||
val module = createModule("kotlin-js-test-module", storageManager)
|
|
||||||
|
|
||||||
val dependencies = ArrayList<ModuleDescriptorImpl>()
|
|
||||||
dependencies.add(module)
|
|
||||||
|
|
||||||
dependencies.addAll(getAdditionalDependencies(module))
|
|
||||||
|
|
||||||
dependencies.add(module.builtIns.builtInsModule)
|
|
||||||
module.setDependencies(dependencies)
|
|
||||||
|
|
||||||
return module
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-51
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.checkers
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
|
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
|
||||||
import org.jetbrains.kotlin.context.ModuleContext
|
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.hasError
|
|
||||||
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult
|
|
||||||
import org.jetbrains.kotlin.js.config.JsConfig
|
|
||||||
import org.jetbrains.kotlin.js.facade.K2JSTranslator
|
|
||||||
import org.jetbrains.kotlin.js.facade.MainCallParameters
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
|
||||||
|
|
||||||
@OptIn(ObsoleteTestInfrastructure::class)
|
|
||||||
abstract class AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation : AbstractDiagnosticsTestWithJsStdLib() {
|
|
||||||
override fun analyzeModuleContents(
|
|
||||||
moduleContext: ModuleContext,
|
|
||||||
files: List<KtFile>,
|
|
||||||
moduleTrace: BindingTrace,
|
|
||||||
languageVersionSettings: LanguageVersionSettings,
|
|
||||||
separateModules: Boolean,
|
|
||||||
jvmTarget: JvmTarget
|
|
||||||
): JsAnalysisResult {
|
|
||||||
val analysisResult = super.analyzeModuleContents(moduleContext, files, moduleTrace, languageVersionSettings, separateModules, jvmTarget)
|
|
||||||
val diagnostics = analysisResult.bindingTrace.bindingContext.diagnostics
|
|
||||||
|
|
||||||
if (!hasError(diagnostics)) {
|
|
||||||
val translator = K2JSTranslator(config, false)
|
|
||||||
translator.translate(object : JsConfig.Reporter() {}, files, MainCallParameters.noCall(), analysisResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
return analysisResult
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-5
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.asJava.AbstractCompilerLightClassTest
|
|||||||
import org.jetbrains.kotlin.cfg.AbstractControlFlowTest
|
import org.jetbrains.kotlin.cfg.AbstractControlFlowTest
|
||||||
import org.jetbrains.kotlin.cfg.AbstractDataFlowTest
|
import org.jetbrains.kotlin.cfg.AbstractDataFlowTest
|
||||||
import org.jetbrains.kotlin.cfg.AbstractPseudoValueTest
|
import org.jetbrains.kotlin.cfg.AbstractPseudoValueTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation
|
|
||||||
import org.jetbrains.kotlin.cli.AbstractCliTest
|
import org.jetbrains.kotlin.cli.AbstractCliTest
|
||||||
import org.jetbrains.kotlin.codegen.*
|
import org.jetbrains.kotlin.codegen.*
|
||||||
import org.jetbrains.kotlin.codegen.defaultConstructor.AbstractDefaultArgumentsReflectionTest
|
import org.jetbrains.kotlin.codegen.defaultConstructor.AbstractDefaultArgumentsReflectionTest
|
||||||
@@ -53,10 +52,6 @@ fun generateJUnit3CompilerTests(args: Array<String>, mainClassName: String?) {
|
|||||||
|
|
||||||
generateTestGroupSuite(args, mainClassName) {
|
generateTestGroupSuite(args, mainClassName) {
|
||||||
testGroup("compiler/tests-gen", "compiler/testData") {
|
testGroup("compiler/tests-gen", "compiler/testData") {
|
||||||
testClass<AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation> {
|
|
||||||
model("diagnostics/testsWithJsStdLibAndBackendCompilation")
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractMultiPlatformIntegrationTest> {
|
testClass<AbstractMultiPlatformIntegrationTest> {
|
||||||
model("multiplatform", extension = null, recursive = true, excludeParentDirs = true)
|
model("multiplatform", extension = null, recursive = true, excludeParentDirs = true)
|
||||||
}
|
}
|
||||||
|
|||||||
-4
@@ -35,10 +35,6 @@ fun generateJUnit5CompilerTests(args: Array<String>, mainClassName: String?) {
|
|||||||
model("diagnostics/tests/javac", pattern = "^(.*)\\.kts?$", excludedPattern = excludedCustomTestdataPattern)
|
model("diagnostics/tests/javac", pattern = "^(.*)\\.kts?$", excludedPattern = excludedCustomTestdataPattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractDiagnosticsTestWithJsStdLib> {
|
|
||||||
model("diagnostics/testsWithJsStdLib", excludedPattern = excludedCustomTestdataPattern)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractDiagnosticsTestWithJvmIrBackend> {
|
testClass<AbstractDiagnosticsTestWithJvmIrBackend> {
|
||||||
model(
|
model(
|
||||||
"diagnostics/testsWithJvmBackend",
|
"diagnostics/testsWithJvmBackend",
|
||||||
|
|||||||
@@ -191,7 +191,39 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractFirPsiJsDiagnosticTest>(suiteTestClassName = "FirPsiJsOldFrontendDiagnosticsTestGenerated") {
|
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> {
|
testClass<AbstractClassicJsIrTextTest> {
|
||||||
|
|||||||
@@ -102,6 +102,6 @@ class FirJsKlibBackendFacade(
|
|||||||
}
|
}
|
||||||
testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib)
|
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)
|
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
|
package org.jetbrains.kotlin.js.test.fir
|
||||||
|
|
||||||
import org.jetbrains.kotlin.js.test.JsAdditionalSourceProvider
|
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.platform.js.JsPlatforms
|
||||||
import org.jetbrains.kotlin.test.FirParser
|
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.TestConfigurationBuilder
|
||||||
import org.jetbrains.kotlin.test.builders.firHandlersStep
|
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.ConfigurationDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives
|
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.configureFirParser
|
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.FirFrontendFacade
|
||||||
import org.jetbrains.kotlin.test.frontend.fir.handlers.*
|
import org.jetbrains.kotlin.test.frontend.fir.handlers.*
|
||||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
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
|
import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider
|
||||||
|
|
||||||
abstract class AbstractFirJsDiagnosticTestBase(val parser: FirParser) : AbstractKotlinCompilerTest() {
|
abstract class AbstractFirJsDiagnosticTestBase(val parser: FirParser) : AbstractKotlinCompilerTest() {
|
||||||
override fun TestConfigurationBuilder.configuration() {
|
protected open fun configureTestBuilder(builder: TestConfigurationBuilder) = builder.apply {
|
||||||
globalDefaults {
|
globalDefaults {
|
||||||
frontend = FrontendKinds.FIR
|
frontend = FrontendKinds.FIR
|
||||||
targetPlatform = JsPlatforms.defaultJsPlatform
|
targetPlatform = JsPlatforms.defaultJsPlatform
|
||||||
|
targetBackend = TargetBackend.JS_IR
|
||||||
dependencyKind = DependencyKind.Source
|
dependencyKind = DependencyKind.Source
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
|
||||||
|
|
||||||
defaultDirectives {
|
defaultDirectives {
|
||||||
+ConfigurationDirectives.WITH_STDLIB
|
+ConfigurationDirectives.WITH_STDLIB
|
||||||
DiagnosticsDirectives.DIAGNOSTICS with listOf("-warnings", "-infos")
|
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 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -99,6 +99,6 @@ class FirWasmKlibBackendFacade(
|
|||||||
testServices.moduleDescriptorProvider.replaceModuleDescriptorForModule(module, moduleDescriptor)
|
testServices.moduleDescriptorProvider.replaceModuleDescriptorForModule(module, moduleDescriptor)
|
||||||
testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib)
|
testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib)
|
||||||
|
|
||||||
return BinaryArtifacts.KLib(File(outputFile))
|
return BinaryArtifacts.KLib(File(outputFile), inputArtifact.diagnosticReporter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user