forkConfiguration.isDebug() );
}
}
catch ( IOException e )
{
throw new SurefireBooterForkException( "Error creating properties files for forking", e );
}
final Classpath bootClasspathConfiguration = forkConfiguration.getBootClasspath();
final Classpath additionlClassPathUrls =
startupConfiguration.useSystemClassLoader() ? startupConfiguration.getClasspathConfiguration().getTestClasspath()
: null;
// Surefire-booter + all test classes if "useSystemClassloader"
// Surefire-booter if !useSystemClassLoader
Classpath bootClasspath = Classpath.join( bootClasspathConfiguration, additionlClassPathUrls );
@SuppressWarnings( "unchecked" )
OutputStreamFlushableCommandline cli =
forkConfiguration.createCommandLine( bootClasspath.getClassPath(),
startupConfiguration.getClassLoaderConfiguration(),
startupConfiguration.isShadefire(), forkNumber );
final InputStreamCloser inputStreamCloser;
final Thread inputStreamCloserHook;
if ( testProvidingInputStream != null )
{
testProvidingInputStream.setFlushReceiverProvider( cli );
inputStreamCloser = new InputStreamCloser( testProvidingInputStream );
inputStreamCloserHook = new Thread( inputStreamCloser );
ShutdownHookUtils.addShutDownHook( inputStreamCloserHook );
}
else
{
inputStreamCloser = null;
inputStreamCloserHook = null;
}
cli.createArg().setFile( surefireProperties );
if ( systPropsFile != null )
{
cli.createArg().setFile( systPropsFile );
}
ThreadedStreamConsumer threadedStreamConsumer = new ThreadedStreamConsumer( forkClient );
if ( forkConfiguration.isDebug() )
{
System.out.println( "Forking command line: " + cli );
}
RunResult runResult = null;
try
{
final int timeout = forkedProcessTimeoutInSeconds > 0 ? forkedProcessTimeoutInSeconds : 0;
final int result =
CommandLineUtils.executeCommandLine( cli, testProvidingInputStream, threadedStreamConsumer,
threadedStreamConsumer, timeout, inputStreamCloser );
if ( result != RunResult.SUCCESS )
{
throw new SurefireBooterForkException( "Error occurred in starting fork, check output in log" );
}
}
catch ( CommandLineTimeOutException e )
{
runResult = RunResult.timeout( defaultReporterFactory.getGlobalRunStatistics().getRunResult() );
}
catch ( CommandLineException e )
{
runResult = RunResult.failure( defaultReporterFactory.getGlobalRunStatistics().getRunResult(), e );
throw new SurefireBooterForkException( "Error while executing forked tests.", e.getCause() );
}
finally
{
threadedStreamConsumer.close();
if ( inputStreamCloser != null )