From f70724415237017c40d45c6669300c148c57dee6 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Wed, 29 Aug 2018 17:24:59 +0300 Subject: [PATCH] Cleanup coroutines utils duplicates --- .../org/jetbrains/kotlin/KonanTest.groovy | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index d772b543f70..6c3c9ccb509 100644 --- a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -150,31 +150,6 @@ abstract class KonanTest extends JavaExec { return sourceFiles } - void createCoroutineUtil(String file) { - StringBuilder text = new StringBuilder("import kotlin.coroutines.*\n") - text.append( - """ -open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation { - companion object : EmptyContinuation() - override fun resumeWith(result: SuccessOrFailure) { result.getOrThrow() } -} - -fun handleResultContinuation(x: (T) -> Unit): Continuation = object: Continuation { - override val context = EmptyCoroutineContext - override fun resumeWith(result: SuccessOrFailure) { x(result.getOrThrow()) } -} - -fun handleExceptionContinuation(x: (Throwable) -> Unit): Continuation = object: Continuation { - override val context = EmptyCoroutineContext - override fun resumeWith(result: SuccessOrFailure) { - val exception = result.exceptionOrNull() ?: return - x(exception) - } -} -""" ) - createFile(file, text.toString()) - } - String createTextForHelpers() { def coroutinesPackage = "kotlin.coroutines" @@ -239,13 +214,8 @@ fun handleExceptionContinuation(x: (Throwable) -> Unit): Continuation = ob def matcher = filePattern.matcher(srcText) if (srcText.contains('// WITH_COROUTINES')) { - def coroutineUtilFileName = "$outputDirectory/CoroutineUtil.kt" - createCoroutineUtil(coroutineUtilFileName) - def coroutineHelpersFileName = "$outputDirectory/helpers.kt" createFile(coroutineHelpersFileName, createTextForHelpers()) - - result.add(coroutineUtilFileName) result.add(coroutineHelpersFileName) } @@ -756,7 +726,9 @@ class RunExternalTestGroup extends RunStandaloneKonanTest { } // Find mutable objects that should be marked as ThreadLocal - text = markMutableObjects(text) + if (filePath != "$outputDirectory/helpers.kt") { + text = markMutableObjects(text) + } createFile(filePath, text) }