提交 23e704f3 编写于 作者: D Dmitriy Novozhilov

[TEST] Migrate AbstractDiagnosticsWithExplicitApi to new test runners

上级 c0e4452c
......@@ -64,6 +64,7 @@ class LanguageVersionSettingsBuilder {
analysisFlag(AnalysisFlags.ignoreDataFlowInAssert, trueOrNull(LanguageSettingsDirectives.IGNORE_DATA_FLOW_IN_ASSERT in directives)),
analysisFlag(AnalysisFlags.constraintSystemForOverloadResolution, directives.singleOrZeroValue(LanguageSettingsDirectives.CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION)),
analysisFlag(AnalysisFlags.allowResultReturnType, trueOrNull(LanguageSettingsDirectives.ALLOW_RESULT_RETURN_TYPE in directives)),
analysisFlag(AnalysisFlags.explicitApiMode, directives.singleOrZeroValue(LanguageSettingsDirectives.EXPLICIT_API_MODE)),
analysisFlag(JvmAnalysisFlags.jvmDefaultMode, directives.singleOrZeroValue(LanguageSettingsDirectives.JVM_DEFAULT_MODE)),
analysisFlag(JvmAnalysisFlags.inheritMultifileParts, trueOrNull(LanguageSettingsDirectives.INHERIT_MULTIFILE_PARTS in directives)),
......
......@@ -7,9 +7,11 @@ package org.jetbrains.kotlin.test.directives
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.ConstraintSystemForOverloadResolutionMode
import org.jetbrains.kotlin.config.ExplicitApiMode
import org.jetbrains.kotlin.config.JvmDefaultMode
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
@Suppress("RemoveExplicitTypeArguments")
object LanguageSettingsDirectives : SimpleDirectivesContainer() {
val LANGUAGE by stringDirective(
description = """
......@@ -45,9 +47,13 @@ object LanguageSettingsDirectives : SimpleDirectivesContainer() {
description = "Allow using Result in return type position"
)
val EXPLICIT_API_MODE by enumDirective<ExplicitApiMode>(
"Configures explicit API mode (AnalysisFlags.explicitApiMode)",
additionalParser = ExplicitApiMode.Companion::fromString
)
// --------------------- Jvm Analysis Flags ---------------------
@Suppress("RemoveExplicitTypeArguments")
val JVM_DEFAULT_MODE by enumDirective<JvmDefaultMode>(
description = "Configures corresponding analysis flag (JvmAnalysisFlags.jvmDefaultMode)",
additionalParser = JvmDefaultMode.Companion::fromStringOrNull
......
// SKIP_TXT
annotation class A
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.PROPERTY,
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.FUNCTION
)
public annotation class B
annotation class C(val a: String)
/**
* Foo1 KDoc
*/
@B
class Foo1() {}
public class Foo2() {
/**
* KDoc for methodWithAnnotations
*/
@B
fun methodWithAnnotations() {}
/**
* Property KDoc
*/
@B
var simple: Int = 10
}
public open class ClassWithOpen {
/**
* constructor KDoc
*/
@B
constructor() {}
/**
* KDoc for openAnnotatedMethod
*/
@B
open fun openAnnotatedMethod() {}
}
\ No newline at end of file
// SKIP_TXT
/**
* KDoc for Foo1
*/
class Foo1() {}
public class Foo2() {
/**
* KDoc for method
*/
fun method() {}
/**
* KDoc for method2
*/
public fun method2() {}
private fun method3() {}
fun implicit() = 10
public fun implicit2() = 10
public fun implicit3(): Int = 10
}
public open class ClassWithOpen() {
/**
* KDoc for method
*/
fun method() {}
/**
* KDoc for openMethod
*/
open fun openMethod() {}
}
public data class FooData(val i: Int, val s: String)
data class FooData2(val i: Int, val s: String)
public class WithNested {
class Nested {}
inner class Inner {}
}
enum class Foo { A, B }
public enum class Bar { A, B }
\ No newline at end of file
// SKIP_TXT
public class Bar {
companion object {}
}
public class Bar2 {
companion object MyCompanion {}
}
public class Bar3 {
/**
* Nested object KDoc
*/
object NestedObject {}
}
data class FooData2(val i: Int, val s: String) {
object NestedObject {}
}
\ No newline at end of file
// SKIP_TXT
public class Foo1 () {}
public class Foo2 constructor() {}
public class Foo3 public constructor() {}
public class Foo4 private constructor() {}
public class Foo5 {
/**
* constructor KDoc
*/
constructor() {}
}
public class Foo6 {
public constructor() {}
}
\ No newline at end of file
// !DIAGNOSTICS: -EXPERIMENTAL_FEATURE_WARNING
// SKIP_TXT
inline class Value1(val inner: Int)
public inline class Value2(val inner: Int)
inline class Value3(public val inner: Int)
public inline class Value4(public val inner: Int)
\ No newline at end of file
// SKIP_TXT
interface I1 {
fun i()
}
public interface I2 {
fun i()
}
public interface I3 {
public fun i()
public val v: Int
}
public interface I4 {
public fun i(): Int
public val v: Int
}
public class Impl: I3 {
override fun i() {}
override val v: Int
get() = 10
}
public class Impl2: I4 {
override fun i() = 10
override val v = 10
}
private class PrivateImpl: I4 {
override fun i() = 10
override val v = 10
}
// SKIP_TXT
public class Foo(val bar: Int, private var bar2: String, internal var bar3: Long, public var bar4: Int) {
/**
* Property KDoc
*/
var simple: Int = 10
public var simple2: Int = 10
val withGetter: Int
get() = 10
public val withGetter2: Int
get() = 10
var getterAndSetter: Int = 10
get() = field
set(v) { field = v }
public var getterAndSetter2: Int = 10
get() = field
set(v) { field = v }
}
\ No newline at end of file
// SKIP_TXT
// WITH_RUNTIME
public class A {
@PublishedApi
internal fun foo() = 1
}
\ No newline at end of file
// SKIP_TXT
/**
* foo KDoc
*/
fun foo() {}
public fun foo2() {}
fun bar() = 10
public fun bar2() = 10
public fun bar3(): Int = 10
......@@ -28200,6 +28200,76 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/testsWithExplicitApi")
@TestDataPath("$PROJECT_ROOT")
public class TestsWithExplicitApi extends AbstractDiagnosticTest {
@Test
public void testAllFilesPresentInTestsWithExplicitApi() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithExplicitApi"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("annotations.kt")
public void testAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/annotations.kt");
}
@Test
@TestMetadata("classes.kt")
public void testClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/classes.kt");
}
@Test
@TestMetadata("companionObject.kt")
public void testCompanionObject() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/companionObject.kt");
}
@Test
@TestMetadata("constructors.kt")
public void testConstructors() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/constructors.kt");
}
@Test
@TestMetadata("inlineClasses.kt")
public void testInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/inlineClasses.kt");
}
@Test
@TestMetadata("interfaces.kt")
public void testInterfaces() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/interfaces.kt");
}
@Test
@TestMetadata("mustBeEffectivelyPublic.kt")
public void testMustBeEffectivelyPublic() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/mustBeEffectivelyPublic.kt");
}
@Test
@TestMetadata("properties.kt")
public void testProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/properties.kt");
}
@Test
@TestMetadata("publishedApi.kt")
public void testPublishedApi() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/publishedApi.kt");
}
@Test
@TestMetadata("toplevel.kt")
public void testToplevel() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/toplevel.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/thisAndSuper")
@TestDataPath("$PROJECT_ROOT")
......@@ -28104,6 +28104,76 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/testsWithExplicitApi")
@TestDataPath("$PROJECT_ROOT")
public class TestsWithExplicitApi extends AbstractFirDiagnosticTest {
@Test
public void testAllFilesPresentInTestsWithExplicitApi() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithExplicitApi"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("annotations.kt")
public void testAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/annotations.kt");
}
@Test
@TestMetadata("classes.kt")
public void testClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/classes.kt");
}
@Test
@TestMetadata("companionObject.kt")
public void testCompanionObject() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/companionObject.kt");
}
@Test
@TestMetadata("constructors.kt")
public void testConstructors() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/constructors.kt");
}
@Test
@TestMetadata("inlineClasses.kt")
public void testInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/inlineClasses.kt");
}
@Test
@TestMetadata("interfaces.kt")
public void testInterfaces() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/interfaces.kt");
}
@Test
@TestMetadata("mustBeEffectivelyPublic.kt")
public void testMustBeEffectivelyPublic() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/mustBeEffectivelyPublic.kt");
}
@Test
@TestMetadata("properties.kt")
public void testProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/properties.kt");
}
@Test
@TestMetadata("publishedApi.kt")
public void testPublishedApi() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/publishedApi.kt");
}
@Test
@TestMetadata("toplevel.kt")
public void testToplevel() throws Exception {
runTest("compiler/testData/diagnostics/tests/testsWithExplicitApi/toplevel.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/thisAndSuper")
@TestDataPath("$PROJECT_ROOT")
......@@ -5,10 +5,13 @@
package org.jetbrains.kotlin.test.runners
import org.jetbrains.kotlin.config.ExplicitApiMode
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.EXPLICIT_API_MODE
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticsHandler
import org.jetbrains.kotlin.test.frontend.classic.handlers.DeclarationsDumpHandler
......@@ -61,5 +64,11 @@ abstract class AbstractDiagnosticTest : AbstractKotlinCompilerTest() {
+WITH_STDLIB
}
}
forTestsMatching("compiler/testData/diagnostics/tests/testsWithExplicitApi/*") {
defaultDirectives {
EXPLICIT_API_MODE with ExplicitApiMode.STRICT
}
}
}
}
/*
* Copyright 2010-2019 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.config.*
import org.jetbrains.kotlin.test.ConfigurationKind
abstract class AbstractDiagnosticsWithExplicitApi : AbstractDiagnosticsTest() {
override fun defaultLanguageVersionSettings(): LanguageVersionSettings =
CompilerTestLanguageVersionSettings(
DEFAULT_DIAGNOSTIC_TESTS_FEATURES,
LanguageVersionSettingsImpl.DEFAULT.apiVersion,
LanguageVersionSettingsImpl.DEFAULT.languageVersion,
mapOf(AnalysisFlags.explicitApiMode to ExplicitApiMode.STRICT)
)
}
\ No newline at end of file
/*
* 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/testsWithExplicitApi")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class DiagnosticsWithExplicitApiGenerated extends AbstractDiagnosticsWithExplicitApi {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInTestsWithExplicitApi() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithExplicitApi"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotations.kt")
public void testAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/annotations.kt");
}
@TestMetadata("classes.kt")
public void testClasses() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/classes.kt");
}
@TestMetadata("companionObject.kt")
public void testCompanionObject() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/companionObject.kt");
}
@TestMetadata("constructors.kt")
public void testConstructors() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/constructors.kt");
}
@TestMetadata("inlineClasses.kt")
public void testInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/inlineClasses.kt");
}
@TestMetadata("interfaces.kt")
public void testInterfaces() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/interfaces.kt");
}
@TestMetadata("mustBeEffectivelyPublic.kt")
public void testMustBeEffectivelyPublic() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/mustBeEffectivelyPublic.kt");
}
@TestMetadata("properties.kt")
public void testProperties() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/properties.kt");
}
@TestMetadata("publishedApi.kt")
public void testPublishedApi() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/publishedApi.kt");
}
@TestMetadata("toplevel.kt")
public void testToplevel() throws Exception {
runTest("compiler/testData/diagnostics/testsWithExplicitApi/toplevel.kt");
}
}
......@@ -92,10 +92,6 @@ fun main(args: Array<String>) {
model("diagnostics/testsWithUnsignedTypes")
}
testClass<AbstractDiagnosticsWithExplicitApi> {
model("diagnostics/testsWithExplicitApi")
}
testClass<AbstractDiagnosticsTestWithOldJvmBackend> {
model("diagnostics/testsWithJvmBackend", targetBackend = TargetBackend.JVM_OLD)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册