diff --git a/build.gradle.kts.182 b/build.gradle.kts.182 index c4ea1ba38b1..ab1f92d59f6 100644 --- a/build.gradle.kts.182 +++ b/build.gradle.kts.182 @@ -12,7 +12,7 @@ import proguard.gradle.ProGuardTask buildscript { extra["defaultSnapshotVersion"] = "1.2-SNAPSHOT" - kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.50-dev-310", onlySuccessBootstrap = false)) + kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.50-dev-880", onlySuccessBootstrap = false)) val mirrorRepo: String? = findProperty("maven.repository.mirror")?.toString() diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt.172 b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt.172 index 7a5f5a9a9d2..eed2016a84f 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt.172 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt.172 @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 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. + * Copyright 2010-2018 JetBrains s.r.o. 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 @@ -99,7 +88,14 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { val oldModule = modules[testModule]!! - val languageVersionSettings = loadLanguageVersionSettings(testFilesInModule) + val languageVersionSettings = + if (coroutinesPackage.isNotEmpty()) + CompilerTestLanguageVersionSettings( + DEFAULT_DIAGNOSTIC_TESTS_FEATURES, + if (coroutinesPackage.contains("experimental")) ApiVersion.KOTLIN_1_2 else ApiVersion.KOTLIN_1_3, + if (coroutinesPackage.contains("experimental")) LanguageVersion.KOTLIN_1_2 else LanguageVersion.KOTLIN_1_3 + ) + else loadLanguageVersionSettings(testFilesInModule) val moduleContext = context.withProject(project).withModule(oldModule) val separateModules = groupedByModule.size == 1 && groupedByModule.keys.single() == null @@ -151,7 +147,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { else -> ".txt" } val expectedFile = File(FileUtil.getNameWithoutExtension(testDataFile.absolutePath) + postfix) - validateAndCompareDescriptorWithFile(expectedFile, files, modules) + validateAndCompareDescriptorWithFile(expectedFile, files, modules, coroutinesPackage) } catch (e: Throwable) { exceptionFromDescriptorValidation = e } @@ -185,7 +181,9 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { exceptionFromDynamicCallDescriptorsValidation = e } - KotlinTestUtils.assertEqualsToFile(testDataFile, actualText.toString()) + KotlinTestUtils.assertEqualsToFile(getExpectedDiagnosticsFile(testDataFile), actualText.toString()) { s -> + s.replace("COROUTINES_PACKAGE", coroutinesPackage) + } assertTrue("Diagnostics mismatch. See the output above", ok) @@ -385,7 +383,8 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { private fun validateAndCompareDescriptorWithFile( expectedFile: File, testFiles: List, - modules: Map + modules: Map, + coroutinesPackage: String ) { if (skipDescriptorsValidation()) return if (testFiles.any { file -> InTextDirectivesUtils.isDirectiveDefined(file.expectedText, "// SKIP_TXT") }) { @@ -446,7 +445,9 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { "Such tests are hard to maintain, take long time to execute and are subject to sudden unreviewed changes anyway." } - KotlinTestUtils.assertEqualsToFile(expectedFile, allPackagesText) + KotlinTestUtils.assertEqualsToFile(expectedFile, allPackagesText) { s -> + s.replace("COROUTINES_PACKAGE", coroutinesPackage) + } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.181 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.181 index 21b24c1dcf7..b96e13169bd 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.181 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.181 @@ -568,6 +568,9 @@ public class KotlinTestUtils { configuration.put(JVMConfigurationKeys.JDK_HOME, new File(System.getProperty("java.home"))); } + if (configurationKind.getWithCoroutines()) { + JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests()); + } if (configurationKind.getWithRuntime()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests()); JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests()); @@ -709,13 +712,13 @@ public class KotlinTestUtils { } @NotNull - public static List createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory factory) { - return createTestFiles(testFileName, expectedText, factory, false); + public static List createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory factory, String coroutinesPackage) { + return createTestFiles(testFileName, expectedText, factory, false, coroutinesPackage); } @NotNull public static List createTestFiles(String testFileName, String expectedText, TestFileFactory factory, - boolean preserveLocations) { + boolean preserveLocations, String coroutinesPackage) { Map directives = parseDirectives(expectedText); List testFiles = Lists.newArrayList(); @@ -768,10 +771,13 @@ public class KotlinTestUtils { if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) { M supportModule = hasModules ? factory.createModule("support", Collections.emptyList(), Collections.emptyList()) : null; + if (coroutinesPackage.isEmpty()) { + coroutinesPackage = "kotlin.coroutines.experimental"; + } testFiles.add(factory.createFile(supportModule, "CoroutineUtil.kt", "package helpers\n" + - "import kotlin.coroutines.experimental.*\n" + + "import " + coroutinesPackage + ".*\n" + "fun handleResultContinuation(x: (T) -> Unit): Continuation = object: Continuation {\n" + " override val context = EmptyCoroutineContext\n" + " override fun resumeWithException(exception: Throwable) {\n" + @@ -862,7 +868,7 @@ public class KotlinTestUtils { int firstLineEnd = text.indexOf('\n'); return StringUtil.trimTrailing(text.substring(firstLineEnd + 1)); } - }); + }, ""); Assert.assertTrue("Exactly two files expected: ", files.size() == 2); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 index ff15343ceb3..62e1a456718 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 @@ -568,6 +568,9 @@ public class KotlinTestUtils { JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromCurrentJre()); } + if (configurationKind.getWithCoroutines()) { + JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests()); + } if (configurationKind.getWithRuntime()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests()); JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests()); @@ -709,13 +712,13 @@ public class KotlinTestUtils { } @NotNull - public static List createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory factory) { - return createTestFiles(testFileName, expectedText, factory, false); + public static List createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory factory, String coroutinesPackage) { + return createTestFiles(testFileName, expectedText, factory, false, coroutinesPackage); } @NotNull public static List createTestFiles(String testFileName, String expectedText, TestFileFactory factory, - boolean preserveLocations) { + boolean preserveLocations, String coroutinesPackage) { Map directives = parseDirectives(expectedText); List testFiles = Lists.newArrayList(); @@ -768,10 +771,13 @@ public class KotlinTestUtils { if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) { M supportModule = hasModules ? factory.createModule("support", Collections.emptyList(), Collections.emptyList()) : null; + if (coroutinesPackage.isEmpty()) { + coroutinesPackage = "kotlin.coroutines.experimental"; + } testFiles.add(factory.createFile(supportModule, "CoroutineUtil.kt", "package helpers\n" + - "import kotlin.coroutines.experimental.*\n" + + "import " + coroutinesPackage + ".*\n" + "fun handleResultContinuation(x: (T) -> Unit): Continuation = object: Continuation {\n" + " override val context = EmptyCoroutineContext\n" + " override fun resumeWithException(exception: Throwable) {\n" + @@ -862,7 +868,7 @@ public class KotlinTestUtils { int firstLineEnd = text.indexOf('\n'); return StringUtil.trimTrailing(text.substring(firstLineEnd + 1)); } - }); + }, ""); Assert.assertTrue("Exactly two files expected: ", files.size() == 2); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 index 260ad837e61..2929ca1e43b 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 @@ -568,6 +568,9 @@ public class KotlinTestUtils { JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromCurrentJre()); } + if (configurationKind.getWithCoroutines()) { + JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests()); + } if (configurationKind.getWithRuntime()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests()); JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests()); @@ -709,13 +712,13 @@ public class KotlinTestUtils { } @NotNull - public static List createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory factory) { - return createTestFiles(testFileName, expectedText, factory, false); + public static List createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory factory, String coroutinesPackage) { + return createTestFiles(testFileName, expectedText, factory, false, coroutinesPackage); } @NotNull public static List createTestFiles(String testFileName, String expectedText, TestFileFactory factory, - boolean preserveLocations) { + boolean preserveLocations, String coroutinesPackage) { Map directives = parseDirectives(expectedText); List testFiles = Lists.newArrayList(); @@ -768,10 +771,13 @@ public class KotlinTestUtils { if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) { M supportModule = hasModules ? factory.createModule("support", Collections.emptyList(), Collections.emptyList()) : null; + if (coroutinesPackage.isEmpty()) { + coroutinesPackage = "kotlin.coroutines.experimental"; + } testFiles.add(factory.createFile(supportModule, "CoroutineUtil.kt", "package helpers\n" + - "import kotlin.coroutines.experimental.*\n" + + "import " + coroutinesPackage + ".*\n" + "fun handleResultContinuation(x: (T) -> Unit): Continuation = object: Continuation {\n" + " override val context = EmptyCoroutineContext\n" + " override fun resumeWithException(exception: Throwable) {\n" + @@ -862,7 +868,7 @@ public class KotlinTestUtils { int firstLineEnd = text.indexOf('\n'); return StringUtil.trimTrailing(text.substring(firstLineEnd + 1)); } - }); + }, ""); Assert.assertTrue("Exactly two files expected: ", files.size() == 2);