mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit: support fork per module in order to get process with MODULE_DIR working directory; sorting issues
This commit is contained in:
@@ -472,7 +472,7 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
myJavaParameters.getProgramParametersList().add("@" + myTempFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
final Map<String, List<String>> perModule = forkPerModule() ? new HashMap<String, List<String>>() : null;
|
||||
final Map<String, List<String>> perModule = forkPerModule() ? new TreeMap<String, List<String>>() : null;
|
||||
final PrintWriter writer = new PrintWriter(myTempFile, "UTF-8");
|
||||
try {
|
||||
writer.println(packageName);
|
||||
@@ -483,7 +483,6 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
LOG.error("invalid element " + element);
|
||||
return;
|
||||
}
|
||||
testNames.add(name);
|
||||
|
||||
if (perModule != null && element instanceof PsiElement) {
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement((PsiElement)element);
|
||||
@@ -496,9 +495,18 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
}
|
||||
list.add(name);
|
||||
}
|
||||
} else {
|
||||
testNames.add(name);
|
||||
}
|
||||
}
|
||||
Collections.sort(testNames); //sort tests in FQN order
|
||||
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);
|
||||
}
|
||||
@@ -515,7 +523,6 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
wWriter.println(workingDir);
|
||||
final List<String> classNames = perModule.get(workingDir);
|
||||
wWriter.println(classNames.size());
|
||||
Collections.sort(classNames);
|
||||
for (String className : classNames) {
|
||||
wWriter.println(className);
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
package com.intellij.rt.execution.junit;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.SegmentedOutputStream;
|
||||
import org.junit.runner.Description;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -113,16 +111,19 @@ public class JUnitForkedStarter {
|
||||
|
||||
final FileOutputStream writer = new FileOutputStream(tempFile);
|
||||
|
||||
String className = null;
|
||||
String firstName = null;
|
||||
try {
|
||||
final int classNamesSize = Integer.parseInt(perDirReader.readLine());
|
||||
writer.write((packageName + ", working directory: \'" + workingDir + "\'\n").getBytes("UTF-8")); //instead of package name
|
||||
for (int i = 0; i < classNamesSize; i++) {
|
||||
className = perDirReader.readLine();
|
||||
String className = perDirReader.readLine();
|
||||
if (className == null) {
|
||||
System.err.println("Class name is expected. Working dir: " + workingDir);
|
||||
return -1;
|
||||
}
|
||||
if (firstName == null) {
|
||||
firstName = className;
|
||||
}
|
||||
writer.write((className + "\n").getBytes("UTF-8"));
|
||||
}
|
||||
}
|
||||
@@ -130,8 +131,7 @@ public class JUnitForkedStarter {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
final Object rootDescriptor = findByClassName(testRunner, className, description);
|
||||
|
||||
final Object rootDescriptor = findByClassName(testRunner, firstName, description);
|
||||
final int childResult;
|
||||
final File dir = new File(workingDir);
|
||||
if (forkMode.equals("none")) {
|
||||
|
||||
Reference in New Issue
Block a user