mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
pass repeat count to fork vms
This commit is contained in:
+11
-7
@@ -43,7 +43,8 @@ public abstract class ForkedByModuleSplitter {
|
||||
|
||||
public int startSplitting(String[] args,
|
||||
String configName,
|
||||
String commandLinePath) throws Exception {
|
||||
String commandLinePath,
|
||||
String repeatCount) throws Exception {
|
||||
args = myForkedDebuggerHelper.excludeDebugPortFromArgs(args);
|
||||
|
||||
myVMParameters = new ArrayList();
|
||||
@@ -60,14 +61,14 @@ public abstract class ForkedByModuleSplitter {
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
int result = startSplitting(args, configName);
|
||||
int result = startSplitting(args, configName, repeatCount);
|
||||
myForkedDebuggerHelper.closeDebugSocket();
|
||||
sendTime(time);
|
||||
return result;
|
||||
}
|
||||
|
||||
//read output from wrappers
|
||||
protected int startChildFork(List args, File workingDir, String classpath) throws IOException, InterruptedException {
|
||||
protected int startChildFork(List args, File workingDir, String classpath, String repeatCount) throws IOException, InterruptedException {
|
||||
List vmParameters = new ArrayList(myVMParameters);
|
||||
|
||||
myForkedDebuggerHelper.setupDebugger(vmParameters);
|
||||
@@ -94,6 +95,9 @@ public abstract class ForkedByModuleSplitter {
|
||||
builder.add(getStarterName());
|
||||
builder.add(testOutputPath);
|
||||
builder.add(args);
|
||||
if (repeatCount != null) {
|
||||
builder.add(repeatCount);
|
||||
}
|
||||
builder.setWorkingDir(workingDir);
|
||||
|
||||
final Process exec = builder.createProcess();
|
||||
@@ -103,7 +107,7 @@ public abstract class ForkedByModuleSplitter {
|
||||
}
|
||||
|
||||
//read file with classes grouped by module
|
||||
protected int splitPerModule() throws IOException {
|
||||
protected int splitPerModule(String repeatCount) throws IOException {
|
||||
int result = 0;
|
||||
final BufferedReader perDirReader = new BufferedReader(new FileReader(myWorkingDirsPath));
|
||||
try {
|
||||
@@ -126,7 +130,7 @@ public abstract class ForkedByModuleSplitter {
|
||||
classNames.add(className);
|
||||
}
|
||||
|
||||
final int childResult = startPerModuleFork(moduleName, classNames, packageName, workingDir, classpath, result);
|
||||
final int childResult = startPerModuleFork(moduleName, classNames, packageName, workingDir, classpath, repeatCount, result);
|
||||
result = Math.min(childResult, result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -140,14 +144,14 @@ public abstract class ForkedByModuleSplitter {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract int startSplitting(String[] args, String configName) throws Exception;
|
||||
protected abstract int startSplitting(String[] args, String configName, String repeatCount) throws Exception;
|
||||
|
||||
protected abstract int startPerModuleFork(String moduleName,
|
||||
List classNames,
|
||||
String packageName,
|
||||
String workingDir,
|
||||
String classpath,
|
||||
int result) throws Exception;
|
||||
String repeatCount, int result) throws Exception;
|
||||
|
||||
protected abstract String getStarterName();
|
||||
|
||||
|
||||
+10
-10
@@ -31,7 +31,8 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
|
||||
}
|
||||
|
||||
protected int startSplitting(String[] args,
|
||||
String configName) throws Exception {
|
||||
String configName,
|
||||
String repeatCount) throws Exception {
|
||||
myRootDescription = createRootDescription(args, configName);
|
||||
if (myRootDescription == null) {
|
||||
return -1;
|
||||
@@ -40,11 +41,10 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
|
||||
if (myWorkingDirsPath == null || new File(myWorkingDirsPath).length() == 0) {
|
||||
final List children = getChildren(myRootDescription);
|
||||
final boolean forkTillMethod = myForkMode.equalsIgnoreCase("method");
|
||||
return splitChildren(children, 0, forkTillMethod, null, System.getProperty("java.class.path")
|
||||
);
|
||||
return splitChildren(children, 0, forkTillMethod, null, System.getProperty("java.class.path"), repeatCount);
|
||||
}
|
||||
else {
|
||||
return splitPerModule();
|
||||
return splitPerModule(repeatCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
|
||||
String packageName,
|
||||
String workingDir,
|
||||
String classpath,
|
||||
int result) throws Exception {
|
||||
String repeatCount, int result) throws Exception {
|
||||
if (myForkMode.equals("none")) {
|
||||
final List childArgs = createPerModuleArgs(packageName, workingDir, classNames, myRootDescription);
|
||||
return startChildFork(childArgs, new File(workingDir), classpath);
|
||||
return startChildFork(childArgs, new File(workingDir), classpath, repeatCount);
|
||||
}
|
||||
else {
|
||||
final List children = new ArrayList(getChildren(myRootDescription));
|
||||
@@ -66,7 +66,7 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
|
||||
}
|
||||
}
|
||||
final boolean forkTillMethod = myForkMode.equalsIgnoreCase("method");
|
||||
return splitChildren(children, result, forkTillMethod, new File(workingDir), classpath);
|
||||
return splitChildren(children, result, forkTillMethod, new File(workingDir), classpath, repeatCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,16 +74,16 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
|
||||
int result,
|
||||
boolean forkTillMethod,
|
||||
File workingDir,
|
||||
String classpath) throws IOException, InterruptedException {
|
||||
String classpath, 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);
|
||||
childResult = startChildFork(createChildArgs(child), workingDir, classpath, repeatCount);
|
||||
}
|
||||
else {
|
||||
childResult = splitChildren(childTests, result, forkTillMethod, workingDir, classpath);
|
||||
childResult = splitChildren(childTests, result, forkTillMethod, workingDir, classpath, repeatCount);
|
||||
}
|
||||
result = Math.min(childResult, result);
|
||||
}
|
||||
|
||||
@@ -20,11 +20,21 @@ import com.intellij.rt.execution.testFrameworks.ChildVMStarter;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JUnitForkedStarter extends ChildVMStarter {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new JUnitForkedStarter().startVM(args);
|
||||
List argList = new ArrayList();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
final int count = RepeatCount.getCount(args[i]);
|
||||
if (count > 0) {
|
||||
JUnitStarter.ourCount = count;
|
||||
continue;
|
||||
}
|
||||
argList.add(args[i]);
|
||||
}
|
||||
new JUnitForkedStarter().startVM((String[])argList.toArray(new String[argList.size()]));
|
||||
}
|
||||
|
||||
protected void configureFrameworkAndRun(String[] args, PrintStream out, PrintStream err)
|
||||
@@ -39,7 +49,7 @@ public class JUnitForkedStarter extends ChildVMStarter {
|
||||
IdeaTestRunner testRunner = (IdeaTestRunner)JUnitStarter.getAgentClass(argentName).newInstance();
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
testRunner.setStreams(new SegmentedOutputStream(out, true), new SegmentedOutputStream(err, true), lastIdx);
|
||||
System.exit(testRunner.startRunnerWithArgs(childTestDescription, listeners, null, 1, false));
|
||||
System.exit(testRunner.startRunnerWithArgs(childTestDescription, listeners, null, JUnitStarter.ourCount, false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -45,8 +46,9 @@ public class JUnitStarter {
|
||||
private static String ourForkMode;
|
||||
private static String ourCommandFileName;
|
||||
private static String ourWorkingDirs;
|
||||
private static int ourCount = 1;
|
||||
protected static int ourCount = 1;
|
||||
public static boolean SM_RUNNER = isSmRunner();
|
||||
public static String ourRepeatCount = null;
|
||||
|
||||
private static boolean isSmRunner() {
|
||||
try {
|
||||
@@ -147,6 +149,7 @@ public class JUnitStarter {
|
||||
|
||||
final int count = RepeatCount.getCount(arg);
|
||||
if (count != 0) {
|
||||
ourRepeatCount = arg;
|
||||
ourCount = count;
|
||||
continue;
|
||||
}
|
||||
@@ -243,7 +246,7 @@ public class JUnitStarter {
|
||||
PrintStream printOutputStream = SM_RUNNER ? ((PrintStream)out) : ((SegmentedOutputStream)out).getPrintStream();
|
||||
PrintStream printErrStream = SM_RUNNER ? ((PrintStream)err) : ((SegmentedOutputStream)err).getPrintStream();
|
||||
return new JUnitForkedSplitter(ourWorkingDirs, ourForkMode, printOutputStream, printErrStream, newArgs)
|
||||
.startSplitting(args, name, ourCommandFileName);
|
||||
.startSplitting(args, name, ourCommandFileName, ourRepeatCount);
|
||||
}
|
||||
}
|
||||
testRunner.setStreams(out, err, 0);
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class TestNGForkTest {
|
||||
new TestNGForkedSplitter(tempFile.getCanonicalPath(), System.out, System.err, Collections.singletonList(tempFile.getCanonicalPath())) {
|
||||
private boolean myStarted = false;
|
||||
@Override
|
||||
protected int startChildFork(List args, File workingDir, String classpath) throws IOException, InterruptedException {
|
||||
protected int startChildFork(List args, File workingDir, String classpath, String repeatCount) throws IOException, InterruptedException {
|
||||
Assert.assertEquals(dynamicClasspath, myDynamicClasspath);
|
||||
Assert.assertArrayEquals(vmParams, myVMParameters.toArray());
|
||||
Assert.assertEquals(workingDirFromFile, workingDir.getName());
|
||||
@@ -68,7 +68,7 @@ public class TestNGForkTest {
|
||||
myStarted = true;
|
||||
return 0;
|
||||
}
|
||||
}.startSplitting(ArrayUtil.EMPTY_STRING_ARRAY, "", commandLineFile.getCanonicalPath());
|
||||
}.startSplitting(ArrayUtil.EMPTY_STRING_ARRAY, "", commandLineFile.getCanonicalPath(), null);
|
||||
}
|
||||
finally {
|
||||
FileUtil.delete(tempDirectory);
|
||||
|
||||
@@ -22,7 +22,6 @@ package org.testng;
|
||||
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.intellij.rt.execution.testFrameworks.ForkedDebuggerHelper;
|
||||
import org.testng.remote.RemoteArgs;
|
||||
import org.testng.remote.RemoteTestNG;
|
||||
|
||||
import java.io.*;
|
||||
@@ -114,7 +113,7 @@ public class RemoteTestNGStarter {
|
||||
if (commandFileName != null) {
|
||||
if (workingDirs != null && new File(workingDirs).length() > 0) {
|
||||
System.exit(new TestNGForkedSplitter(workingDirs, System.out, System.err, newArgs)
|
||||
.startSplitting(args, param, commandFileName));
|
||||
.startSplitting(args, param, commandFileName, null));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ public class TestNGForkedSplitter extends ForkedByModuleSplitter {
|
||||
|
||||
@Override
|
||||
protected int startSplitting(String[] args,
|
||||
String configName) throws Exception {
|
||||
return splitPerModule();
|
||||
String configName, String repeatCount) throws Exception {
|
||||
return splitPerModule(repeatCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +48,7 @@ public class TestNGForkedSplitter extends ForkedByModuleSplitter {
|
||||
String packageName,
|
||||
String workingDir,
|
||||
String classpath,
|
||||
int result) throws Exception {
|
||||
String repeatCount, int result) throws Exception {
|
||||
final LinkedHashMap<String, Map<String, List<String>>> classes = new LinkedHashMap<String, Map<String, List<String>>>();
|
||||
for (Object className : classNames) {
|
||||
classes.put((String)className, null);
|
||||
@@ -63,7 +63,7 @@ public class TestNGForkedSplitter extends ForkedByModuleSplitter {
|
||||
TestNGXmlSuiteHelper.writeSuite(classes, new LinkedHashMap<String, String>(), moduleName, rootPath, TestNGXmlSuiteHelper.Logger.DEAF);
|
||||
file.deleteOnExit();
|
||||
|
||||
return Math.min(result, startChildFork(Collections.singletonList(file.getAbsolutePath()), new File(workingDir), classpath));
|
||||
return Math.min(result, startChildFork(Collections.singletonList(file.getAbsolutePath()), new File(workingDir), classpath, repeatCount));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user