Add special tests for interceptRun support
Basically they're built upon basic coroutine tests, but for each of them different interceptResume implementation are injected (currently there are 12 of them). It might be more simple just to generated additional testData, but I see this more problematic in a sense of further maintenance Note that all tests add idempotent 'interceptRun' operators, which just execute given lambda in the current thread #KT-14891 Fixed
This commit is contained in:
@@ -240,6 +240,10 @@ fun main(args: Array<String>) {
|
||||
model("codegen/boxAgainstJava")
|
||||
}
|
||||
|
||||
testClass<AbstractAdditionalCoroutineBlackBoxCodegenTest> {
|
||||
model("codegen/box/coroutines")
|
||||
}
|
||||
|
||||
testClass<AbstractScriptCodegenTest>() {
|
||||
model("codegen/script", extension = "kts")
|
||||
}
|
||||
@@ -1118,7 +1122,7 @@ fun main(args: Array<String>) {
|
||||
testClass<AbstractAnnotationProcessingTest>() {
|
||||
model("wrappers", recursive = true, extension = "kt")
|
||||
}
|
||||
|
||||
|
||||
testClass<AbstractBytecodeListingTestForSourceRetention>() {
|
||||
model("sourceRetention", extension = "kt")
|
||||
}
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeGenerated() {
|
||||
public boolean shouldBeGenerated(@NotNull String baseClassName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-2
@@ -20,12 +20,14 @@ 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.codegen.AbstractAdditionalCoroutineBlackBoxCodegenTest;
|
||||
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.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -102,8 +104,19 @@ public class SimpleTestMethodModel implements TestMethodModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeGenerated() {
|
||||
return InTextDirectivesUtils.isCompatibleTarget(targetBackend, file);
|
||||
public boolean shouldBeGenerated(@NotNull String baseClassName) {
|
||||
if (!InTextDirectivesUtils.isCompatibleTarget(targetBackend, file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!baseClassName.equals(AbstractAdditionalCoroutineBlackBoxCodegenTest.class.getSimpleName())) return true;
|
||||
|
||||
try {
|
||||
return !InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(file), "// NO_INTERCEPT_RESUME_TESTS");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public class SingleClassTestModel implements TestClassModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeGenerated() {
|
||||
public boolean shouldBeGenerated(@NotNull String baseClassName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class TestGenerator {
|
||||
for (Iterator<MethodModel> iterator = testMethods.iterator(); iterator.hasNext(); ) {
|
||||
MethodModel methodModel = iterator.next();
|
||||
|
||||
if (!methodModel.shouldBeGenerated()) continue;
|
||||
if (!methodModel.shouldBeGenerated(baseTestClassName)) continue;
|
||||
|
||||
generateTestMethod(p, methodModel);
|
||||
if (iterator.hasNext() || !innerTestClasses.isEmpty()) {
|
||||
@@ -188,11 +188,11 @@ public class TestGenerator {
|
||||
|
||||
private static void generateTestMethod(Printer p, MethodModel methodModel) {
|
||||
generateMetadata(p, methodModel);
|
||||
|
||||
|
||||
methodModel.generateSignature(p);
|
||||
p.printWithNoIndent(" {");
|
||||
p.println();
|
||||
|
||||
|
||||
p.pushIndent();
|
||||
|
||||
methodModel.generateBody(p);
|
||||
|
||||
@@ -31,7 +31,7 @@ interface TestClassModel : TestEntityModel {
|
||||
}
|
||||
|
||||
interface MethodModel : TestEntityModel {
|
||||
fun shouldBeGenerated(): Boolean = true
|
||||
fun shouldBeGenerated(baseClassName: String): Boolean = true
|
||||
fun generateSignature(p: Printer)
|
||||
fun generateBody(p: Printer)
|
||||
}
|
||||
@@ -40,4 +40,4 @@ interface TestMethodModel : MethodModel {
|
||||
override fun generateSignature(p: Printer) {
|
||||
p.print("public void $name() throws Exception")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user