diff --git a/compiler/android-tests/android-tests.iml b/compiler/android-tests/android-tests.iml index 4d66298af68..c79988410a0 100644 --- a/compiler/android-tests/android-tests.iml +++ b/compiler/android-tests/android-tests.iml @@ -18,6 +18,5 @@ - \ No newline at end of file diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt index 0d0facca92a..ebf935efe94 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt @@ -31,25 +31,20 @@ private val packagePattern = Pattern.compile("(?m)^\\s*package[ |\t]+([\\w|\\.]* private val importPattern = Pattern.compile("import[ |\t]([\\w|]*\\.)") -internal fun genFiles( - testFileName: String, - filePath: String, - fileContent: String, - filesHolder: CodegenTestsOnAndroidGenerator.FilesWriter -): FqName? { - val testFiles = createTestFiles(testFileName, fileContent) +internal fun genFiles(file: File, fileContent: String, filesHolder: CodegenTestsOnAndroidGenerator.FilesWriter): FqName? { + val testFiles = createTestFiles(file, fileContent) if (testFiles.filter { it.name.endsWith(".java") }.isNotEmpty()) { //TODO support java files - return null + return null; } val ktFiles = testFiles.filter { it.name.endsWith(".kt") } if (ktFiles.isEmpty()) return null - val newPackagePrefix = filePath.replace("\\\\|-|\\.|/".toRegex(), "_") + val newPackagePrefix = file.path.replace("\\\\|-|\\.|/".toRegex(), "_") val oldPackage = Ref() val isSingle = testFiles.size == 1 val resultFiles = testFiles.map { - val fileName = if (isSingle) it.name else testFileName.substringBeforeLast(".kt") + "/" + it.name + val fileName = if (isSingle) it.name else file.name.substringBeforeLast(".kt") + "/" + it.name TestClassInfo( fileName, changePackage(newPackagePrefix, it.content, oldPackage), @@ -82,14 +77,14 @@ internal fun genFiles( val boxFiles = resultFiles.filter { hasBoxMethod(it.content) } if (boxFiles.size != 1) { - println("Several box methods in $filePath") + println("Several box methods in $file") } return boxFiles.last().newClassId } -private fun createTestFiles(fileName: String, expectedText: String): List { - val files = KotlinTestUtils.createTestFiles(fileName, expectedText, object : KotlinTestUtils.TestFileFactoryNoModules() { +private fun createTestFiles(file: File, expectedText: String): List { + val files = KotlinTestUtils.createTestFiles(file.name, expectedText, object : KotlinTestUtils.TestFileFactoryNoModules() { override fun create(fileName: String, text: String, directives: Map): CodegenTestCase.TestFile { return CodegenTestCase.TestFile(fileName, text) } diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java index 79ca4ca959e..3a9c1456574 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java @@ -25,7 +25,6 @@ import org.jetbrains.kotlin.backend.common.output.OutputFileCollection; import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; -import org.jetbrains.kotlin.codegen.AbstractAdditionalCoroutineBlackBoxCodegenTest; import org.jetbrains.kotlin.codegen.CodegenTestFiles; import org.jetbrains.kotlin.codegen.GenerationUtils; import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime; @@ -253,46 +252,17 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase { InTextDirectivesUtils.isDirectiveDefined(fullFileText, "WITH_REFLECT") ? holderFull : holderMock; filesHolder = fullFileText.contains("+JVM.INHERIT_MULTIFILE_PARTS") ? holderInheritMFP : filesHolder; - if (!generateTest(file.getName(), file.getPath(), fullFileText, printer, filesHolder)) continue; - - if (fullFileText.contains(AbstractAdditionalCoroutineBlackBoxCodegenTest.INTERCEPT_RESUME_PLACEHOLDER)) { - int counter = 1; - for (String replacement : AbstractAdditionalCoroutineBlackBoxCodegenTest.ALL_REPLACEMENTS) { - String testFileName = file.getName().replace(".kt", "_" + counter + ".kt"); - String filePath = file.getPath().replace(".kt", "_" + counter + ".kt"); - generateTest( - testFileName, - filePath, - fullFileText.replace( - AbstractAdditionalCoroutineBlackBoxCodegenTest.INTERCEPT_RESUME_PLACEHOLDER, replacement - ), - printer, - filesHolder - ); - - counter++; - } - } + FqName classWithBoxMethod = AndroidTestGeneratorKt.genFiles(file, fullFileText, filesHolder); + if (classWithBoxMethod == null) + continue; + String generatedTestName = generateTestName(file.getName()); + generateTestMethod(printer, generatedTestName, classWithBoxMethod.asString(), StringUtil.escapeStringCharacters(file.getPath())); } } } } - private boolean generateTest( - @NotNull String testFileName, - @NotNull String filePath, - @NotNull String fullFileText, - @NotNull Printer printer, - @NotNull FilesWriter filesHolder - ) { - FqName classWithBoxMethod = AndroidTestGeneratorKt.genFiles(testFileName, filePath, fullFileText, filesHolder); - if (classWithBoxMethod == null) return false; - - String generatedTestName = generateTestName(testFileName); - generateTestMethod(printer, generatedTestName, classWithBoxMethod.asString(), StringUtil.escapeStringCharacters(filePath)); - return true; - } private static boolean hasBoxMethod(String text) { diff --git a/compiler/testData/codegen/box/coroutines/await.kt b/compiler/testData/codegen/box/coroutines/await.kt index 27843579618..b10b9474d8a 100644 --- a/compiler/testData/codegen/box/coroutines/await.kt +++ b/compiler/testData/codegen/box/coroutines/await.kt @@ -1,6 +1,5 @@ // WITH_RUNTIME // WITH_COROUTINES -// NO_INTERCEPT_RESUME_TESTS // FILE: promise.kt import kotlin.coroutines.* diff --git a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt index 69ff61f6390..b45bcbc8b6f 100644 --- a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt +++ b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt @@ -12,8 +12,6 @@ class Controller { fun foo() { result = true } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt index fc1059e1a1a..f62442290d5 100644 --- a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt +++ b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt @@ -7,8 +7,6 @@ class Controller { x.resume(a + "#" + (i + 1)) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/emptyClosure.kt b/compiler/testData/codegen/box/coroutines/emptyClosure.kt index b3df5ba9f12..ec7bd51ccb7 100644 --- a/compiler/testData/codegen/box/coroutines/emptyClosure.kt +++ b/compiler/testData/codegen/box/coroutines/emptyClosure.kt @@ -10,8 +10,6 @@ class Controller { x.resume("OK") SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } diff --git a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt index 4b030d434ef..daf04bb26b0 100644 --- a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt +++ b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt @@ -7,8 +7,6 @@ class Controller { x.resume(v) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/illegalState.kt b/compiler/testData/codegen/box/coroutines/illegalState.kt index 7741cda6d1a..2a793ccc6bb 100644 --- a/compiler/testData/codegen/box/coroutines/illegalState.kt +++ b/compiler/testData/codegen/box/coroutines/illegalState.kt @@ -1,7 +1,6 @@ // WITH_RUNTIME // WITH_COROUTINES // TARGET_BACKEND: JVM -// NO_INTERCEPT_RESUME_TESTS import kotlin.coroutines.* suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> diff --git a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt index 37f76b41bed..e5ced90ddf2 100644 --- a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt +++ b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt @@ -19,8 +19,6 @@ class Controller { suspend inline fun suspendInline(crossinline b: () -> String): String = suspendInline(b()) suspend inline fun suspendInline(): String = suspendInline({ T::class.simpleName!! }) - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt index e03b5afe3fa..32394140a43 100644 --- a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt +++ b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt @@ -8,8 +8,6 @@ class Controller { x.resume((i++).toString()) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt index 7ad0e1874f8..9baa09c2c8c 100644 --- a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt +++ b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt @@ -15,8 +15,6 @@ class Controller { x.resume(Continuation::class.isInstance(y as Continuation<*>)) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt index 0f190d3b6d7..883c132adcf 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt index a1cf038a9a9..3845a14459a 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt index c469756b9e8..623a883ecbd 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt index a8abe172293..c9a816c38f6 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt index 77ab204d475..9f0e1e0f49a 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt index 8cf35efbff7..348f37eed9a 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt index 628f16827ac..f249490ddda 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt @@ -8,8 +8,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt index d3e995f9352..1164710b546 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt index 8557055d2c9..b282defd3f1 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt @@ -8,8 +8,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt index cfd7dc23d10..214bb2c002a 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt @@ -7,8 +7,6 @@ class Controller { x.resume(Unit) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/interceptResume.kt b/compiler/testData/codegen/box/coroutines/interceptResume.kt index 9613d7b35e1..409411ebad3 100644 --- a/compiler/testData/codegen/box/coroutines/interceptResume.kt +++ b/compiler/testData/codegen/box/coroutines/interceptResume.kt @@ -1,6 +1,5 @@ // WITH_RUNTIME // WITH_COROUTINES -// NO_INTERCEPT_RESUME_TESTS import kotlin.coroutines.* class Controller { diff --git a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt index c7c278227c8..8c4b170523a 100644 --- a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt +++ b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt @@ -7,8 +7,6 @@ class Controller { x.resume("OK") SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt index aab87e880f5..5bd5192e380 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt @@ -11,8 +11,6 @@ class Controller { x.resume("OK") SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } // MODULE: main(controller) diff --git a/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt b/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt index 144e3a43bda..19b79261a3a 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt @@ -14,8 +14,6 @@ class Controller { } inline suspend fun String.inlineSuspendHere(): String = suspendHere() - - // INTERCEPT_RESUME_PLACEHOLDER } suspend fun Controller.suspendExtension(v: String): String = v.suspendHere() diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt index c766fe6d932..6de7143a57c 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt @@ -16,8 +16,6 @@ class Controller { lastSuspension = null x.resume("56") } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt index 7559fe7f181..c192859f2d1 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt @@ -16,8 +16,6 @@ class Controller { lastSuspension = null x.resume("56") } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt index 5221d5fda53..1ea6395e75e 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt @@ -16,8 +16,6 @@ class Controller { lastSuspension = null x.resume("56") } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt index d08073a6bd5..e96aee18076 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt @@ -16,8 +16,6 @@ class Controller { lastSuspension = null x.resume("56") } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt index 9667017257c..04b147fa218 100644 --- a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt +++ b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt @@ -32,8 +32,6 @@ class Controller { postponedActions.removeAt(0) } } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/simpleException.kt b/compiler/testData/codegen/box/coroutines/simpleException.kt index 52fc0c3d146..80a1622a038 100644 --- a/compiler/testData/codegen/box/coroutines/simpleException.kt +++ b/compiler/testData/codegen/box/coroutines/simpleException.kt @@ -7,8 +7,6 @@ class Controller { x.resumeWithException(RuntimeException("OK")) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt index eca0c8ab351..04294aa9e4b 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt @@ -4,8 +4,6 @@ import kotlin.coroutines.* class Controller { suspend fun suspendHere(): String = throw RuntimeException("OK") - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt index 9cfb1fe7fbb..6708e8a2714 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt @@ -12,8 +12,6 @@ class Controller { suspend inline fun suspendInline(crossinline b: () -> String): String = suspendInline(b()) suspend inline fun suspendInline(): String = suspendInline({ T::class.simpleName!! }) - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt index fac7fc9c42d..31e1bc7f640 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt @@ -4,8 +4,6 @@ import kotlin.coroutines.* class Controller { suspend fun suspendHere() = "OK" - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt index bd4c7c87a46..7dbba4b82e9 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt @@ -9,8 +9,6 @@ class Controller { suspend fun suspendThere(): String = suspendWithCurrentContinuation { x -> "?" } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt index b1b39797ace..473588c4c65 100644 --- a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt +++ b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt @@ -9,8 +9,6 @@ class Controller { x.resume("OK") SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/suspendExtension.kt b/compiler/testData/codegen/box/coroutines/suspendExtension.kt index b2ab62fa9f0..5a5baa2a4f7 100644 --- a/compiler/testData/codegen/box/coroutines/suspendExtension.kt +++ b/compiler/testData/codegen/box/coroutines/suspendExtension.kt @@ -10,8 +10,6 @@ class Controller { } inline suspend fun String.inlineSuspendHere(): String = suspendHere() - - // INTERCEPT_RESUME_PLACEHOLDER } suspend fun Controller.suspendExtension(v: String): String = v.suspendHere() diff --git a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt index f3f50be9914..b54775cce3e 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt @@ -7,8 +7,6 @@ class Controller { x.resume(v * 2) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt index 6414e7ffb9b..afb47bd0213 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt @@ -12,8 +12,6 @@ class Controller { x.resume("?") SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt index 6992fe0dbad..d765256ab46 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt @@ -17,8 +17,6 @@ class Controller { x.resume(v) SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt index 629055790c4..32e11472980 100644 --- a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt @@ -32,8 +32,6 @@ class Controller { postponedActions.removeAt(0) } } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt index 41f3f50c53e..302fe293b38 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt @@ -8,8 +8,6 @@ class Controller { SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt index 8edc919578d..8a8f5f909a0 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt @@ -32,8 +32,6 @@ class Controller { postponedActions.removeAt(0) } } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt index 746438e2deb..02879c0c320 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt @@ -7,8 +7,6 @@ class Controller { x.resume("OK") SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt index eb4ad0a4276..8de5125aea9 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt @@ -7,8 +7,6 @@ class Controller { x.resume("OK") SUSPENDED } - - // INTERCEPT_RESUME_PLACEHOLDER } fun builder(c: suspend Controller.() -> Unit) { diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java index a4492c55f5f..5e2291826a8 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -896,24 +896,13 @@ public class KotlinTestUtils { assertTestClassPresentByMetadata(testCaseClass, file); } } - else if (filenamePattern.matcher(file.getName()).matches() && isCompatibleTarget(targetBackend, file) && - !isThereCustomReasonToSkip(file, testCaseClass)) { + else if (filenamePattern.matcher(file.getName()).matches() && isCompatibleTarget(targetBackend, file)) { assertFilePathPresent(file, rootFile, filePaths); } } } } - private static boolean isThereCustomReasonToSkip(File file, Class aClass) { - if (!aClass.getSuperclass().getSimpleName().equals("AbstractAdditionalCoroutineBlackBoxCodegenTest")) return false; - try { - return InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(file), "// NO_INTERCEPT_RESUME_TESTS"); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - public static void assertAllTestsPresentInSingleGeneratedClass( @NotNull Class testCaseClass, @NotNull File testDataDir, diff --git a/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt b/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt index 07da2b71222..aa51b6277f2 100644 --- a/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt @@ -27,15 +27,13 @@ class ModulesDependenciesTest : TestCase() { val GENERATORS_MODULE_FILE = File("generators/generators.iml") val COMPILER_TESTS_JAVA8_MODULE_FILE = File("compiler/tests-java8/compiler-tests-java8.iml") val NON_COMPILER_TESTS_MODULE_FILE = File("non-compiler-tests/non-compiler-tests.iml") - val ANDROID_TESTS_MODULE_FILE = File("compiler/android-tests/android-tests.iml") val COMPILER_TESTS_MODULE_NAME = COMPILER_TESTS_MODULE_FILE.nameWithoutExtension - val MODULES_CAN_DEPEND_ON_COMPILER_TESTS = listOf(COMPILER_TESTS_JAVA8_MODULE_FILE, GENERATORS_MODULE_FILE, ANDROID_TESTS_MODULE_FILE) + val MODULES_CAN_DEPEND_ON_COMPILER_TESTS = listOf(COMPILER_TESTS_JAVA8_MODULE_FILE, GENERATORS_MODULE_FILE) fun testModulesPresent() { val modules = listOf( - COMPILER_TESTS_MODULE_FILE, GENERATORS_MODULE_FILE, COMPILER_TESTS_JAVA8_MODULE_FILE, NON_COMPILER_TESTS_MODULE_FILE, - ANDROID_TESTS_MODULE_FILE + COMPILER_TESTS_MODULE_FILE, GENERATORS_MODULE_FILE, COMPILER_TESTS_JAVA8_MODULE_FILE, NON_COMPILER_TESTS_MODULE_FILE ) for (module in modules) { diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractAdditionalCoroutineBlackBoxCodegenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractAdditionalCoroutineBlackBoxCodegenTest.kt deleted file mode 100644 index 9463e9295f6..00000000000 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractAdditionalCoroutineBlackBoxCodegenTest.kt +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2010-2016 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.codegen - -import org.junit.Assert -import java.io.File - -abstract class AbstractAdditionalCoroutineBlackBoxCodegenTest : AbstractBlackBoxCodegenTest() { - companion object { - private val callLambda = """ - | operator inline fun interceptResume(crossinline x: () -> Unit) { - | x() - | } - """.trimMargin() - - private val sendToLambda = """ - | operator inline fun interceptResume(crossinline x: () -> Unit) { - | myInvokeLater { x() } - | } - | - | fun myInvokeLater(block: () -> Unit) { - | block() - | } - """.trimMargin() - - private val makeRunnableSamConstructor = """ - | operator inline fun interceptResume(crossinline x: () -> Unit) { - | myInvokeLater(Runnable { x() }) - | } - | - | fun myInvokeLater(r: java.lang.Runnable) { - | r.run() - | } - """.trimMargin() - - private val makeRunnableSamAdapter = """ - | operator inline fun interceptResume(crossinline x: () -> Unit) { - | val t = Thread { x() } - | t.run() // run in same Thread - | } - | - """.trimMargin() - - // That's how asyncUI's implementation should look like (but it should call SwingUtilities.invokeLater instead if Thread) - private val bothSamAndPlainExecution1 = """ - | val TRUE = hashCode() % 2 == 0 || hashCode() xor 1 == 1 - | operator inline fun interceptResume(crossinline x: () -> Unit) { - | if (TRUE) { - | x() - | } else { - | val t = Thread { x() } - | t.run() - | } - | } - | - """.trimMargin() - - private val bothSamAndPlainExecution2 = """ - | val FALSE = !(hashCode() % 2 == 0 || hashCode() xor 1 == 1) - | operator inline fun interceptResume(crossinline x: () -> Unit) { - | if (FALSE) { - | x() - | } else { - | val t = Thread { x() } - | t.run() - | } - | } - | - """.trimMargin() - - private val noInline = """ - | operator fun interceptResume(x: () -> Unit) { - | x() - | } - """.trimMargin() - - @JvmField - val ALL_REPLACEMENTS = - listOf(callLambda, sendToLambda, makeRunnableSamConstructor, makeRunnableSamAdapter, bothSamAndPlainExecution1, - bothSamAndPlainExecution2, noInline - ) - - const val INTERCEPT_RESUME_PLACEHOLDER = "// INTERCEPT_RESUME_PLACEHOLDER" - } - - override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { - // add "// NO_INTERCEPT_RESUME_TESTS" directive and run "Generate tests" - // if you think that interceptResume is irrelevant for the test - Assert.assertTrue("No placeholder in $wholeFile", files.any { it.content.contains(INTERCEPT_RESUME_PLACEHOLDER) }) - for (replacement in ALL_REPLACEMENTS) { - - try { - super.doMultiFileTest( - wholeFile, - files.map { TestFile(it.name, it.content.replace(INTERCEPT_RESUME_PLACEHOLDER, replacement)) }, - javaFilesDir - ) - } - catch(t: Throwable) { - throw RuntimeException("Fail for replacement: \n$replacement", t) - } - - this.initializedClassLoader = null - } - } -} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AdditionalCoroutineBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/AdditionalCoroutineBlackBoxCodegenTestGenerated.java deleted file mode 100644 index 2e21997c2cb..00000000000 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AdditionalCoroutineBlackBoxCodegenTestGenerated.java +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright 2010-2016 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.codegen; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -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("compiler/testData/codegen/box/coroutines") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class AdditionalCoroutineBlackBoxCodegenTestGenerated extends AbstractAdditionalCoroutineBlackBoxCodegenTest { - public void testAllFilesPresentInCoroutines() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("beginWithException.kt") - public void testBeginWithException() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/beginWithException.kt"); - doTest(fileName); - } - - @TestMetadata("beginWithExceptionNoHandleException.kt") - public void testBeginWithExceptionNoHandleException() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt"); - doTest(fileName); - } - - @TestMetadata("coercionToUnit.kt") - public void testCoercionToUnit() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/coercionToUnit.kt"); - doTest(fileName); - } - - @TestMetadata("controllerAccessFromInnerLambda.kt") - public void testControllerAccessFromInnerLambda() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt"); - doTest(fileName); - } - - @TestMetadata("defaultParametersInSuspend.kt") - public void testDefaultParametersInSuspend() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt"); - doTest(fileName); - } - - @TestMetadata("emptyClosure.kt") - public void testEmptyClosure() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/emptyClosure.kt"); - doTest(fileName); - } - - @TestMetadata("falseUnitCoercion.kt") - public void testFalseUnitCoercion() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt"); - doTest(fileName); - } - - @TestMetadata("generate.kt") - public void testGenerate() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/generate.kt"); - doTest(fileName); - } - - @TestMetadata("handleException.kt") - public void testHandleException() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleException.kt"); - doTest(fileName); - } - - @TestMetadata("handleResultCallEmptyBody.kt") - public void testHandleResultCallEmptyBody() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt"); - doTest(fileName); - } - - @TestMetadata("handleResultNonUnitExpression.kt") - public void testHandleResultNonUnitExpression() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt"); - doTest(fileName); - } - - @TestMetadata("handleResultSuspended.kt") - public void testHandleResultSuspended() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleResultSuspended.kt"); - doTest(fileName); - } - - @TestMetadata("inlineSuspendFunction.kt") - public void testInlineSuspendFunction() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt"); - doTest(fileName); - } - - @TestMetadata("inlinedTryCatchFinally.kt") - public void testInlinedTryCatchFinally() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt"); - doTest(fileName); - } - - @TestMetadata("innerSuspensionCalls.kt") - public void testInnerSuspensionCalls() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt"); - doTest(fileName); - } - - @TestMetadata("instanceOfContinuation.kt") - public void testInstanceOfContinuation() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt"); - doTest(fileName); - } - - @TestMetadata("iterateOverArray.kt") - public void testIterateOverArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/iterateOverArray.kt"); - doTest(fileName); - } - - @TestMetadata("kt12958.kt") - public void testKt12958() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/kt12958.kt"); - doTest(fileName); - } - - @TestMetadata("lastExpressionIsLoop.kt") - public void testLastExpressionIsLoop() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt"); - doTest(fileName); - } - - @TestMetadata("lastStatementInc.kt") - public void testLastStatementInc() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastStatementInc.kt"); - doTest(fileName); - } - - @TestMetadata("lastStementAssignment.kt") - public void testLastStementAssignment() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastStementAssignment.kt"); - doTest(fileName); - } - - @TestMetadata("lastUnitExpression.kt") - public void testLastUnitExpression() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastUnitExpression.kt"); - doTest(fileName); - } - - @TestMetadata("multipleInvokeCalls.kt") - public void testMultipleInvokeCalls() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt"); - doTest(fileName); - } - - @TestMetadata("multipleInvokeCallsInsideInlineLambda1.kt") - public void testMultipleInvokeCallsInsideInlineLambda1() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt"); - doTest(fileName); - } - - @TestMetadata("multipleInvokeCallsInsideInlineLambda2.kt") - public void testMultipleInvokeCallsInsideInlineLambda2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt"); - doTest(fileName); - } - - @TestMetadata("multipleInvokeCallsInsideInlineLambda3.kt") - public void testMultipleInvokeCallsInsideInlineLambda3() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt"); - doTest(fileName); - } - - @TestMetadata("nestedTryCatch.kt") - public void testNestedTryCatch() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nestedTryCatch.kt"); - doTest(fileName); - } - - @TestMetadata("noSuspensionPoints.kt") - public void testNoSuspensionPoints() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt"); - doTest(fileName); - } - - @TestMetadata("nonLocalReturnFromInlineLambda.kt") - public void testNonLocalReturnFromInlineLambda() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt"); - doTest(fileName); - } - - @TestMetadata("nonLocalReturnFromInlineLambdaDeep.kt") - public void testNonLocalReturnFromInlineLambdaDeep() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt"); - doTest(fileName); - } - - @TestMetadata("returnByLabel.kt") - public void testReturnByLabel() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/returnByLabel.kt"); - doTest(fileName); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/simple.kt"); - doTest(fileName); - } - - @TestMetadata("simpleException.kt") - public void testSimpleException() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/simpleException.kt"); - doTest(fileName); - } - - @TestMetadata("simpleWithHandleResult.kt") - public void testSimpleWithHandleResult() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt"); - doTest(fileName); - } - - @TestMetadata("statementLikeLastExpression.kt") - public void testStatementLikeLastExpression() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt"); - doTest(fileName); - } - - @TestMetadata("suspendDelegation.kt") - public void testSuspendDelegation() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendDelegation.kt"); - doTest(fileName); - } - - @TestMetadata("suspendExtension.kt") - public void testSuspendExtension() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendExtension.kt"); - doTest(fileName); - } - - @TestMetadata("suspendFromInlineLambda.kt") - public void testSuspendFromInlineLambda() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt"); - doTest(fileName); - } - - @TestMetadata("suspendInCycle.kt") - public void testSuspendInCycle() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendInCycle.kt"); - doTest(fileName); - } - - @TestMetadata("suspendInTheMiddleOfObjectConstruction.kt") - public void testSuspendInTheMiddleOfObjectConstruction() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt"); - doTest(fileName); - } - - @TestMetadata("tryCatchFinallyWithHandleResult.kt") - public void testTryCatchFinallyWithHandleResult() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt"); - doTest(fileName); - } - - @TestMetadata("tryCatchWithHandleResult.kt") - public void testTryCatchWithHandleResult() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt"); - doTest(fileName); - } - - @TestMetadata("tryFinallyInsideInlineLambda.kt") - public void testTryFinallyInsideInlineLambda() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt"); - doTest(fileName); - } - - @TestMetadata("tryFinallyWithHandleResult.kt") - public void testTryFinallyWithHandleResult() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt"); - doTest(fileName); - } - - @TestMetadata("varValueConflictsWithTable.kt") - public void testVarValueConflictsWithTable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt"); - doTest(fileName); - } - - @TestMetadata("varValueConflictsWithTableSameSort.kt") - public void testVarValueConflictsWithTableSameSort() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt"); - doTest(fileName); - } - - @TestMetadata("compiler/testData/codegen/box/coroutines/controlFlow") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ControlFlow extends AbstractAdditionalCoroutineBlackBoxCodegenTest { - public void testAllFilesPresentInControlFlow() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/controlFlow"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("breakFinally.kt") - public void testBreakFinally() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt"); - doTest(fileName); - } - - @TestMetadata("breakStatement.kt") - public void testBreakStatement() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt"); - doTest(fileName); - } - - @TestMetadata("doWhileStatement.kt") - public void testDoWhileStatement() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt"); - doTest(fileName); - } - - @TestMetadata("forContinue.kt") - public void testForContinue() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt"); - doTest(fileName); - } - - @TestMetadata("forStatement.kt") - public void testForStatement() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt"); - doTest(fileName); - } - - @TestMetadata("ifStatement.kt") - public void testIfStatement() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt"); - doTest(fileName); - } - - @TestMetadata("returnFromFinally.kt") - public void testReturnFromFinally() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt"); - doTest(fileName); - } - - @TestMetadata("switchLikeWhen.kt") - public void testSwitchLikeWhen() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt"); - doTest(fileName); - } - - @TestMetadata("throwFromCatch.kt") - public void testThrowFromCatch() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt"); - doTest(fileName); - } - - @TestMetadata("throwInTryWithHandleResult.kt") - public void testThrowInTryWithHandleResult() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt"); - doTest(fileName); - } - - @TestMetadata("whileStatement.kt") - public void testWhileStatement() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt"); - doTest(fileName); - } - } - - @TestMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class IntLikeVarSpilling extends AbstractAdditionalCoroutineBlackBoxCodegenTest { - public void testAllFilesPresentInIntLikeVarSpilling() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/intLikeVarSpilling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("complicatedMerge.kt") - public void testComplicatedMerge() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt"); - doTest(fileName); - } - - @TestMetadata("i2bResult.kt") - public void testI2bResult() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt"); - doTest(fileName); - } - - @TestMetadata("loadFromBooleanArray.kt") - public void testLoadFromBooleanArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt"); - doTest(fileName); - } - - @TestMetadata("loadFromByteArray.kt") - public void testLoadFromByteArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt"); - doTest(fileName); - } - - @TestMetadata("noVariableInTable.kt") - public void testNoVariableInTable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt"); - doTest(fileName); - } - - @TestMetadata("sameIconst1ManyVars.kt") - public void testSameIconst1ManyVars() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); - doTest(fileName); - } - - @TestMetadata("usedInArrayStore.kt") - public void testUsedInArrayStore() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt"); - doTest(fileName); - } - - @TestMetadata("usedInMethodCall.kt") - public void testUsedInMethodCall() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt"); - doTest(fileName); - } - - @TestMetadata("usedInPutfield.kt") - public void testUsedInPutfield() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt"); - doTest(fileName); - } - - @TestMetadata("usedInVarStore.kt") - public void testUsedInVarStore() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt"); - doTest(fileName); - } - } - - @TestMetadata("compiler/testData/codegen/box/coroutines/multiModule") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class MultiModule extends AbstractAdditionalCoroutineBlackBoxCodegenTest { - public void testAllFilesPresentInMultiModule() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt"); - doTest(fileName); - } - - @TestMetadata("suspendExtension.kt") - public void testSuspendExtension() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt"); - doTest(fileName); - } - } - - @TestMetadata("compiler/testData/codegen/box/coroutines/stackUnwinding") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class StackUnwinding extends AbstractAdditionalCoroutineBlackBoxCodegenTest { - public void testAllFilesPresentInStackUnwinding() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/stackUnwinding"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("exception.kt") - public void testException() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt"); - doTest(fileName); - } - - @TestMetadata("inlineSuspendFunction.kt") - public void testInlineSuspendFunction() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt"); - doTest(fileName); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt"); - doTest(fileName); - } - - @TestMetadata("suspendInCycle.kt") - public void testSuspendInCycle() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt"); - doTest(fileName); - } - } -} diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 4597155aebf..9b04eb743ae 100755 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -255,10 +255,6 @@ fun main(args: Array) { model("codegen/boxAgainstJava") } - testClass { - model("codegen/box/coroutines") - } - testClass { model("codegen/script", extension = "kts") } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java index b57eea85073..33328d0ac78 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java @@ -235,7 +235,7 @@ public class SimpleTestClassModel implements TestClassModel { } @Override - public boolean shouldBeGenerated(@NotNull String baseClassName) { + public boolean shouldBeGenerated() { return true; } } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java index 98b93f1e1ec..72e596523c3 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java @@ -20,14 +20,12 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.codegen.AbstractAdditionalCoroutineBlackBoxCodegenTest; import org.jetbrains.kotlin.test.InTextDirectivesUtils; import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.utils.Printer; import java.io.File; -import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -104,19 +102,8 @@ public class SimpleTestMethodModel implements TestMethodModel { } @Override - public boolean shouldBeGenerated(@NotNull String baseClassName) { - if (!InTextDirectivesUtils.isCompatibleTarget(targetBackend, file)) { - return false; - } - - if (!baseClassName.equals(AbstractAdditionalCoroutineBlackBoxCodegenTest.class.getSimpleName())) return true; - - try { - return !InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(file), "// NO_INTERCEPT_RESUME_TESTS"); - } - catch (IOException e) { - throw new RuntimeException(e); - } + public boolean shouldBeGenerated() { + return InTextDirectivesUtils.isCompatibleTarget(targetBackend, file); } @NotNull diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java index eba95adbb78..9a57d59655c 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java @@ -162,7 +162,7 @@ public class SingleClassTestModel implements TestClassModel { } @Override - public boolean shouldBeGenerated(@NotNull String baseClassName) { + public boolean shouldBeGenerated() { return true; } } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java index 42f7fbdcda9..85c0d1f6fe8 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java @@ -164,7 +164,7 @@ public class TestGenerator { for (Iterator iterator = testMethods.iterator(); iterator.hasNext(); ) { MethodModel methodModel = iterator.next(); - if (!methodModel.shouldBeGenerated(baseTestClassName)) continue; + if (!methodModel.shouldBeGenerated()) continue; generateTestMethod(p, methodModel); if (iterator.hasNext() || !innerTestClasses.isEmpty()) { @@ -188,11 +188,11 @@ public class TestGenerator { private static void generateTestMethod(Printer p, MethodModel methodModel) { generateMetadata(p, methodModel); - + methodModel.generateSignature(p); p.printWithNoIndent(" {"); p.println(); - + p.pushIndent(); methodModel.generateBody(p); diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt index f9200f11a08..a7826cd4c1a 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt @@ -31,7 +31,7 @@ interface TestClassModel : TestEntityModel { } interface MethodModel : TestEntityModel { - fun shouldBeGenerated(baseClassName: String): Boolean = true + fun shouldBeGenerated(): Boolean = true fun generateSignature(p: Printer) fun generateBody(p: Printer) } @@ -40,4 +40,4 @@ interface TestMethodModel : MethodModel { override fun generateSignature(p: Printer) { p.print("public void $name() throws Exception") } -} +}