support module path and options on fork per module/class/ect (IDEA-171419)

GitOrigin-RevId: 5012cf6a8509998a1b13de64f7c415b030403d94
This commit is contained in:
Anna Kozlova
2019-10-02 10:43:43 +02:00
committed by intellij-monorepo-bot
parent ed74d06909
commit ce2dcf2884
14 changed files with 250 additions and 52 deletions

View File

@@ -63,7 +63,7 @@ public abstract class ForkedByModuleSplitter {
}
//read output from wrappers
protected int startChildFork(final List args, File workingDir, String classpath, String repeatCount) throws IOException, InterruptedException {
protected int startChildFork(final List args, File workingDir, String classpath, List moduleOptions, String repeatCount) throws IOException, InterruptedException {
List vmParameters = new ArrayList(myVMParameters);
myForkedDebuggerHelper.setupDebugger(vmParameters);
@@ -89,6 +89,10 @@ public abstract class ForkedByModuleSplitter {
builder.add(classpath);
}
if (moduleOptions != null) {
builder.add(moduleOptions);
}
builder.add(getStarterName());
builder.add(args);
if (repeatCount != null) {
@@ -136,6 +140,16 @@ public abstract class ForkedByModuleSplitter {
while ((workingDir = perDirReader.readLine()) != null) {
final String moduleName = perDirReader.readLine();
final String classpath = perDirReader.readLine();
List moduleOptions = new ArrayList();
String modulePath = perDirReader.readLine();
if (modulePath != null && modulePath.length() > 0) {
moduleOptions.add("-p");
moduleOptions.add(modulePath);
}
final int optionsSize = Integer.parseInt(perDirReader.readLine());
for (int i = 0; i < optionsSize; i++) {
moduleOptions.add(perDirReader.readLine());
}
try {
List classNames = new ArrayList();
@@ -151,7 +165,7 @@ public abstract class ForkedByModuleSplitter {
}
String filters = perDirReader.readLine();
final int childResult = startPerModuleFork(moduleName, classNames, packageName, workingDir, classpath, repeatCount, result, filters != null ? filters : "");
final int childResult = startPerModuleFork(moduleName, classNames, packageName, workingDir, classpath, moduleOptions, repeatCount, result, filters != null ? filters : "");
result = Math.min(childResult, result);
}
catch (Exception e) {
@@ -172,8 +186,9 @@ public abstract class ForkedByModuleSplitter {
String packageName,
String workingDir,
String classpath,
String repeatCount,
int result,
List moduleOptions,
String repeatCount,
int result,
String filters) throws Exception;
protected abstract String getStarterName();

View File

@@ -40,12 +40,18 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
}
if (myWorkingDirsPath == null || new File(myWorkingDirsPath).length() == 0) {
final String classpath = System.getProperty("java.class.path");
final String modulePath = System.getProperty("jdk.module.path");
final List moduleOptions = new ArrayList();
if (modulePath != null && modulePath.length() > 0) {
moduleOptions.add("-p");
moduleOptions.add(modulePath);
}
if (repeatCount != null && RepeatCount.getCount(repeatCount) != 0 && myForkMode.equals("repeat")) {
return startChildFork(createChildArgs(myRootDescription), null, classpath, repeatCount);
return startChildFork(createChildArgs(myRootDescription), null, classpath, moduleOptions, repeatCount);
}
final List children = getChildren(myRootDescription);
final boolean forkTillMethod = myForkMode.equalsIgnoreCase("method");
return splitChildren(children, 0, forkTillMethod, null, classpath, repeatCount);
return splitChildren(children, 0, forkTillMethod, null, classpath, moduleOptions, repeatCount);
}
else {
return splitPerModule(repeatCount);
@@ -57,12 +63,13 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
String packageName,
String workingDir,
String classpath,
String repeatCount,
int result,
List moduleOptions,
String repeatCount,
int result,
String filters) throws Exception {
if (myForkMode.equals("none")) {
final List childArgs = createPerModuleArgs(packageName, workingDir, classNames, myRootDescription, filters);
return startChildFork(childArgs, new File(workingDir), classpath, repeatCount);
return startChildFork(childArgs, new File(workingDir), classpath, moduleOptions, repeatCount);
}
else {
final List children = new ArrayList(getChildren(myRootDescription));
@@ -72,7 +79,7 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
}
}
final boolean forkTillMethod = myForkMode.equalsIgnoreCase("method");
return splitChildren(children, result, forkTillMethod, new File(workingDir), classpath, repeatCount);
return splitChildren(children, result, forkTillMethod, new File(workingDir), classpath, moduleOptions, repeatCount);
}
}
@@ -80,16 +87,18 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
int result,
boolean forkTillMethod,
File workingDir,
String classpath, String repeatCount) throws IOException, InterruptedException {
String classpath,
List moduleOptions,
String repeatCount) throws IOException, InterruptedException {
for (int i = 0, argsLength = children.size(); i < argsLength; i++) {
final Object child = children.get(i);
final List childTests = getChildren(child);
final int childResult;
if (childTests.isEmpty() || !forkTillMethod) {
childResult = startChildFork(createChildArgs(child), workingDir, classpath, repeatCount);
childResult = startChildFork(createChildArgs(child), workingDir, classpath, moduleOptions, repeatCount);
}
else {
childResult = splitChildren(childTests, result, forkTillMethod, workingDir, classpath, repeatCount);
childResult = splitChildren(childTests, result, forkTillMethod, workingDir, classpath, moduleOptions, repeatCount);
}
result = Math.min(childResult, result);
}