[TEST] Drop generating tests for coroutines of Kotlin 1.2
This commit is contained in:
committed by
TeamCityServer
parent
0389589d83
commit
8c4b7ad1e1
-39
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.generators.tests.generator
|
||||
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
class RunTestMethodWithPackageReplacementModel(
|
||||
private val targetBackend: TargetBackend,
|
||||
private val testMethodName: String,
|
||||
private val testRunnerMethodName: String,
|
||||
private val additionalRunnerArguments: List<String>
|
||||
) : MethodModel {
|
||||
override val name = METHOD_NAME
|
||||
override val dataString: String? = null
|
||||
|
||||
override fun generateSignature(p: Printer) {
|
||||
p.print("private void $name(String testDataFilePath, String packageName) throws Exception")
|
||||
}
|
||||
|
||||
override fun generateBody(p: Printer) {
|
||||
val className = TargetBackend::class.java.simpleName
|
||||
val additionalArguments = if (additionalRunnerArguments.isNotEmpty())
|
||||
additionalRunnerArguments.joinToString(separator = ", ", prefix = ", ")
|
||||
else ""
|
||||
p.println("KotlinTestUtils.$testRunnerMethodName(filePath -> $testMethodName(filePath, packageName), $className.$targetBackend, testDataFilePath$additionalArguments);")
|
||||
}
|
||||
|
||||
override fun imports(): Collection<Class<*>> {
|
||||
return super.imports() + setOf(TargetBackend::class.java)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val METHOD_NAME = "runTestWithPackageReplacement"
|
||||
}
|
||||
}
|
||||
+7
-39
@@ -9,7 +9,6 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.generators.util.CoroutinesKt;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.utils.Printer;
|
||||
@@ -17,7 +16,6 @@ import org.jetbrains.kotlin.utils.Printer;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SimpleTestClassModel extends TestClassModel {
|
||||
private static final Comparator<TestEntityModel> BY_NAME = Comparator.comparing(TestEntityModel::getName);
|
||||
@@ -53,8 +51,6 @@ public class SimpleTestClassModel extends TestClassModel {
|
||||
private final String testRunnerMethodName;
|
||||
private final List<String> additionalRunnerArguments;
|
||||
|
||||
private boolean skipTestsForExperimentalCoroutines;
|
||||
|
||||
public SimpleTestClassModel(
|
||||
@NotNull File rootFile,
|
||||
boolean recursive,
|
||||
@@ -70,8 +66,7 @@ public class SimpleTestClassModel extends TestClassModel {
|
||||
String testRunnerMethodName,
|
||||
List<String> additionalRunnerArguments,
|
||||
Integer deep,
|
||||
@NotNull Collection<AnnotationModel> annotations,
|
||||
boolean skipTestsForExperimentalCoroutines
|
||||
@NotNull Collection<AnnotationModel> annotations
|
||||
) {
|
||||
this.rootFile = rootFile;
|
||||
this.recursive = recursive;
|
||||
@@ -88,7 +83,6 @@ public class SimpleTestClassModel extends TestClassModel {
|
||||
this.additionalRunnerArguments = additionalRunnerArguments;
|
||||
this.deep = deep;
|
||||
this.annotations = annotations;
|
||||
this.skipTestsForExperimentalCoroutines = skipTestsForExperimentalCoroutines;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -108,8 +102,8 @@ public class SimpleTestClassModel extends TestClassModel {
|
||||
children.add(new SimpleTestClassModel(
|
||||
file, true, excludeParentDirs, filenamePattern, excludePattern, checkFilenameStartsLowerCase,
|
||||
doTestMethodName, innerTestClassName, targetBackend, excludesStripOneDirectory(file.getName()),
|
||||
skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep != null ? deep - 1 : null, annotations,
|
||||
skipTestsForExperimentalCoroutines)
|
||||
skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep != null ? deep - 1 : null, annotations
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
@@ -158,16 +152,9 @@ public class SimpleTestClassModel extends TestClassModel {
|
||||
public Collection<MethodModel> getMethods() {
|
||||
if (testMethods == null) {
|
||||
if (!rootFile.isDirectory()) {
|
||||
if (CoroutinesKt.isCommonCoroutineTest(rootFile)) {
|
||||
testMethods = CoroutinesKt.createCommonCoroutinesTestMethodModels(rootFile, rootFile, filenamePattern,
|
||||
checkFilenameStartsLowerCase, targetBackend,
|
||||
skipIgnored, skipTestsForExperimentalCoroutines);
|
||||
}
|
||||
else {
|
||||
testMethods = Collections.singletonList(new SimpleTestMethodModel(
|
||||
rootFile, rootFile, filenamePattern, checkFilenameStartsLowerCase, targetBackend, skipIgnored
|
||||
));
|
||||
}
|
||||
testMethods = Collections.singletonList(new SimpleTestMethodModel(
|
||||
rootFile, rootFile, filenamePattern, checkFilenameStartsLowerCase, targetBackend, skipIgnored
|
||||
));
|
||||
}
|
||||
else {
|
||||
List<MethodModel> result = new ArrayList<>();
|
||||
@@ -178,8 +165,6 @@ public class SimpleTestClassModel extends TestClassModel {
|
||||
|
||||
File[] listFiles = rootFile.listFiles();
|
||||
|
||||
boolean hasCoroutines = false;
|
||||
|
||||
if (listFiles != null && (deep == null || deep == 0)) {
|
||||
for (File file : listFiles) {
|
||||
boolean excluded = excludePattern != null && excludePattern.matcher(file.getName()).matches();
|
||||
@@ -188,28 +173,11 @@ public class SimpleTestClassModel extends TestClassModel {
|
||||
if (file.isDirectory() && excludeParentDirs && dirHasSubDirs(file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!file.isDirectory() && CoroutinesKt.isCommonCoroutineTest(file)) {
|
||||
hasCoroutines = true;
|
||||
result.addAll(CoroutinesKt.createCommonCoroutinesTestMethodModels(rootFile, file,
|
||||
filenamePattern,
|
||||
checkFilenameStartsLowerCase,
|
||||
targetBackend, skipIgnored,
|
||||
skipTestsForExperimentalCoroutines));
|
||||
}
|
||||
else {
|
||||
result.add(new SimpleTestMethodModel(rootFile, file, filenamePattern,
|
||||
checkFilenameStartsLowerCase, targetBackend, skipIgnored));
|
||||
}
|
||||
result.add(new SimpleTestMethodModel(rootFile, file, filenamePattern, checkFilenameStartsLowerCase, targetBackend, skipIgnored));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCoroutines) {
|
||||
String methodName = doTestMethodName + "WithCoroutinesPackageReplacement";
|
||||
result.add(new RunTestMethodWithPackageReplacementModel(targetBackend, methodName, testRunnerMethodName, additionalRunnerArguments));
|
||||
}
|
||||
|
||||
result.sort(BY_NAME);
|
||||
|
||||
testMethods = result;
|
||||
|
||||
+2
-4
@@ -66,8 +66,7 @@ class TestGroup(
|
||||
excludeDirs: List<String> = listOf(),
|
||||
filenameStartsLowerCase: Boolean? = null,
|
||||
skipIgnored: Boolean = false,
|
||||
deep: Int? = null,
|
||||
skipTestsForExperimentalCoroutines: Boolean = false
|
||||
deep: Int? = null
|
||||
) {
|
||||
val rootFile = File("$testDataRoot/$relativeRootPath")
|
||||
val compiledPattern = Pattern.compile(pattern)
|
||||
@@ -84,8 +83,7 @@ class TestGroup(
|
||||
SimpleTestClassModel(
|
||||
rootFile, recursive, excludeParentDirs,
|
||||
compiledPattern, compiledExcludedPattern, filenameStartsLowerCase, testMethod, className,
|
||||
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep, annotations,
|
||||
skipTestsForExperimentalCoroutines
|
||||
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep, annotations
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.generators.util
|
||||
|
||||
import org.jetbrains.kotlin.generators.tests.generator.MethodModel
|
||||
import org.jetbrains.kotlin.generators.tests.generator.RunTestMethodWithPackageReplacementModel
|
||||
import org.jetbrains.kotlin.generators.tests.generator.SimpleTestMethodModel
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class CoroutinesTestModel(
|
||||
rootDir: File,
|
||||
file: File,
|
||||
filenamePattern: Pattern,
|
||||
checkFilenameStartsLowerCase: Boolean?,
|
||||
targetBackend: TargetBackend,
|
||||
skipIgnored: Boolean,
|
||||
private val isLanguageVersion1_3: Boolean
|
||||
) : SimpleTestMethodModel(
|
||||
rootDir,
|
||||
file,
|
||||
filenamePattern,
|
||||
checkFilenameStartsLowerCase,
|
||||
targetBackend,
|
||||
skipIgnored
|
||||
) {
|
||||
override val name: String
|
||||
get() = super.name + if (isLanguageVersion1_3) "_1_3" else "_1_2"
|
||||
|
||||
override fun generateBody(p: Printer) {
|
||||
val filePath = KotlinTestUtils.getFilePath(file) + if (file.isDirectory) "/" else ""
|
||||
val packageName = if (isLanguageVersion1_3) "kotlin.coroutines" else "kotlin.coroutines.experimental"
|
||||
|
||||
p.println(RunTestMethodWithPackageReplacementModel.METHOD_NAME, "(\"$filePath\", \"$packageName\");")
|
||||
}
|
||||
}
|
||||
|
||||
fun isCommonCoroutineTest(file: File): Boolean {
|
||||
return InTextDirectivesUtils.isDirectiveDefined(file.readText(), "COMMON_COROUTINES_TEST")
|
||||
}
|
||||
|
||||
fun createCommonCoroutinesTestMethodModels(
|
||||
rootDir: File,
|
||||
file: File,
|
||||
filenamePattern: Pattern,
|
||||
checkFilenameStartsLowerCase: Boolean?,
|
||||
targetBackend: TargetBackend,
|
||||
skipIgnored: Boolean,
|
||||
skipExperimental: Boolean
|
||||
): Collection<MethodModel> {
|
||||
return if (targetBackend.isIR || targetBackend == TargetBackend.JS)
|
||||
listOf(
|
||||
CoroutinesTestModel(
|
||||
rootDir,
|
||||
file,
|
||||
filenamePattern,
|
||||
checkFilenameStartsLowerCase,
|
||||
targetBackend,
|
||||
skipIgnored,
|
||||
true
|
||||
)
|
||||
)
|
||||
else {
|
||||
mutableListOf(
|
||||
CoroutinesTestModel(
|
||||
rootDir,
|
||||
file,
|
||||
filenamePattern,
|
||||
checkFilenameStartsLowerCase,
|
||||
targetBackend,
|
||||
skipIgnored,
|
||||
true
|
||||
)
|
||||
).apply {
|
||||
if (!skipExperimental) {
|
||||
this += CoroutinesTestModel(
|
||||
rootDir,
|
||||
file,
|
||||
filenamePattern,
|
||||
checkFilenameStartsLowerCase,
|
||||
targetBackend,
|
||||
skipIgnored,
|
||||
false
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user