forkConfiguration.isDebug() );
}
}
catch ( IOException e )
{
throw new SurefireBooterForkException( "Error creating properties files for forking", e );
}
// this could probably be simplified further
final Classpath bootClasspathConfiguration = startupConfiguration.isProviderMainClass()
? startupConfiguration.getClasspathConfiguration().getProviderClasspath()
: forkConfiguration.getBootClasspath();
Classpath bootClasspath = join(
join( bootClasspathConfiguration, startupConfiguration.getClasspathConfiguration().getTestClasspath() ),
startupConfiguration.getClasspathConfiguration().getProviderClasspath() );
if ( log.isDebugEnabled() )
{
log.debug( bootClasspath.getLogMessage( "boot" ) );
log.debug( bootClasspath.getCompactLogMessage( "boot(compact)" ) );
}
OutputStreamFlushableCommandline cli =
forkConfiguration.createCommandLine( bootClasspath.getClassPath(), startupConfiguration, 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 )