Take coroutinesPackage into account in bunch files
#KT-23362
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
+19
-18
@@ -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<TestFile>,
|
||||
modules: Map<TestModule?, ModuleDescriptorImpl>
|
||||
modules: Map<TestModule?, ModuleDescriptorImpl>,
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 <M, F> List<F> createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory<M, F> factory) {
|
||||
return createTestFiles(testFileName, expectedText, factory, false);
|
||||
public static <M, F> List<F> createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory<M, F> factory, String coroutinesPackage) {
|
||||
return createTestFiles(testFileName, expectedText, factory, false, coroutinesPackage);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <M, F> List<F> createTestFiles(String testFileName, String expectedText, TestFileFactory<M, F> factory,
|
||||
boolean preserveLocations) {
|
||||
boolean preserveLocations, String coroutinesPackage) {
|
||||
Map<String, String> directives = parseDirectives(expectedText);
|
||||
|
||||
List<F> 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 <T> handleResultContinuation(x: (T) -> Unit): Continuation<T> = object: Continuation<T> {\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);
|
||||
|
||||
|
||||
@@ -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 <M, F> List<F> createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory<M, F> factory) {
|
||||
return createTestFiles(testFileName, expectedText, factory, false);
|
||||
public static <M, F> List<F> createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory<M, F> factory, String coroutinesPackage) {
|
||||
return createTestFiles(testFileName, expectedText, factory, false, coroutinesPackage);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <M, F> List<F> createTestFiles(String testFileName, String expectedText, TestFileFactory<M, F> factory,
|
||||
boolean preserveLocations) {
|
||||
boolean preserveLocations, String coroutinesPackage) {
|
||||
Map<String, String> directives = parseDirectives(expectedText);
|
||||
|
||||
List<F> 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 <T> handleResultContinuation(x: (T) -> Unit): Continuation<T> = object: Continuation<T> {\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);
|
||||
|
||||
|
||||
@@ -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 <M, F> List<F> createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory<M, F> factory) {
|
||||
return createTestFiles(testFileName, expectedText, factory, false);
|
||||
public static <M, F> List<F> createTestFiles(@Nullable String testFileName, String expectedText, TestFileFactory<M, F> factory, String coroutinesPackage) {
|
||||
return createTestFiles(testFileName, expectedText, factory, false, coroutinesPackage);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <M, F> List<F> createTestFiles(String testFileName, String expectedText, TestFileFactory<M, F> factory,
|
||||
boolean preserveLocations) {
|
||||
boolean preserveLocations, String coroutinesPackage) {
|
||||
Map<String, String> directives = parseDirectives(expectedText);
|
||||
|
||||
List<F> 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 <T> handleResultContinuation(x: (T) -> Unit): Continuation<T> = object: Continuation<T> {\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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user