From 3af0840512ed636469a564646e17df880315bfc0 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Thu, 15 Dec 2016 20:24:20 +0300 Subject: [PATCH] Test coroutines setting in Gradle plugin --- .../jetbrains/kotlin/gradle/CoroutinesIT.kt | 98 +++++++++++++++++++ .../kotlin/gradle/KotlinGradlePluginIT.kt | 14 --- 2 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CoroutinesIT.kt diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CoroutinesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CoroutinesIT.kt new file mode 100644 index 00000000000..4c9ff7905f8 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CoroutinesIT.kt @@ -0,0 +1,98 @@ +/* + * 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.gradle + +import org.junit.Test +import java.io.File + +class CoroutinesIT: BaseGradleIT() { + companion object { + private const val GRADLE_VERSION = "2.14.1" + private const val LOCAL_PROPERTIES = "local.properties" + private const val GRADLE_PROPERTIES = "gradle.properties" + } + + @Test + fun testCoroutinesJvmEnabled() { + jvmProject.doTest("enable", GRADLE_PROPERTIES) + } + + @Test + fun testCoroutinesJvmWarn() { + jvmProject.doTest("warn", GRADLE_PROPERTIES) + } + + @Test + fun testCoroutinesJvmError() { + jvmProject.doTest("error", GRADLE_PROPERTIES) + } + + @Test + fun testCoroutinesJvmDefault() { + jvmProject.doTest("warn", null) + } + + @Test + fun testCoroutinesJvmLocalProperties() { + jvmProject.doTest("enable", LOCAL_PROPERTIES) + } + + @Test + fun testCoroutinesJsLocalProperties() { + jsProject.doTest("enable", LOCAL_PROPERTIES) + } + + @Test + fun testCoroutinesJsEnabled() { + jsProject.doTest("enable", GRADLE_PROPERTIES) + } + + @Test + fun testCoroutinesJsWarn() { + jsProject.doTest("warn", GRADLE_PROPERTIES) + } + + @Test + fun testCoroutinesJsError() { + jsProject.doTest("error", GRADLE_PROPERTIES) + } + + @Test + fun testCoroutinesJsDefault() { + jsProject.doTest("warn", null) + } + + // todo: replace with project that actually uses coroutines after their syntax is finalized + private val jvmProject: Project + get() = Project("kotlinProject", GRADLE_VERSION) + + private val jsProject: Project + get() = Project("kotlin2JsProject", GRADLE_VERSION) + + private fun Project.doTest(coroutineSupport: String, propertyFileName: String?) { + if (propertyFileName != null) { + setupWorkingDir() + val propertyFile = File(projectDir, propertyFileName) + val coroutinesProperty = "kotlin.coroutines=$coroutineSupport" + propertyFile.writeText(coroutinesProperty) + } + + build("build") { + assertContains("-Xcoroutines=$coroutineSupport") + } + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index f79a33380dc..874735c3ba7 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -216,20 +216,6 @@ class KotlinGradleIT: BaseGradleIT() { } } - @Test - fun testCoroutinesPropertyFromLocalPropertiesFile() { - val project = Project("kotlinCoroutinesProject", GRADLE_VERSION) - project.setupWorkingDir() - - val localPropertyFile = File(project.projectDir, "local.properties") - val coroutinesProperty = "kotlin.coroutines=error" - localPropertyFile.writeText(coroutinesProperty) - - project.build("build") { - assertContains(coroutinesProperty) - } - } - @Test fun testConvertJavaToKotlin() { val project = Project("convertBetweenJavaAndKotlin", GRADLE_VERSION)