IrCompileKotlinAgainstInlineKotlin tests
This commit is contained in:
+6
-2
@@ -11,7 +11,8 @@ import org.jetbrains.kotlin.utils.Printer
|
||||
class RunTestMethodModel(
|
||||
private val targetBackend: TargetBackend,
|
||||
private val testMethodName: String,
|
||||
private val testRunnerMethodName: String
|
||||
private val testRunnerMethodName: String,
|
||||
private val additionalRunnerArguments: List<String> = emptyList()
|
||||
) : MethodModel {
|
||||
override val name = METHOD_NAME
|
||||
override val dataString: String? = null
|
||||
@@ -22,7 +23,10 @@ class RunTestMethodModel(
|
||||
|
||||
override fun generateBody(p: Printer) {
|
||||
val className = TargetBackend::class.java.simpleName
|
||||
p.println("KotlinTestUtils.$testRunnerMethodName(this::$testMethodName, $className.$targetBackend, testDataFilePath);")
|
||||
val additionalArguments = if (additionalRunnerArguments.isNotEmpty())
|
||||
additionalRunnerArguments.joinToString(separator = ", ", prefix = ", ")
|
||||
else ""
|
||||
p.println("KotlinTestUtils.$testRunnerMethodName(this::$testMethodName, $className.$targetBackend, testDataFilePath$additionalArguments);")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+6
-2
@@ -11,7 +11,8 @@ import org.jetbrains.kotlin.utils.Printer
|
||||
class RunTestMethodWithPackageReplacementModel(
|
||||
private val targetBackend: TargetBackend,
|
||||
private val testMethodName: String,
|
||||
private val testRunnerMethodName: String
|
||||
private val testRunnerMethodName: String,
|
||||
private val additionalRunnerArguments: List<String>
|
||||
) : MethodModel {
|
||||
override val name = METHOD_NAME
|
||||
override val dataString: String? = null
|
||||
@@ -22,7 +23,10 @@ class RunTestMethodWithPackageReplacementModel(
|
||||
|
||||
override fun generateBody(p: Printer) {
|
||||
val className = TargetBackend::class.java.simpleName
|
||||
p.println("KotlinTestUtils.$testRunnerMethodName(filePath -> $testMethodName(filePath, packageName), $className.$targetBackend, testDataFilePath);")
|
||||
val additionalArguments = if (additionalRunnerArguments.isNotEmpty())
|
||||
additionalRunnerArguments.joinToString(separator = ", ", prefix = ", ")
|
||||
else ""
|
||||
p.println("KotlinTestUtils.$testRunnerMethodName(filePath -> $testMethodName(filePath, packageName), $className.$targetBackend, testDataFilePath$additionalArguments);")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+6
-3
@@ -45,6 +45,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
|
||||
private final boolean skipIgnored;
|
||||
private final String testRunnerMethodName;
|
||||
private final List<String> additionalRunnerArguments;
|
||||
|
||||
public SimpleTestClassModel(
|
||||
@NotNull File rootFile,
|
||||
@@ -58,6 +59,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
@NotNull Collection<String> excludeDirs,
|
||||
boolean skipIgnored,
|
||||
String testRunnerMethodName,
|
||||
List<String> additionalRunnerArguments,
|
||||
Integer deep
|
||||
) {
|
||||
this.rootFile = rootFile;
|
||||
@@ -71,6 +73,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
this.excludeDirs = excludeDirs.isEmpty() ? Collections.emptySet() : new LinkedHashSet<>(excludeDirs);
|
||||
this.skipIgnored = skipIgnored;
|
||||
this.testRunnerMethodName = testRunnerMethodName;
|
||||
this.additionalRunnerArguments = additionalRunnerArguments;
|
||||
this.deep = deep;
|
||||
}
|
||||
|
||||
@@ -91,7 +94,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
children.add(new SimpleTestClassModel(
|
||||
file, true, excludeParentDirs, filenamePattern, checkFilenameStartsLowerCase,
|
||||
doTestMethodName, innerTestClassName, targetBackend, excludesStripOneDirectory(file.getName()),
|
||||
skipIgnored, testRunnerMethodName, deep != null ? deep - 1 : null)
|
||||
skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep != null ? deep - 1 : null)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -153,7 +156,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
else {
|
||||
List<MethodModel> result = new ArrayList<>();
|
||||
|
||||
result.add(new RunTestMethodModel(targetBackend, doTestMethodName, testRunnerMethodName));
|
||||
result.add(new RunTestMethodModel(targetBackend, doTestMethodName, testRunnerMethodName, additionalRunnerArguments));
|
||||
|
||||
result.add(new TestAllFilesPresentMethodModel());
|
||||
|
||||
@@ -186,7 +189,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
|
||||
if (hasCoroutines) {
|
||||
String methodName = doTestMethodName + "WithCoroutinesPackageReplacement";
|
||||
result.add(new RunTestMethodWithPackageReplacementModel(targetBackend, methodName, testRunnerMethodName));
|
||||
result.add(new RunTestMethodWithPackageReplacementModel(targetBackend, methodName, testRunnerMethodName, additionalRunnerArguments));
|
||||
}
|
||||
|
||||
result.sort(BY_NAME);
|
||||
|
||||
+5
-2
@@ -50,6 +50,7 @@ public class SingleClassTestModel implements TestClassModel {
|
||||
|
||||
private final boolean skipIgnored;
|
||||
private final String testRunnerMethodName;
|
||||
private final List<String> additionalRunnerArguments;
|
||||
|
||||
public SingleClassTestModel(
|
||||
@NotNull File rootFile,
|
||||
@@ -59,7 +60,8 @@ public class SingleClassTestModel implements TestClassModel {
|
||||
@NotNull String testClassName,
|
||||
@NotNull TargetBackend targetBackend,
|
||||
boolean skipIgnored,
|
||||
String testRunnerMethodName
|
||||
String testRunnerMethodName,
|
||||
List<String> additionalRunnerArguments
|
||||
) {
|
||||
this.rootFile = rootFile;
|
||||
this.filenamePattern = filenamePattern;
|
||||
@@ -69,6 +71,7 @@ public class SingleClassTestModel implements TestClassModel {
|
||||
this.targetBackend = targetBackend;
|
||||
this.skipIgnored = skipIgnored;
|
||||
this.testRunnerMethodName = testRunnerMethodName;
|
||||
this.additionalRunnerArguments = additionalRunnerArguments;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -83,7 +86,7 @@ public class SingleClassTestModel implements TestClassModel {
|
||||
if (methods == null) {
|
||||
List<MethodModel> result = new ArrayList<>();
|
||||
|
||||
result.add(new RunTestMethodModel(targetBackend, doTestMethodName, testRunnerMethodName));
|
||||
result.add(new RunTestMethodModel(targetBackend, doTestMethodName, testRunnerMethodName, additionalRunnerArguments));
|
||||
|
||||
result.add(new TestAllFilesPresentMethodModel());
|
||||
|
||||
|
||||
+10
-4
@@ -11,7 +11,12 @@ import java.io.File
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class TestGroup(private val testsRoot: String, val testDataRoot: String, val testRunnerMethodName: String) {
|
||||
class TestGroup(
|
||||
private val testsRoot: String,
|
||||
val testDataRoot: String,
|
||||
val testRunnerMethodName: String,
|
||||
val additionalRunnerArguments: List<String> = emptyList()
|
||||
) {
|
||||
inline fun <reified T : TestCase> testClass(
|
||||
suiteTestClassName: String = getDefaultSuiteTestClassName(T::class.java.simpleName),
|
||||
noinline init: TestClass.() -> Unit
|
||||
@@ -58,13 +63,13 @@ class TestGroup(private val testsRoot: String, val testDataRoot: String, val tes
|
||||
if (excludeDirs.isNotEmpty()) error("excludeDirs is unsupported for SingleClassTestModel yet")
|
||||
SingleClassTestModel(
|
||||
rootFile, compiledPattern, filenameStartsLowerCase, testMethod, className, targetBackend,
|
||||
skipIgnored, testRunnerMethodName
|
||||
skipIgnored, testRunnerMethodName, additionalRunnerArguments
|
||||
)
|
||||
} else {
|
||||
SimpleTestClassModel(
|
||||
rootFile, recursive, excludeParentDirs,
|
||||
compiledPattern, filenameStartsLowerCase, testMethod, className,
|
||||
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName, deep
|
||||
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -76,9 +81,10 @@ fun testGroup(
|
||||
testsRoot: String,
|
||||
testDataRoot: String,
|
||||
testRunnerMethodName: String = RunTestMethodModel.METHOD_NAME,
|
||||
additionalRunnerArguments: List<String> = emptyList(),
|
||||
init: TestGroup.() -> Unit
|
||||
) {
|
||||
TestGroup(testsRoot, testDataRoot, testRunnerMethodName).init()
|
||||
TestGroup(testsRoot, testDataRoot, testRunnerMethodName, additionalRunnerArguments).init()
|
||||
}
|
||||
|
||||
fun getDefaultSuiteTestClassName(baseTestClassName: String): String {
|
||||
|
||||
Reference in New Issue
Block a user