Diagnostics tests with JVM backend
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
inline fun inlineFun1(p: () -> Unit) {
|
||||||
|
p()
|
||||||
|
<!INLINE_CALL_CYCLE, INLINE_CALL_CYCLE!>inlineFun2(p)<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun inlineFun2(p: () -> Unit) {
|
||||||
|
p()
|
||||||
|
<!INLINE_CALL_CYCLE, INLINE_CALL_CYCLE!>inlineFun1(p)<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public inline fun inlineFun1(/*0*/ p: () -> kotlin.Unit): kotlin.Unit
|
||||||
|
public inline fun inlineFun2(/*0*/ p: () -> kotlin.Unit): kotlin.Unit
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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.checkers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||||
|
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||||
|
import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
|
||||||
|
import org.jetbrains.kotlin.backend.jvm.jvmPhases
|
||||||
|
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||||
|
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
|
||||||
|
import org.jetbrains.kotlin.codegen.DefaultCodegenFactory
|
||||||
|
import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
|
||||||
|
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||||
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
|
import org.jetbrains.kotlin.context.ModuleContext
|
||||||
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||||
|
|
||||||
|
abstract class AbstractDiagnosticsTestWithJvmBackend : AbstractDiagnosticsTest() {
|
||||||
|
|
||||||
|
override fun analyzeModuleContents(
|
||||||
|
moduleContext: ModuleContext,
|
||||||
|
files: List<KtFile>,
|
||||||
|
moduleTrace: BindingTrace,
|
||||||
|
languageVersionSettings: LanguageVersionSettings,
|
||||||
|
separateModules: Boolean,
|
||||||
|
jvmTarget: JvmTarget
|
||||||
|
): AnalysisResult {
|
||||||
|
val analysisResult =
|
||||||
|
super.analyzeModuleContents(
|
||||||
|
moduleContext, files, moduleTrace, languageVersionSettings, separateModules, jvmTarget
|
||||||
|
)
|
||||||
|
|
||||||
|
val generationState =
|
||||||
|
GenerationState.Builder(
|
||||||
|
project, ClassBuilderFactories.TEST, analysisResult.moduleDescriptor, analysisResult.bindingContext,
|
||||||
|
files, environment.configuration
|
||||||
|
).setupGenerationState().build()
|
||||||
|
|
||||||
|
KotlinCodegenFacade.compileCorrectFiles(generationState)
|
||||||
|
|
||||||
|
for (diagnostic in generationState.collectedExtraJvmDiagnostics.all()) {
|
||||||
|
moduleTrace.report(diagnostic)
|
||||||
|
}
|
||||||
|
return analysisResult
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract fun GenerationState.Builder.setupGenerationState(): GenerationState.Builder
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class AbstractDiagnosticsTestWithOldJvmBackend : AbstractDiagnosticsTestWithJvmBackend() {
|
||||||
|
|
||||||
|
override fun GenerationState.Builder.setupGenerationState(): GenerationState.Builder =
|
||||||
|
codegenFactory(DefaultCodegenFactory).isIrBackend(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class AbstractDiagnosticsTestWithJvmIrBackend : AbstractDiagnosticsTestWithJvmBackend() {
|
||||||
|
|
||||||
|
override fun GenerationState.Builder.setupGenerationState(): GenerationState.Builder =
|
||||||
|
codegenFactory(
|
||||||
|
JvmIrCodegenFactory(
|
||||||
|
environment.configuration.get(CLIConfigurationKeys.PHASE_CONFIG)
|
||||||
|
?: PhaseConfig(jvmPhases)
|
||||||
|
)
|
||||||
|
).isIrBackend(true)
|
||||||
|
}
|
||||||
Generated
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.checkers;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
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("compiler/testData/diagnostics/testsWithJvmBackend")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class DiagnosticsTestWithJvmIrBackendGenerated extends AbstractDiagnosticsTestWithJvmIrBackend {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInTestsWithJvmBackend() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineCycle.kt")
|
||||||
|
public void testInlineCycle() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithJvmBackend/inlineCycle.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.checkers;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
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("compiler/testData/diagnostics/testsWithJvmBackend")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class DiagnosticsTestWithOldJvmBackendGenerated extends AbstractDiagnosticsTestWithOldJvmBackend {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInTestsWithJvmBackend() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineCycle.kt")
|
||||||
|
public void testInlineCycle() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithJvmBackend/inlineCycle.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -126,6 +126,14 @@ fun main(args: Array<String>) {
|
|||||||
model("diagnostics/testsWithExplicitApi")
|
model("diagnostics/testsWithExplicitApi")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass<AbstractDiagnosticsTestWithOldJvmBackend> {
|
||||||
|
model("diagnostics/testsWithJvmBackend")
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractDiagnosticsTestWithJvmIrBackend> {
|
||||||
|
model("diagnostics/testsWithJvmBackend")
|
||||||
|
}
|
||||||
|
|
||||||
testClass<AbstractMultiPlatformIntegrationTest> {
|
testClass<AbstractMultiPlatformIntegrationTest> {
|
||||||
model("multiplatform", extension = null, recursive = true, excludeParentDirs = true)
|
model("multiplatform", extension = null, recursive = true, excludeParentDirs = true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user