log("Test class names:\n" + testClassPerLine, Project.MSG_VERBOSE);
Files.write(testClassPerLine, classNamesFile, Charsets.UTF_8);
// Prepare command line for java execution.
CommandlineJava commandline;
commandline = (CommandlineJava) getCommandline().clone();
commandline.createClasspath(getProject()).add(addSlaveClasspath());
commandline.setClassname(SlaveMainSafe.class.getName());
if (slave.slaves == 1) {
commandline.createArgument().setValue(SlaveMain.OPTION_FREQUENT_FLUSH);
}
// Set up full output files.
File sysoutFile = tempFile(uniqueSeed,
"junit4-J" + slave.id, ".sysout", getTempDir());
File syserrFile = tempFile(uniqueSeed,
"junit4-J" + slave.id, ".syserr", getTempDir());
// Set up communication channel.
File eventFile = tempFile(uniqueSeed,
"junit4-J" + slave.id, ".events", getTempDir());
temporaryFiles.add(eventFile);
commandline.createArgument().setValue(SlaveMain.OPTION_EVENTSFILE);
commandline.createArgument().setFile(eventFile);
if (sysouts) {
commandline.createArgument().setValue(SlaveMain.OPTION_SYSOUTS);
}
if (debugStream) {
commandline.createArgument().setValue(SlaveMain.OPTION_DEBUGSTREAM);
}
InputStream eventStream = new TailInputStream(eventFile);
// Set up input suites file.
commandline.createArgument().setValue("@" + classNamesFile.getAbsolutePath());
// Emit command line before -stdin to avoid confusion.
slave.slaveCommandLine = escapeAndJoin(commandline.getCommandline());
log("Forked JVM process command line (may need escape sequences for your shell):\n" +
slave.slaveCommandLine, Project.MSG_VERBOSE);
commandline.createArgument().setValue(SlaveMain.OPTION_STDIN);
final EventBus eventBus = new EventBus("slave-" + slave.id);
final DiagnosticsListener diagnosticsListener = new DiagnosticsListener(slave, this);
eventBus.register(diagnosticsListener);
eventBus.register(new AggregatingListener(aggregatedBus, slave));