Don't generate test when target backend is not suitable

This commit is contained in:
Zalim Bashorov
2016-11-04 16:44:16 +03:00
parent f382f938c7
commit a1730f98ba
9 changed files with 18 additions and 158 deletions
@@ -234,5 +234,10 @@ public class SimpleTestClassModel implements TestClassModel {
public void generateSignature(@NotNull Printer p) {
TestMethodModel.DefaultImpls.generateSignature(this, p);
}
@Override
public boolean shouldBeGenerated() {
return true;
}
}
}
@@ -117,7 +117,8 @@ public class SimpleTestMethodModel implements TestMethodModel {
}
}
private boolean shouldBeGenerated() {
@Override
public boolean shouldBeGenerated() {
if (targetBackend == TargetBackend.ANY) return true;
List<String> backends = InTextDirectivesUtils.findLinesWithPrefixesRemoved(textWithDirectives(), "// TARGET_BACKEND: ");
@@ -149,7 +150,7 @@ public class SimpleTestMethodModel implements TestMethodModel {
String relativePath = FileUtil.getRelativePath(rootDir, file.getParentFile());
unescapedName = relativePath + "-" + StringUtil.capitalize(extractedName);
}
return (!shouldBeGenerated() ? "ignored" : "test") + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
return "test" + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
}
@Override
@@ -160,5 +160,10 @@ public class SingleClassTestModel implements TestClassModel {
public void generateSignature(@NotNull Printer p) {
TestMethodModel.DefaultImpls.generateSignature(this, p);
}
@Override
public boolean shouldBeGenerated() {
return true;
}
}
}
@@ -168,6 +168,9 @@ public class TestGenerator {
for (Iterator<MethodModel> iterator = testMethods.iterator(); iterator.hasNext(); ) {
MethodModel methodModel = iterator.next();
if (!methodModel.shouldBeGenerated()) continue;
generateTestMethod(p, methodModel);
if (iterator.hasNext() || !innerTestClasses.isEmpty()) {
p.println();
@@ -31,6 +31,7 @@ interface TestClassModel : TestEntityModel {
}
interface MethodModel : TestEntityModel {
fun shouldBeGenerated(): Boolean = true
fun generateSignature(p: Printer)
fun generateBody(p: Printer)
}