Test coroutines setting in Gradle plugin

This commit is contained in:
Alexey Tsvetkov
2016-12-15 20:24:20 +03:00
committed by Stanislav Erokhin
parent 3e1edf006f
commit 3af0840512
2 changed files with 98 additions and 14 deletions
@@ -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")
}
}
}
@@ -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)