Added the checking of extra generation of tests in TestGenerator.
Dropped tests that have been registered more than once.
This commit is contained in:
@@ -151,7 +151,6 @@ fun main(args: Array<String>) {
|
|||||||
model("codegen/defaultArguments/reflection")
|
model("codegen/defaultArguments/reflection")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
testClass(javaClass<AbstractLoadJavaTest>()) {
|
testClass(javaClass<AbstractLoadJavaTest>()) {
|
||||||
model("loadJava/compiledJava", extension = "java", testMethod = "doTestCompiledJava")
|
model("loadJava/compiledJava", extension = "java", testMethod = "doTestCompiledJava")
|
||||||
model("loadJava/compiledJavaAndKotlin", extension = "txt", testMethod = "doTestCompiledJavaAndKotlin")
|
model("loadJava/compiledJavaAndKotlin", extension = "txt", testMethod = "doTestCompiledJavaAndKotlin")
|
||||||
@@ -220,18 +219,8 @@ fun main(args: Array<String>) {
|
|||||||
model("evaluate/constant", testMethod = "doConstantTest")
|
model("evaluate/constant", testMethod = "doConstantTest")
|
||||||
model("evaluate/isPure", testMethod = "doIsPureTest")
|
model("evaluate/isPure", testMethod = "doIsPureTest")
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractAnnotationParameterTest>()) {
|
|
||||||
model("resolveAnnotations/parameters")
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass(javaClass<AbstractEvaluateExpressionTest>()) {
|
|
||||||
model("evaluate/constant", testMethod = "doConstantTest")
|
|
||||||
model("evaluate/isPure", testMethod = "doIsPureTest")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
testGroup("idea/tests", "idea/testData") {
|
testGroup("idea/tests", "idea/testData") {
|
||||||
testClass(javaClass<AbstractAdditionalLazyResolveDescriptorRendererTest>()) {
|
testClass(javaClass<AbstractAdditionalLazyResolveDescriptorRendererTest>()) {
|
||||||
model("resolve/additionalLazyResolve", testMethod = "doTest")
|
model("resolve/additionalLazyResolve", testMethod = "doTest")
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.generators.tests.generator;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.di.GeneratorsFileUtil;
|
import org.jetbrains.jet.di.GeneratorsFileUtil;
|
||||||
@@ -25,10 +26,7 @@ import org.jetbrains.jet.utils.Printer;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TestGenerator {
|
public class TestGenerator {
|
||||||
|
|
||||||
@@ -38,6 +36,8 @@ public class TestGenerator {
|
|||||||
"junit.framework.TestSuite"
|
"junit.framework.TestSuite"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static final Set<String> GENERATED_FILES = ContainerUtil.newHashSet();
|
||||||
|
|
||||||
private final String baseDir;
|
private final String baseDir;
|
||||||
private final String suiteClassPackage;
|
private final String suiteClassPackage;
|
||||||
private final String suiteClassName;
|
private final String suiteClassName;
|
||||||
@@ -45,6 +45,7 @@ public class TestGenerator {
|
|||||||
private final String baseTestClassName;
|
private final String baseTestClassName;
|
||||||
private final Collection<TestClassModel> testClassModels;
|
private final Collection<TestClassModel> testClassModels;
|
||||||
private final String generatorName;
|
private final String generatorName;
|
||||||
|
private final String testSourceFilePath;
|
||||||
|
|
||||||
public TestGenerator(
|
public TestGenerator(
|
||||||
@NotNull String baseDir,
|
@NotNull String baseDir,
|
||||||
@@ -61,6 +62,12 @@ public class TestGenerator {
|
|||||||
this.baseTestClassName = baseTestClass.getSimpleName();
|
this.baseTestClassName = baseTestClass.getSimpleName();
|
||||||
this.testClassModels = Lists.newArrayList(testClassModels);
|
this.testClassModels = Lists.newArrayList(testClassModels);
|
||||||
this.generatorName = generatorClass;
|
this.generatorName = generatorClass;
|
||||||
|
|
||||||
|
this.testSourceFilePath = this.baseDir + "/" + this.suiteClassPackage.replace(".", "/") + "/" + this.suiteClassName + ".java";
|
||||||
|
|
||||||
|
if (!GENERATED_FILES.add(testSourceFilePath)) {
|
||||||
|
throw new IllegalArgumentException("Same test file already generated in current session: " + testSourceFilePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateAndSave() throws IOException {
|
public void generateAndSave() throws IOException {
|
||||||
@@ -128,7 +135,6 @@ public class TestGenerator {
|
|||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String testSourceFilePath = baseDir + "/" + suiteClassPackage.replace(".", "/") + "/" + suiteClassName + ".java";
|
|
||||||
File testSourceFile = new File(testSourceFilePath);
|
File testSourceFile = new File(testSourceFilePath);
|
||||||
GeneratorsFileUtil.writeFileIfContentChanged(testSourceFile, out.toString(), false);
|
GeneratorsFileUtil.writeFileIfContentChanged(testSourceFile, out.toString(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user