From af0e40a0d2cf8505385066a01939fa942fa9020a Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Oct 2021 13:04:19 +0300 Subject: [PATCH] [JS Test] Support RECOMPILE directive in js box tests in new infrastructure --- .../org/jetbrains/kotlin/test/TestRunner.kt | 13 +- .../test/services/DependencyProvider.kt | 15 ++- .../test/builders/TestConfigurationBuilder.kt | 65 +++++++++- .../kotlin/test/impl/TestConfigurationImpl.kt | 11 +- .../kotlin/test/model/ResultingArtifacts.kt | 13 +- .../generators/tests/GenerateJsTests.kt | 8 +- .../abstractClassesForGeneratedTests.kt | 16 --- .../AbstractJsBlackBoxCodegenTestBase.kt | 10 +- .../kotlin/js/testNew/AbstractJsTest.kt | 4 + .../converters/ClassicJsBackendFacade.kt | 54 ++++++-- .../RecompileModuleJsBackendFacade.kt | 99 ++++++++++++++ .../js/testNew/handlers/JsAstHandler.kt | 4 +- .../JsRecompiledArtifactsIdentityHandler.kt | 70 ++++++++++ .../js/testNew/handlers/JsSourceMapHandler.kt | 4 +- .../handlers/JsTranslationResultHandler.kt | 4 +- .../utils/JsIncrementalDataProvider.kt | 44 +++++++ .../JsIncrementalEnvironmentConfigurator.kt | 39 ++++++ .../js/test/semantics/BoxJsTestGenerated.java | 122 ------------------ .../kotlin/js/testNew/BoxJsTestGenerated.java | 120 ++++++++++++++++- .../test/runners/AbstractParcelizeBoxTest.kt | 3 +- 20 files changed, 541 insertions(+), 177 deletions(-) delete mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt create mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/RecompileModuleJsBackendFacade.kt create mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsRecompiledArtifactsIdentityHandler.kt create mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalDataProvider.kt create mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalEnvironmentConfigurator.kt delete mode 100644 js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt index 74f9a786651..202fbbabe6f 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt @@ -66,6 +66,13 @@ class TestRunner(private val testConfiguration: TestConfiguration) { if (it.shouldSkipTest()) return } + runTestPipeline(moduleStructure, services) + } + + fun runTestPipeline( + moduleStructure: TestModuleStructure, + services: TestServices + ) { val globalMetadataInfoHandler = testConfiguration.testServices.globalMetadataInfoHandler globalMetadataInfoHandler.parseExistingMetadataInfosFromAllSources() @@ -103,6 +110,10 @@ class TestRunner(private val testConfiguration: TestConfiguration) { } } + reportFailures(services) + } + + fun reportFailures(services: TestServices) { val filteredFailedAssertions = filterFailedExceptions(allFailedExceptions) filteredFailedAssertions.firstIsInstanceOrNull()?.let { throw it @@ -113,7 +124,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) { /* * Returns false if next modules should be not processed */ - private fun processModule( + fun processModule( module: TestModule, dependencyProvider: DependencyProviderImpl ): Boolean { diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DependencyProvider.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DependencyProvider.kt index 1f0fcb396c0..60090670f9a 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DependencyProvider.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DependencyProvider.kt @@ -12,13 +12,16 @@ abstract class DependencyProvider : TestService { abstract fun getTestModule(name: String): TestModule abstract fun > getArtifact(module: TestModule, kind: TestArtifactKind): A + + abstract fun unregisterAllArtifacts(module: TestModule) + abstract fun copy(): DependencyProvider } val TestServices.dependencyProvider: DependencyProvider by TestServices.testServiceAccessor() class DependencyProviderImpl( private val testServices: TestServices, - testModules: List + private val testModules: List ) : DependencyProvider() { private val assertions: Assertions get() = testServices.assertions @@ -44,6 +47,16 @@ class DependencyProviderImpl( if (previousValue != null) error("Artifact with kind $kind already registered for module ${module.name}") } + override fun unregisterAllArtifacts(module: TestModule) { + artifactsByModule.remove(module) + } + + override fun copy(): DependencyProvider { + return DependencyProviderImpl(testServices, testModules).also { + artifactsByModule.putAll(artifactsByModule.mapValues { (_, map) -> map.toMutableMap() }) + } + } + private fun MutableMap>.getMap(key: K): MutableMap { return getOrPut(key) { mutableMapOf() } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt index 9a1de8bf80f..7b21ffbcbf5 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt @@ -53,11 +53,14 @@ class TestConfigurationBuilder { lateinit var startingArtifactFactory: (TestModule) -> ResultingArtifact<*> + private val globalDefaultsConfigurators: MutableList Unit> = mutableListOf() + private val defaultDirectiveConfigurators: MutableList Unit> = mutableListOf() + inline fun useAdditionalService(noinline serviceConstructor: (TestServices) -> T) { - useAdditionalService(service(serviceConstructor)) + useAdditionalServices(service(serviceConstructor)) } - fun useAdditionalService(serviceRegistrationData: ServiceRegistrationData) { + fun useAdditionalServices(vararg serviceRegistrationData: ServiceRegistrationData) { additionalServices += serviceRegistrationData } @@ -88,7 +91,8 @@ class TestConfigurationBuilder { configurationsByNegativeTestDataCondition += pattern to configuration } - inline fun globalDefaults(init: DefaultsProviderBuilder.() -> Unit) { + fun globalDefaults(init: DefaultsProviderBuilder.() -> Unit) { + globalDefaultsConfigurators += init defaultsProviderBuilder.apply(init) } @@ -196,7 +200,8 @@ class TestConfigurationBuilder { afterAnalysisCheckers += checkers } - inline fun defaultDirectives(init: RegisteredDirectivesBuilder.() -> Unit) { + fun defaultDirectives(init: RegisteredDirectivesBuilder.() -> Unit) { + defaultDirectiveConfigurators += init defaultRegisteredDirectivesBuilder.apply(init) } @@ -237,9 +242,59 @@ class TestConfigurationBuilder { directives, defaultRegisteredDirectivesBuilder.build(), startingArtifactFactory, - additionalServices + additionalServices, + originalBuilder = ReadOnlyBuilder(this, testDataPath) ) } + + class ReadOnlyBuilder(private val builder: TestConfigurationBuilder, val testDataPath: String) { + val defaultsProviderBuilder: DefaultsProviderBuilder + get() = builder.defaultsProviderBuilder + val assertions: AssertionsService + get() = builder.assertions + val sourcePreprocessors: List> + get() = builder.sourcePreprocessors + val additionalMetaInfoProcessors: List> + get() = builder.additionalMetaInfoProcessors + val environmentConfigurators: List> + get() = builder.environmentConfigurators + val preAnalysisHandlers: List> + get() = builder.preAnalysisHandlers + val additionalSourceProviders: List> + get() = builder.additionalSourceProviders + val moduleStructureTransformers: List + get() = builder.moduleStructureTransformers + val metaTestConfigurators: List> + get() = builder.metaTestConfigurators + val afterAnalysisCheckers: List> + get() = builder.afterAnalysisCheckers + val metaInfoHandlerEnabled: Boolean + get() = builder.metaInfoHandlerEnabled + val directives: List + get() = builder.directives + + val defaultDirectiveConfigurators: List Unit> + get() = builder.defaultDirectiveConfigurators + + val globalDefaultsConfigurators: List Unit> + get() = builder.globalDefaultsConfigurators + + val configurationsByPositiveTestDataCondition: List Unit>> + get() = builder.configurationsByPositiveTestDataCondition + val configurationsByNegativeTestDataCondition: List Unit>> + get() = builder.configurationsByNegativeTestDataCondition + val additionalServices: List + get() = builder.additionalServices + + val compilerConfigurationProvider: ((Disposable, List) -> CompilerConfigurationProvider)? + get() = builder.compilerConfigurationProvider + val runtimeClasspathProviders: List> + get() = builder.runtimeClasspathProviders + val testInfo: KotlinTestInfo + get() = builder.testInfo + val startingArtifactFactory: (TestModule) -> ResultingArtifact<*> + get() = builder.startingArtifactFactory + } } inline fun testConfiguration(testDataPath: String, init: TestConfigurationBuilder.() -> Unit): TestConfiguration { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt index a4636d5471a..8bab1f6206e 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.test.impl import com.intellij.openapi.Disposable import org.jetbrains.kotlin.test.* +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.directives.model.ComposedDirectivesContainer import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives @@ -45,12 +46,15 @@ class TestConfigurationImpl( directives: List, override val defaultRegisteredDirectives: RegisteredDirectives, override val startingArtifactFactory: (TestModule) -> ResultingArtifact<*>, - additionalServices: List -) : TestConfiguration() { + additionalServices: List, + + val originalBuilder: TestConfigurationBuilder.ReadOnlyBuilder +) : TestConfiguration(), TestService { override val rootDisposable: Disposable = TestDisposable() override val testServices: TestServices = TestServices() init { + testServices.register(TestConfigurationImpl::class, this) testServices.register(KotlinTestInfo::class, testInfo) val runtimeClassPathProviders = runtimeClasspathProviders.map { it.invoke(testServices) } testServices.register(RuntimeClasspathProvidersContainer::class, RuntimeClasspathProvidersContainer(runtimeClassPathProviders)) @@ -133,3 +137,6 @@ class TestConfigurationImpl( this.forEach { it.registerDirectivesAndServices() } } } + +@TestInfrastructureInternals +val TestServices.testConfiguration: TestConfigurationImpl by TestServices.testServiceAccessor() diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/model/ResultingArtifacts.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/model/ResultingArtifacts.kt index 699904b6a75..7a764c3bbf9 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/model/ResultingArtifacts.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/model/ResultingArtifacts.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.test.model import org.jetbrains.kotlin.codegen.ClassFileFactory +import org.jetbrains.kotlin.incremental.js.TranslationResultValue import org.jetbrains.kotlin.ir.backend.js.CompilerResult import org.jetbrains.kotlin.js.backend.ast.JsProgram import org.jetbrains.kotlin.js.facade.TranslationResult @@ -22,9 +23,19 @@ object BinaryArtifacts { override val kind: BinaryKind get() = ArtifactKinds.Js - class OldJsArtifact(override val outputFile: File, val translationResult: TranslationResult) : Js() + open fun unwrap(): Js = this + class OldJsArtifact(override val outputFile: File, val translationResult: TranslationResult) : Js() class JsIrArtifact(override val outputFile: File, val compilerResult: CompilerResult) : Js() + + data class IncrementalJsArtifact(val originalArtifact: Js, val recompiledArtifact: Js) : Js() { + override val outputFile: File + get() = unwrap().outputFile + + override fun unwrap(): Js { + return originalArtifact + } + } } class Native : ResultingArtifact.Binary() { diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt index dcdb10084e5..75ab19dca00 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt @@ -36,10 +36,6 @@ fun main(args: Array) { generateTestGroupSuite(args) { testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") { - testClass { - model("box/incremental/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS) - } - testClass { model("box/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS_IR) } @@ -126,8 +122,8 @@ fun main(args: Array) { generateTestGroupSuiteWithJUnit5(args) { testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") { - testClass { - model("box/", pattern = "^([^_](.+))\\.kt$", excludeDirs = listOf("incremental")) + testClass { + model("box/", pattern = "^([^_](.+))\\.kt$") } testClass { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt deleted file mode 100644 index 490118e2655..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2010-2020 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.semantics - -import org.jetbrains.kotlin.js.test.BasicBoxTest - -abstract class AbstractBoxJsTest : BasicBoxTest( - TEST_DATA_DIR_PATH + "box/", - "box/" -) { - override val runMinifierByDefault: Boolean = true -} - diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/AbstractJsBlackBoxCodegenTestBase.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/AbstractJsBlackBoxCodegenTestBase.kt index b666990648c..c4832652fa7 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/AbstractJsBlackBoxCodegenTestBase.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/AbstractJsBlackBoxCodegenTestBase.kt @@ -5,10 +5,8 @@ package org.jetbrains.kotlin.js.testNew -import org.jetbrains.kotlin.js.testNew.handlers.JsArtifactsDumpHandler -import org.jetbrains.kotlin.js.testNew.handlers.JsBoxRunner -import org.jetbrains.kotlin.js.testNew.handlers.JsMinifierRunner -import org.jetbrains.kotlin.js.testNew.handlers.NodeJsGeneratorHandler +import org.jetbrains.kotlin.js.testNew.handlers.* +import org.jetbrains.kotlin.js.testNew.utils.JsIncrementalEnvironmentConfigurator import org.jetbrains.kotlin.platform.js.JsPlatforms import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.TargetBackend @@ -37,6 +35,7 @@ abstract class AbstractJsBlackBoxCodegenTestBase> abstract val frontendToBackendConverter: Constructor> abstract val backendFacade: Constructor> + abstract val recompileFacade: Constructor> override fun TestConfigurationBuilder.configuration() { globalDefaults { @@ -58,6 +57,7 @@ abstract class AbstractJsBlackBoxCodegenTestBase> get() = ::ClassicJsBackendFacade + override val recompileFacade: Constructor> + get() = { RecompileModuleJsBackendFacade(it, frontendFacade, frontendToBackendConverter) } + override fun configure(builder: TestConfigurationBuilder) { super.configure(builder) with(builder) { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/ClassicJsBackendFacade.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/ClassicJsBackendFacade.kt index 711aab5c4da..7ead465868c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/ClassicJsBackendFacade.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/ClassicJsBackendFacade.kt @@ -7,15 +7,16 @@ package org.jetbrains.kotlin.js.testNew.converters import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil -import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport -import org.jetbrains.kotlin.cli.common.messages.MessageRenderer -import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector import org.jetbrains.kotlin.cli.common.output.writeAllTo +import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult +import org.jetbrains.kotlin.js.config.JSConfigurationKeys import org.jetbrains.kotlin.js.facade.K2JSTranslator import org.jetbrains.kotlin.js.facade.MainCallParameters import org.jetbrains.kotlin.js.facade.TranslationResult import org.jetbrains.kotlin.js.facade.TranslationUnit +import org.jetbrains.kotlin.js.testNew.utils.JsClassicIncrementalDataProvider +import org.jetbrains.kotlin.js.testNew.utils.jsClassicIncrementalDataProvider import org.jetbrains.kotlin.serialization.js.ModuleKind import org.jetbrains.kotlin.test.backend.classic.ClassicBackendFacade import org.jetbrains.kotlin.test.backend.classic.ClassicBackendInput @@ -23,21 +24,26 @@ import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives import org.jetbrains.kotlin.test.model.ArtifactKinds import org.jetbrains.kotlin.test.model.BinaryArtifacts import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.ServiceRegistrationData import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.compilerConfigurationProvider import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator -import java.io.ByteArrayOutputStream +import org.jetbrains.kotlin.test.services.service import java.io.File -import java.io.PrintStream -import java.nio.charset.Charset class ClassicJsBackendFacade( - testServices: TestServices + testServices: TestServices, + val incrementalCompilationEnabled: Boolean ) : ClassicBackendFacade(testServices, ArtifactKinds.Js) { companion object { const val KOTLIN_TEST_INTERNAL = "\$kotlin_test_internal\$" } + constructor(testServices: TestServices) : this(testServices, incrementalCompilationEnabled = false) + + override val additionalServices: List + get() = listOf(service(::JsClassicIncrementalDataProvider)) + private fun wrapWithModuleEmulationMarkers(content: String, moduleKind: ModuleKind, moduleId: String): String { val escapedModuleId = StringUtil.escapeStringCharacters(moduleId) @@ -57,13 +63,25 @@ class ClassicJsBackendFacade( } } - override fun transform(module: TestModule, inputArtifact: ClassicBackendInput): BinaryArtifacts.Js? { + override fun transform(module: TestModule, inputArtifact: ClassicBackendInput): BinaryArtifacts.Js { val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) val (psiFiles, analysisResult, project, _) = inputArtifact // TODO how to reuse this config from frontend val jsConfig = JsEnvironmentConfigurator.createJsConfig(project, configuration) - val units = psiFiles.map(TranslationUnit::SourceFile) + + val unitsByPath: MutableMap = psiFiles.associateTo(mutableMapOf()) { + (it.virtualFile.canonicalPath ?: "") to TranslationUnit.SourceFile(it) + } + if (incrementalCompilationEnabled) { + val incrementalData = testServices.jsClassicIncrementalDataProvider.getIncrementalData(module) + for ((file, data) in incrementalData.translatedFiles) { + unitsByPath[file.canonicalPath] = TranslationUnit.BinaryAst(data.binaryAst, data.inlineData) + } + } + + val units = unitsByPath.entries.sortedBy { it.key }.map { it.value } + val mainCallParameters = when (JsEnvironmentConfigurationDirectives.CALL_MAIN) { in module.directives -> MainCallParameters.mainWithArguments(listOf()) else -> MainCallParameters.noCall() @@ -74,6 +92,22 @@ class ClassicJsBackendFacade( JsEnvironmentConfigurator.Companion.ExceptionThrowingReporter, units, mainCallParameters, analysisResult as? JsAnalysisResult ) + if (!incrementalCompilationEnabled) { + jsConfig.configuration[JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER]?.let { + val incrementalData = JsClassicIncrementalDataProvider.IncrementalData() + val incrementalService = it as IncrementalResultsConsumerImpl + + for ((srcFile, data) in incrementalService.packageParts) { + incrementalData.translatedFiles[srcFile] = data + } + + incrementalData.packageMetadata += incrementalService.packageMetadata + + incrementalData.header = incrementalService.headerMetadata + testServices.jsClassicIncrementalDataProvider.recordIncrementalData(module, incrementalData) + } + } + val outputFile = File(JsEnvironmentConfigurator.getJsModuleArtifactPath(testServices, module.name) + ".js") if (translationResult !is TranslationResult.Success) { return BinaryArtifacts.Js.OldJsArtifact(outputFile, translationResult) @@ -92,4 +126,4 @@ class ClassicJsBackendFacade( return BinaryArtifacts.Js.OldJsArtifact(outputFile, translationResult) } -} \ No newline at end of file +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/RecompileModuleJsBackendFacade.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/RecompileModuleJsBackendFacade.kt new file mode 100644 index 00000000000..203b7114e0d --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/converters/RecompileModuleJsBackendFacade.kt @@ -0,0 +1,99 @@ +/* + * 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.js.testNew.converters + +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapParser +import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapSuccess +import org.jetbrains.kotlin.js.testNew.utils.jsClassicIncrementalDataProvider +import org.jetbrains.kotlin.test.* +import org.jetbrains.kotlin.test.backend.classic.ClassicBackendInput +import org.jetbrains.kotlin.test.builders.testConfiguration +import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives.RECOMPILE +import org.jetbrains.kotlin.test.impl.testConfiguration +import org.jetbrains.kotlin.test.model.* +import org.jetbrains.kotlin.test.services.* +import org.jetbrains.kotlin.test.services.impl.TestModuleStructureImpl +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.PrintStream +import java.nio.charset.Charset + +@Suppress("warnings") +class RecompileModuleJsBackendFacade>( + val testServices: TestServices, + private val frontendFacade: Constructor>, + private val frontend2BackendConverter: Constructor> +) : AbstractTestFacade() { + override val inputKind: ArtifactKinds.Js + get() = ArtifactKinds.Js + override val outputKind: ArtifactKinds.Js + get() = ArtifactKinds.Js + + @OptIn(TestInfrastructureInternals::class) + override fun transform(module: TestModule, inputArtifact: BinaryArtifacts.Js): BinaryArtifacts.Js { + val filesToRecompile = module.files.filter { RECOMPILE in it.directives } + if (filesToRecompile.isEmpty()) return inputArtifact + + val builder = testServices.testConfiguration.originalBuilder + val incrementalConfiguration = testConfiguration(builder.testDataPath) { + assertions = builder.assertions + testInfo = builder.testInfo + startingArtifactFactory = builder.startingArtifactFactory + useSourcePreprocessor(*builder.sourcePreprocessors.toTypedArray()) + useMetaInfoProcessors(*builder.additionalMetaInfoProcessors.toTypedArray()) + useConfigurators(*builder.environmentConfigurators.toTypedArray()) + useDirectives(*builder.directives.toTypedArray()) + useAdditionalServices(*builder.additionalServices.toTypedArray()) + builder.globalDefaultsConfigurators.forEach { globalDefaults(it) } + builder.defaultDirectiveConfigurators.forEach { defaultDirectives(it) } + builder.configurationsByPositiveTestDataCondition.forEach { (regex, init) -> forTestsMatching(regex, init) } + builder.configurationsByNegativeTestDataCondition.forEach { (regex, init) -> forTestsNotMatching(regex, init) } + + facadeStep(frontendFacade) + facadeStep(frontend2BackendConverter) + facadeStep { ClassicJsBackendFacade(it, incrementalCompilationEnabled = true) } + } + + val moduleStructure = testServices.moduleStructure + val incrementalModule = module.copy(files = filesToRecompile) + val incrementalModuleStructure = TestModuleStructureImpl( + moduleStructure.modules.map { + if (it != module) return@map it + else incrementalModule + }, + moduleStructure.originalTestDataFiles + ) + val incrementalRunner = TestRunner(incrementalConfiguration) + val incrementalDependencyProvider = testServices.dependencyProvider.copy().also { + it.unregisterAllArtifacts(module) + } as DependencyProviderImpl + + val incrementalServices = incrementalConfiguration.testServices + incrementalServices.registerDependencyProvider(incrementalDependencyProvider) + incrementalServices.register(TestModuleStructure::class, incrementalModuleStructure) + incrementalServices.register(TemporaryDirectoryManager::class, testServices.temporaryDirectoryManager) + + val incrementalData = testServices.jsClassicIncrementalDataProvider.getIncrementalData(module).copy() + for (testFile in filesToRecompile) { + incrementalData.translatedFiles.remove(File("/${testFile.relativePath}")) + } + + incrementalServices.jsClassicIncrementalDataProvider.recordIncrementalData( + module, + incrementalData + ) + incrementalRunner.processModule(incrementalModule, incrementalDependencyProvider) + incrementalRunner.reportFailures(incrementalServices) + + val incrementalArtifact = incrementalDependencyProvider.getArtifact(incrementalModule, ArtifactKinds.Js) + return BinaryArtifacts.Js.IncrementalJsArtifact(inputArtifact, incrementalArtifact) + } + + override fun shouldRunAnalysis(module: TestModule): Boolean { + return module.targetBackend == TargetBackend.JS && module.files.any { RECOMPILE in it.directives } + } +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsAstHandler.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsAstHandler.kt index 90831355048..095df262d31 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsAstHandler.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsAstHandler.kt @@ -25,7 +25,7 @@ class JsAstHandler(testServices: TestServices) : JsBinaryArtifactHandler(testSer override fun processModule(module: TestModule, info: BinaryArtifacts.Js) { val ktFiles = module.files.filter { it.isKtFile }.map { it.originalContent } - val result = (info as? BinaryArtifacts.Js.OldJsArtifact)?.translationResult + val result = (info.unwrap() as? BinaryArtifacts.Js.OldJsArtifact)?.translationResult ?: throw IllegalArgumentException("JsBoxRunner suppose to work only with old js backend") processJsProgram((result as TranslationResult.Success).program, ktFiles, module.targetBackend!!) { testServices.assertions.fail { it } @@ -59,4 +59,4 @@ class JsAstHandler(testServices: TestServices) : JsBinaryArtifactHandler(testSer }) } } -} \ No newline at end of file +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsRecompiledArtifactsIdentityHandler.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsRecompiledArtifactsIdentityHandler.kt new file mode 100644 index 00000000000..e42643f1ec1 --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsRecompiledArtifactsIdentityHandler.kt @@ -0,0 +1,70 @@ +/* + * 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.js.testNew.handlers + +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapParser +import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapSuccess +import org.jetbrains.kotlin.test.backend.handlers.JsBinaryArtifactHandler +import org.jetbrains.kotlin.test.model.BinaryArtifacts.Js +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.assertions +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.PrintStream +import java.nio.charset.Charset + +class JsRecompiledArtifactsIdentityHandler(testServices: TestServices) : JsBinaryArtifactHandler(testServices) { + override fun processModule(module: TestModule, info: Js) { + if (info !is Js.IncrementalJsArtifact) return + val (originalArtifact, incrementalArtifact) = info + when { + originalArtifact is Js.OldJsArtifact && incrementalArtifact is Js.OldJsArtifact -> { + compareArtifacts(originalArtifact, incrementalArtifact) + } + else -> assertions.fail { + """ + Incompatible types of original and incremental artifacts: + original: ${originalArtifact::class} + incremental: ${incrementalArtifact::class} + """.trimIndent() + } + } + + } + + private fun compareArtifacts(originalArtifact: Js.OldJsArtifact, incrementalArtifact: Js.OldJsArtifact) { + val originalSourceMap = FileUtil.loadFile(File(originalArtifact.outputFile.parentFile, originalArtifact.outputFile.name + ".map")) + val recompiledSourceMap = + removeRecompiledSuffix( + FileUtil.loadFile(File(incrementalArtifact.outputFile.parentFile, incrementalArtifact.outputFile.name + ".map")) + ) + + if (originalSourceMap != recompiledSourceMap) { + val originalSourceMapParse = SourceMapParser.parse(originalSourceMap) + val recompiledSourceMapParse = SourceMapParser.parse(recompiledSourceMap) + if (originalSourceMapParse is SourceMapSuccess && recompiledSourceMapParse is SourceMapSuccess) { + testServices.assertions.assertEquals( + originalSourceMapParse.toDebugString(), + recompiledSourceMapParse.toDebugString(), + ) { "Source map file changed after recompilation" } + } + testServices.assertions.assertEquals(originalSourceMap, recompiledSourceMap) { "Source map file changed after recompilation" } + } + } + + private fun SourceMapSuccess.toDebugString(): String { + val out = ByteArrayOutputStream() + PrintStream(out).use { value.debug(it) } + return String(out.toByteArray(), Charset.forName("UTF-8")) + } + + private fun removeRecompiledSuffix(text: String): String = text.replace("-recompiled.js", ".js") + + + override fun processAfterAllModules(someAssertionWasFailed: Boolean) {} +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsSourceMapHandler.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsSourceMapHandler.kt index 933e4659f6b..8ffa31fa17e 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsSourceMapHandler.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsSourceMapHandler.kt @@ -34,7 +34,7 @@ class JsSourceMapHandler(testServices: TestServices) : JsBinaryArtifactHandler(t override fun processModule(module: TestModule, info: BinaryArtifacts.Js) { val outputFile = File(JsEnvironmentConfigurator.getJsModuleArtifactPath(testServices, module.name)) - val result = (info as? BinaryArtifacts.Js.OldJsArtifact)?.translationResult + val result = (info.unwrap() as? BinaryArtifacts.Js.OldJsArtifact)?.translationResult ?: throw IllegalArgumentException("JsBoxRunner suppose to work only with old js backend") val remap = JsEnvironmentConfigurationDirectives.SKIP_SOURCEMAP_REMAPPING !in module.directives checkSourceMap(outputFile, (result as TranslationResult.Success).program, remap) { expected, actual -> @@ -98,4 +98,4 @@ class JsSourceMapHandler(testServices: TestServices) : JsBinaryArtifactHandler(t }) } } -} \ No newline at end of file +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsTranslationResultHandler.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsTranslationResultHandler.kt index 1de11f16a6e..78dec19abc3 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsTranslationResultHandler.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/handlers/JsTranslationResultHandler.kt @@ -21,7 +21,7 @@ class JsTranslationResultHandler(testServices: TestServices) : JsBinaryArtifactH override fun processAfterAllModules(someAssertionWasFailed: Boolean) {} override fun processModule(module: TestModule, info: BinaryArtifacts.Js) { - val result = (info as? BinaryArtifacts.Js.OldJsArtifact)?.translationResult + val result = (info.unwrap() as? BinaryArtifacts.Js.OldJsArtifact)?.translationResult ?: throw IllegalArgumentException("JsTranslationResultHandler suppose to work only with old js backend") if (result !is TranslationResult.Success) { @@ -32,4 +32,4 @@ class JsTranslationResultHandler(testServices: TestServices) : JsBinaryArtifactH throw AssertionError("The following errors occurred compiling test:\n$messages") } } -} \ No newline at end of file +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalDataProvider.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalDataProvider.kt new file mode 100644 index 00000000000..ce535799f8a --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalDataProvider.kt @@ -0,0 +1,44 @@ +/* + * 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.js.testNew.utils + +import org.jetbrains.kotlin.incremental.js.TranslationResultValue +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.TestService +import org.jetbrains.kotlin.test.services.TestServices +import java.io.File + +class JsClassicIncrementalDataProvider(private val testServices: TestServices) : TestService { + class IncrementalData( + var header: ByteArray? = null, + val translatedFiles: MutableMap = hashMapOf(), + val packageMetadata: MutableMap = hashMapOf() + ) { + fun copy(): IncrementalData { + return IncrementalData( + header?.clone(), + translatedFiles.toMutableMap(), + packageMetadata.toMutableMap() + ) + } + } + + private val cache: MutableMap = mutableMapOf() + + fun recordIncrementalData(module: TestModule, incrementalData: IncrementalData) { + cache[module] = incrementalData + } + + fun getIncrementalData(module: TestModule): IncrementalData { + return cache.getValue(module) + } + + fun getIncrementalDataIfAny(module: TestModule): IncrementalData? { + return cache[module] + } +} + +val TestServices.jsClassicIncrementalDataProvider: JsClassicIncrementalDataProvider by TestServices.testServiceAccessor() diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalEnvironmentConfigurator.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalEnvironmentConfigurator.kt new file mode 100644 index 00000000000..a39b775a405 --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testNew/utils/JsIncrementalEnvironmentConfigurator.kt @@ -0,0 +1,39 @@ +/* + * 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.js.testNew.utils + +import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.incremental.js.IncrementalDataProviderImpl +import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl +import org.jetbrains.kotlin.js.config.JSConfigurationKeys +import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.EnvironmentConfigurator +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.utils.JsMetadataVersion + +class JsIncrementalEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) { + override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) { + if (module.files.any { JsEnvironmentConfigurationDirectives.RECOMPILE in it.directives }) { + val incrementalData = testServices.jsClassicIncrementalDataProvider.getIncrementalDataIfAny(module) + val header = incrementalData?.header + if (header != null) { + configuration.put( + JSConfigurationKeys.INCREMENTAL_DATA_PROVIDER, + IncrementalDataProviderImpl( + header, + incrementalData.translatedFiles, + JsMetadataVersion.INSTANCE.toArray(), + incrementalData.packageMetadata, + emptyMap() + ) + ) + } + + configuration.put(JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER, IncrementalResultsConsumerImpl()) + } + } +} diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java deleted file mode 100644 index cb76d436080..00000000000 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.js.test.semantics; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.util.KtTestUtil; -import org.jetbrains.kotlin.test.TargetBackend; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.runner.RunWith; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("js/js.translator/testData/box/incremental") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class BoxJsTestGenerated extends AbstractBoxJsTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInIncremental() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/incremental"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("catchScope.kt") - public void testCatchScope() throws Exception { - runTest("js/js.translator/testData/box/incremental/catchScope.kt"); - } - - @TestMetadata("classReferencingClass.kt") - public void testClassReferencingClass() throws Exception { - runTest("js/js.translator/testData/box/incremental/classReferencingClass.kt"); - } - - @TestMetadata("coroutines.kt") - public void testCoroutines() throws Exception { - runTest("js/js.translator/testData/box/incremental/coroutines.kt"); - } - - @TestMetadata("defaultArguments.kt") - public void testDefaultArguments() throws Exception { - runTest("js/js.translator/testData/box/incremental/defaultArguments.kt"); - } - - @TestMetadata("enumUsage.kt") - public void testEnumUsage() throws Exception { - runTest("js/js.translator/testData/box/incremental/enumUsage.kt"); - } - - @TestMetadata("exportedPackage.kt") - public void testExportedPackage() throws Exception { - runTest("js/js.translator/testData/box/incremental/exportedPackage.kt"); - } - - @TestMetadata("functionReferencingClass.kt") - public void testFunctionReferencingClass() throws Exception { - runTest("js/js.translator/testData/box/incremental/functionReferencingClass.kt"); - } - - @TestMetadata("inline.kt") - public void testInline() throws Exception { - runTest("js/js.translator/testData/box/incremental/inline.kt"); - } - - @TestMetadata("inlineLambda.kt") - public void testInlineLambda() throws Exception { - runTest("js/js.translator/testData/box/incremental/inlineLambda.kt"); - } - - @TestMetadata("inlineModuleVariable.kt") - public void testInlineModuleVariable() throws Exception { - runTest("js/js.translator/testData/box/incremental/inlineModuleVariable.kt"); - } - - @TestMetadata("inlineSuspendFun.kt") - public void testInlineSuspendFun() throws Exception { - runTest("js/js.translator/testData/box/incremental/inlineSuspendFun.kt"); - } - - @TestMetadata("jsModule.kt") - public void testJsModule() throws Exception { - runTest("js/js.translator/testData/box/incremental/jsModule.kt"); - } - - @TestMetadata("multipleExport.kt") - public void testMultipleExport() throws Exception { - runTest("js/js.translator/testData/box/incremental/multipleExport.kt"); - } - - @TestMetadata("multipleReimport.kt") - public void testMultipleReimport() throws Exception { - runTest("js/js.translator/testData/box/incremental/multipleReimport.kt"); - } - - @TestMetadata("packagesWithSameName.kt") - public void testPackagesWithSameName() throws Exception { - runTest("js/js.translator/testData/box/incremental/packagesWithSameName.kt"); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("js/js.translator/testData/box/incremental/simple.kt"); - } - - @TestMetadata("sourceMapSourceEmbedding.kt") - public void testSourceMapSourceEmbedding() throws Exception { - runTest("js/js.translator/testData/box/incremental/sourceMapSourceEmbedding.kt"); - } - - @TestMetadata("syntheticStatement.kt") - public void testSyntheticStatement() throws Exception { - runTest("js/js.translator/testData/box/incremental/syntheticStatement.kt"); - } -} diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/BoxJsTestGenerated.java index 4ef5e717d23..7b7a7d40b68 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/BoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/BoxJsTestGenerated.java @@ -22,7 +22,7 @@ import java.util.regex.Pattern; public class BoxJsTestGenerated extends AbstractBoxJsTest { @Test public void testAllFilesPresentInBox() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true, "incremental"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true); } @Nested @@ -3981,6 +3981,124 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { } } + @Nested + @TestMetadata("js/js.translator/testData/box/incremental") + @TestDataPath("$PROJECT_ROOT") + public class Incremental { + @Test + public void testAllFilesPresentInIncremental() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/incremental"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true); + } + + @Test + @TestMetadata("catchScope.kt") + public void testCatchScope() throws Exception { + runTest("js/js.translator/testData/box/incremental/catchScope.kt"); + } + + @Test + @TestMetadata("classReferencingClass.kt") + public void testClassReferencingClass() throws Exception { + runTest("js/js.translator/testData/box/incremental/classReferencingClass.kt"); + } + + @Test + @TestMetadata("coroutines.kt") + public void testCoroutines() throws Exception { + runTest("js/js.translator/testData/box/incremental/coroutines.kt"); + } + + @Test + @TestMetadata("defaultArguments.kt") + public void testDefaultArguments() throws Exception { + runTest("js/js.translator/testData/box/incremental/defaultArguments.kt"); + } + + @Test + @TestMetadata("enumUsage.kt") + public void testEnumUsage() throws Exception { + runTest("js/js.translator/testData/box/incremental/enumUsage.kt"); + } + + @Test + @TestMetadata("exportedPackage.kt") + public void testExportedPackage() throws Exception { + runTest("js/js.translator/testData/box/incremental/exportedPackage.kt"); + } + + @Test + @TestMetadata("functionReferencingClass.kt") + public void testFunctionReferencingClass() throws Exception { + runTest("js/js.translator/testData/box/incremental/functionReferencingClass.kt"); + } + + @Test + @TestMetadata("inline.kt") + public void testInline() throws Exception { + runTest("js/js.translator/testData/box/incremental/inline.kt"); + } + + @Test + @TestMetadata("inlineLambda.kt") + public void testInlineLambda() throws Exception { + runTest("js/js.translator/testData/box/incremental/inlineLambda.kt"); + } + + @Test + @TestMetadata("inlineModuleVariable.kt") + public void testInlineModuleVariable() throws Exception { + runTest("js/js.translator/testData/box/incremental/inlineModuleVariable.kt"); + } + + @Test + @TestMetadata("inlineSuspendFun.kt") + public void testInlineSuspendFun() throws Exception { + runTest("js/js.translator/testData/box/incremental/inlineSuspendFun.kt"); + } + + @Test + @TestMetadata("jsModule.kt") + public void testJsModule() throws Exception { + runTest("js/js.translator/testData/box/incremental/jsModule.kt"); + } + + @Test + @TestMetadata("multipleExport.kt") + public void testMultipleExport() throws Exception { + runTest("js/js.translator/testData/box/incremental/multipleExport.kt"); + } + + @Test + @TestMetadata("multipleReimport.kt") + public void testMultipleReimport() throws Exception { + runTest("js/js.translator/testData/box/incremental/multipleReimport.kt"); + } + + @Test + @TestMetadata("packagesWithSameName.kt") + public void testPackagesWithSameName() throws Exception { + runTest("js/js.translator/testData/box/incremental/packagesWithSameName.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("js/js.translator/testData/box/incremental/simple.kt"); + } + + @Test + @TestMetadata("sourceMapSourceEmbedding.kt") + public void testSourceMapSourceEmbedding() throws Exception { + runTest("js/js.translator/testData/box/incremental/sourceMapSourceEmbedding.kt"); + } + + @Test + @TestMetadata("syntheticStatement.kt") + public void testSyntheticStatement() throws Exception { + runTest("js/js.translator/testData/box/incremental/syntheticStatement.kt"); + } + } + @Nested @TestMetadata("js/js.translator/testData/box/inheritance") @TestDataPath("$PROJECT_ROOT") diff --git a/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/runners/AbstractParcelizeBoxTest.kt b/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/runners/AbstractParcelizeBoxTest.kt index dfe9682b1b5..0ba617d7961 100644 --- a/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/runners/AbstractParcelizeBoxTest.kt +++ b/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/runners/AbstractParcelizeBoxTest.kt @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.builders.configureClassicFrontendHandlersStep import org.jetbrains.kotlin.test.builders.configureFirHandlersStep -import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.REQUIRES_SEPARATE_PROCESS import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives.DIAGNOSTICS import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives.REPORT_ONLY_EXPLICITLY_DEFINED_DEBUG_INFO @@ -71,7 +70,7 @@ abstract class AbstractParcelizeBoxTestBase(::ParcelizeMainClassProvider)) + useAdditionalServices(service(::ParcelizeMainClassProvider)) useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)