mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit: write classes to temp file in one place
This commit is contained in:
@@ -480,49 +480,44 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
return StringUtil.compare(o1.getName(), o2.getName(), true);
|
||||
}
|
||||
}) : null;
|
||||
final PrintWriter writer = new PrintWriter(myTempFile, CharsetToolkit.UTF8);
|
||||
try {
|
||||
writer.println(packageName);
|
||||
final JUnitConfiguration.Data data = myConfiguration.getPersistentData();
|
||||
final String category = data.TEST_OBJECT == JUnitConfiguration.TEST_CATEGORY ? data.getCategory() : "";
|
||||
writer.println(category);
|
||||
final List<String> testNames = new ArrayList<String>();
|
||||
for (final T element : elements) {
|
||||
final String name = nameFunction.fun(element);
|
||||
if (name == null) {
|
||||
LOG.error("invalid element " + element);
|
||||
return;
|
||||
}
|
||||
|
||||
if (perModule != null && element instanceof PsiElement) {
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement((PsiElement)element);
|
||||
if (module != null) {
|
||||
List<String> list = perModule.get(module);
|
||||
if (list == null) {
|
||||
list = new ArrayList<String>();
|
||||
perModule.put(module, list);
|
||||
}
|
||||
list.add(name);
|
||||
final List<String> testNames = new ArrayList<String>();
|
||||
|
||||
for (final T element : elements) {
|
||||
final String name = nameFunction.fun(element);
|
||||
if (name == null) {
|
||||
LOG.error("invalid element " + element);
|
||||
return;
|
||||
}
|
||||
|
||||
if (perModule != null && element instanceof PsiElement) {
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement((PsiElement)element);
|
||||
if (module != null) {
|
||||
List<String> list = perModule.get(module);
|
||||
if (list == null) {
|
||||
list = new ArrayList<String>();
|
||||
perModule.put(module, list);
|
||||
}
|
||||
} else {
|
||||
testNames.add(name);
|
||||
list.add(name);
|
||||
}
|
||||
}
|
||||
if (perModule != null) {
|
||||
for (List<String> perModuleClasses : perModule.values()) {
|
||||
Collections.sort(perModuleClasses);
|
||||
testNames.addAll(perModuleClasses);
|
||||
}
|
||||
} else {
|
||||
Collections.sort(testNames); //sort tests in FQN order
|
||||
}
|
||||
for (String testName : testNames) {
|
||||
writer.println(testName);
|
||||
else {
|
||||
testNames.add(name);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
writer.close();
|
||||
if (perModule != null) {
|
||||
for (List<String> perModuleClasses : perModule.values()) {
|
||||
Collections.sort(perModuleClasses);
|
||||
testNames.addAll(perModuleClasses);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Collections.sort(testNames); //sort tests in FQN order
|
||||
}
|
||||
|
||||
final JUnitConfiguration.Data data = myConfiguration.getPersistentData();
|
||||
final String category = data.TEST_OBJECT == JUnitConfiguration.TEST_CATEGORY ? data.getCategory() : "";
|
||||
JUnitStarter.printClassesList(testNames, packageName, category, myTempFile);
|
||||
|
||||
if (perModule != null && perModule.size() > 1) {
|
||||
final PrintWriter wWriter = new PrintWriter(myWorkingDirsFile, CharsetToolkit.UTF8);
|
||||
|
||||
@@ -106,32 +106,23 @@ public class JUnitForkedStarter {
|
||||
final String packageName = perDirReader.readLine();
|
||||
String workingDir;
|
||||
while ((workingDir = perDirReader.readLine()) != null) {
|
||||
final String classpath = perDirReader.readLine();
|
||||
try {
|
||||
File tempFile = File.createTempFile("idea_junit", ".tmp");
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
final FileOutputStream writer = new FileOutputStream(tempFile);
|
||||
|
||||
final String classpath = perDirReader.readLine();
|
||||
|
||||
List classNames = new ArrayList();
|
||||
try {
|
||||
final int classNamesSize = Integer.parseInt(perDirReader.readLine());
|
||||
writer.write((packageName + ", working directory: \'" + workingDir + "\'\n").getBytes("UTF-8")); //instead of package name
|
||||
writer.write("\n".getBytes("UTF-8")); //category
|
||||
for (int i = 0; i < classNamesSize; i++) {
|
||||
String className = perDirReader.readLine();
|
||||
if (className == null) {
|
||||
System.err.println("Class name is expected. Working dir: " + workingDir);
|
||||
return -1;
|
||||
}
|
||||
classNames.add(className);
|
||||
writer.write((className + "\n").getBytes("UTF-8"));
|
||||
final int classNamesSize = Integer.parseInt(perDirReader.readLine());
|
||||
for (int i = 0; i < classNamesSize; i++) {
|
||||
String className = perDirReader.readLine();
|
||||
if (className == null) {
|
||||
System.err.println("Class name is expected. Working dir: " + workingDir);
|
||||
return -1;
|
||||
}
|
||||
classNames.add(className);
|
||||
}
|
||||
finally {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
File tempFile = File.createTempFile("idea_junit", ".tmp");
|
||||
tempFile.deleteOnExit();
|
||||
JUnitStarter.printClassesList(classNames, packageName + ", working directory: \'" + workingDir + "\'", "", tempFile);
|
||||
|
||||
final Object rootDescriptor = findByClassName(testRunner, (String)classNames.get(0), description);
|
||||
final int childResult;
|
||||
|
||||
@@ -226,4 +226,19 @@ public class JUnitStarter {
|
||||
: Class.forName("com.intellij.junit3.JUnit3IdeaTestRunner");
|
||||
|
||||
}
|
||||
|
||||
public static void printClassesList(List classNames, String packageName, String category, File tempFile) throws IOException {
|
||||
final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(tempFile), "UTF-8"));
|
||||
|
||||
try {
|
||||
writer.println(packageName); //package name
|
||||
writer.println(category); //category
|
||||
for (int i = 0; i < classNames.size(); i++) {
|
||||
writer.println(classNames.get(i));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user