fix and improve check for TARGET_BACKEND for generated tests
This commit is contained in:
+12
-1
@@ -32,6 +32,8 @@ import java.util.regex.Pattern;
|
|||||||
import static org.jetbrains.kotlin.generators.tests.generator.TestGenerator.TargetBackend;
|
import static org.jetbrains.kotlin.generators.tests.generator.TestGenerator.TargetBackend;
|
||||||
|
|
||||||
public class SimpleTestMethodModel implements TestMethodModel {
|
public class SimpleTestMethodModel implements TestMethodModel {
|
||||||
|
private static final String DIRECTIVES_FILE_NAME = "directives.txt";
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final File rootDir;
|
private final File rootDir;
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -73,7 +75,16 @@ public class SimpleTestMethodModel implements TestMethodModel {
|
|||||||
if (targetBackend == TargetBackend.ANY) return false;
|
if (targetBackend == TargetBackend.ANY) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String fileText = FileUtil.loadFile(file);
|
String fileText;
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
File directivesFile = new File(file, DIRECTIVES_FILE_NAME);
|
||||||
|
if (!directivesFile.exists()) return false;
|
||||||
|
|
||||||
|
fileText = FileUtil.loadFile(directivesFile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fileText = FileUtil.loadFile(file);
|
||||||
|
}
|
||||||
List<String> backends = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "// TARGET_BACKEND: ");
|
List<String> backends = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "// TARGET_BACKEND: ");
|
||||||
return backends.size() > 0 && !targetBackend.name().equals(backends.get(0));
|
return backends.size() > 0 && !targetBackend.name().equals(backends.get(0));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user