TestRequest testRequest = new TestRequest(suiteXmlFiles, testClassesDir, TestListResolver.getEmptyTestListResolver()); ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams, new RunOrderParameters(runOrder, null), failIfNoTests, reporterConfig, null, testRequest, extractProviderProperties(testProps), null, false, Collections.<CommandLineOption> emptyList(),
private SurefireProvider createProviderInCurrentClassloader( ForkingReporterFactory reporterManagerFactory ) { BaseProviderFactory bpf = new BaseProviderFactory( reporterManagerFactory, true ); bpf.setTestRequest( providerConfiguration.getTestSuiteDefinition() ); bpf.setReporterConfiguration( providerConfiguration.getReporterConfiguration() ); ClassLoader classLoader = currentThread().getContextClassLoader(); bpf.setClassLoaders( classLoader ); bpf.setTestArtifactInfo( providerConfiguration.getTestArtifact() ); bpf.setProviderProperties( providerConfiguration.getProviderProperties() ); bpf.setRunOrderParameters( providerConfiguration.getRunOrderParameters() ); bpf.setDirectoryScannerParameters( providerConfiguration.getDirScannerParams() ); bpf.setMainCliOptions( providerConfiguration.getMainCliOptions() ); bpf.setSkipAfterFailureCount( providerConfiguration.getSkipAfterFailureCount() ); bpf.setShutdown( providerConfiguration.getShutdown() ); bpf.setSystemExitTimeout( providerConfiguration.getSystemExitTimeout() ); String providerClass = startupConfiguration.getActualClassName(); return (SurefireProvider) instantiateOneArg( classLoader, providerClass, ProviderParameters.class, bpf ); }
Thread shutdown = createShutdownHookThread( testStreams, providerConfiguration.getShutdown() ); int failFastCount = providerConfiguration.getSkipAfterFailureCount(); final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger( failFastCount ); final Collection<Future<RunResult>> results = new ArrayList<>( forkCount );
private void setupBooter( String tmpDir, String dumpFileName, String surefirePropsFileName, String effectiveSystemPropertiesFileName ) throws IOException { BooterDeserializer booterDeserializer = new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) ); // todo: print PID in debug console logger in version 2.21.2 pingScheduler = isDebugging() ? null : listenToShutdownCommands( booterDeserializer.getPluginPid() ); setSystemProperties( new File( tmpDir, effectiveSystemPropertiesFileName ) ); providerConfiguration = booterDeserializer.deserialize(); DumpErrorSingleton.getSingleton() .init( providerConfiguration.getReporterConfiguration().getReportsDirectory(), dumpFileName ); startupConfiguration = booterDeserializer.getProviderConfiguration(); systemExitTimeoutInSeconds = providerConfiguration.systemExitTimeout( DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS ); AbstractPathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); if ( classpathConfiguration.isClassPathConfig() ) { if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() ) { classpathConfiguration.toRealPath( ClasspathConfiguration.class ) .trickClassPathWhenManifestOnlyClasspath(); } startupConfiguration.writeSurefireTestClasspathProperty(); } ClassLoader classLoader = currentThread().getContextClassLoader(); classLoader.setDefaultAssertionStatus( classpathConfiguration.isEnableAssertions() ); boolean readTestsFromCommandReader = providerConfiguration.isReadTestsFromInStream(); testSet = createTestSet( providerConfiguration.getTestForFork(), readTestsFromCommandReader, classLoader ); }
public RunResult run( @Nonnull SurefireProperties effectiveSystemProperties, @Nonnull DefaultScanResult scanResult ) throws SurefireBooterForkException, SurefireExecutionException { try { Map<String, String> providerProperties = providerConfiguration.getProviderProperties(); scanResult.writeTo( providerProperties ); return isForkOnce() ? run( effectiveSystemProperties, providerProperties ) : run( effectiveSystemProperties ); } finally { defaultReporterFactory.mergeFromOtherFactories( defaultReporterFactories ); defaultReporterFactory.close(); pingThreadScheduler.shutdownNow(); timeoutCheckScheduler.shutdownNow(); } }
private RunResult run( SurefireProperties effectiveSystemProperties, Map<String, String> providerProperties ) throws SurefireBooterForkException { TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder(); PropertiesWrapper props = new PropertiesWrapper( providerProperties ); TestLessInputStream stream = builder.build(); Thread shutdown = createImmediateShutdownHookThread( builder, providerConfiguration.getShutdown() ); ScheduledFuture<?> ping = triggerPingTimerForShutdown( builder ); int forkNumber = drawNumber(); try { addShutDownHook( shutdown ); DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration, log, forkNumber ); defaultReporterFactories.add( forkedReporterFactory ); ForkClient forkClient = new ForkClient( forkedReporterFactory, stream, log, new AtomicBoolean(), forkNumber ); return fork( null, props, forkClient, effectiveSystemProperties, forkNumber, stream, false ); } finally { returnNumber( forkNumber ); removeShutdownHook( shutdown ); ping.cancel( true ); builder.removeStream( stream ); } }
private ForkingReporterFactory createForkingReporterFactory() { final boolean trimStackTrace = providerConfiguration.getReporterConfiguration().isTrimStackTrace(); return new ForkingReporterFactory( trimStackTrace, originalOut ); }
final TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder(); ScheduledFuture<?> ping = triggerPingTimerForShutdown( builder ); Thread shutdown = createCachableShutdownHookThread( builder, providerConfiguration.getShutdown() ); try int failFastCount = providerConfiguration.getSkipAfterFailureCount(); final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger( failFastCount ); final AtomicBoolean printedErrorStream = new AtomicBoolean();
public RunResult run( @Nonnull SurefireProperties effectiveSystemProperties, @Nonnull DefaultScanResult scanResult ) throws SurefireBooterForkException { try { Map<String, String> providerProperties = providerConfiguration.getProviderProperties(); scanResult.writeTo( providerProperties ); return isForkOnce() ? run( effectiveSystemProperties, providerProperties ) : run( effectiveSystemProperties ); } finally { defaultReporterFactory.mergeFromOtherFactories( defaultReporterFactories ); defaultReporterFactory.close(); pingThreadScheduler.shutdownNow(); timeoutCheckScheduler.shutdownNow(); } }
private RunResult run( SurefireProperties effectiveSystemProperties, Map<String, String> providerProperties ) throws SurefireBooterForkException { TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder(); PropertiesWrapper props = new PropertiesWrapper( providerProperties ); TestLessInputStream stream = builder.build(); Thread shutdown = createImmediateShutdownHookThread( builder, providerConfiguration.getShutdown() ); ScheduledFuture<?> ping = triggerPingTimerForShutdown( builder ); int forkNumber = drawNumber(); try { addShutDownHook( shutdown ); DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration, log, forkNumber ); defaultReporterFactories.add( forkedReporterFactory ); ForkClient forkClient = new ForkClient( forkedReporterFactory, stream, log, new AtomicBoolean(), forkNumber ); return fork( null, props, forkClient, effectiveSystemProperties, forkNumber, stream, false ); } finally { returnNumber( forkNumber ); removeShutdownHook( shutdown ); ping.cancel( true ); builder.removeStream( stream ); } }
public SurefireProvider createProvider( boolean isInsideFork ) { final Thread currentThread = Thread.currentThread(); final ClassLoader systemClassLoader = currentThread.getContextClassLoader(); currentThread.setContextClassLoader( classLoader ); // Note: Duplicated in ForkedBooter#createProviderInCurrentClassloader Object o = surefireReflector.createBooterConfiguration( classLoader, reporterManagerFactory, isInsideFork ); surefireReflector.setTestSuiteDefinitionAware( o, providerConfiguration.getTestSuiteDefinition() ); surefireReflector.setProviderPropertiesAware( o, providerConfiguration.getProviderProperties() ); surefireReflector.setReporterConfigurationAware( o, providerConfiguration.getReporterConfiguration() ); surefireReflector.setTestClassLoaderAware( o, classLoader ); surefireReflector.setTestArtifactInfoAware( o, providerConfiguration.getTestArtifact() ); surefireReflector.setRunOrderParameters( o, providerConfiguration.getRunOrderParameters() ); surefireReflector.setIfDirScannerAware( o, providerConfiguration.getDirScannerParams() ); surefireReflector.setMainCliOptions( o, providerConfiguration.getMainCliOptions() ); surefireReflector.setSkipAfterFailureCount( o, providerConfiguration.getSkipAfterFailureCount() ); surefireReflector.setShutdown( o, providerConfiguration.getShutdown() ); if ( isInsideFork ) { surefireReflector.setSystemExitTimeout( o, providerConfiguration.getSystemExitTimeout() ); } Object provider = surefireReflector.instantiateProvider( startupConfiguration.getActualClassName(), o ); currentThread.setContextClassLoader( systemClassLoader ); return new ProviderProxy( provider, classLoader ); }
Thread shutdown = createShutdownHookThread( testStreams, providerConfiguration.getShutdown() ); int failFastCount = providerConfiguration.getSkipAfterFailureCount(); final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger( failFastCount ); final Collection<Future<RunResult>> results = new ArrayList<Future<RunResult>>( forkCount );
systemExitTimeoutAsString == null ? null : Integer.valueOf( systemExitTimeoutAsString ); return new ProviderConfiguration( dirScannerParams, runOrderParameters, properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg, testSuiteDefinition, properties.getProperties(), typeEncodedTestForFork,
Map<String, String> providerProperties = providerConfiguration.getProviderProperties(); try
properties.setProperty( CHILD_DELEGATION, toString( cp.isChildDelegation() ) ); TestArtifactInfo testNg = booterConfiguration.getTestArtifact(); if ( testNg != null ) TestRequest testSuiteDefinition = booterConfiguration.getTestSuiteDefinition(); if ( testSuiteDefinition != null ) DirectoryScannerParameters directoryScannerParameters = booterConfiguration.getDirScannerParams(); if ( directoryScannerParameters != null ) final RunOrderParameters runOrderParameters = booterConfiguration.getRunOrderParameters(); if ( runOrderParameters != null ) ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration(); boolean rep = reporterConfiguration.isTrimStackTrace(); File reportsDirectory = replaceForkThreadsInPath( reporterConfiguration.getReportsDirectory(), forkNumber ); properties.setProperty( USESYSTEMCLASSLOADER, toString( classLoaderConfig.isUseSystemClassLoader() ) ); properties.setProperty( USEMANIFESTONLYJAR, toString( classLoaderConfig.isUseManifestOnlyJar() ) ); properties.setProperty( FAILIFNOTESTS, toString( booterConfiguration.isFailIfNoTests() ) ); properties.setProperty( PROVIDER_CONFIGURATION, providerConfiguration.getProviderClassName() ); properties.setProperty( FAIL_FAST_COUNT, toString( booterConfiguration.getSkipAfterFailureCount() ) ); properties.setProperty( SHUTDOWN, booterConfiguration.getShutdown().name() ); List<CommandLineOption> mainCliOptions = booterConfiguration.getMainCliOptions(); if ( mainCliOptions != null ) properties.setNullableProperty( SYSTEM_EXIT_TIMEOUT, toString( booterConfiguration.getSystemExitTimeout() ) );
final TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder(); ScheduledFuture<?> ping = triggerPingTimerForShutdown( builder ); Thread shutdown = createCachableShutdownHookThread( builder, providerConfiguration.getShutdown() ); try int failFastCount = providerConfiguration.getSkipAfterFailureCount(); final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger( failFastCount ); final AtomicBoolean printedErrorStream = new AtomicBoolean();
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, actualFailIfNoTests, reporterConfiguration,
Map<String, String> providerProperties = providerConfiguration.getProviderProperties(); try
properties.setProperty( CHILD_DELEGATION, toString( cp.isChildDelegation() ) ); TestArtifactInfo testNg = booterConfiguration.getTestArtifact(); if ( testNg != null ) TestRequest testSuiteDefinition = booterConfiguration.getTestSuiteDefinition(); if ( testSuiteDefinition != null ) DirectoryScannerParameters directoryScannerParameters = booterConfiguration.getDirScannerParams(); if ( directoryScannerParameters != null ) final RunOrderParameters runOrderParameters = booterConfiguration.getRunOrderParameters(); if ( runOrderParameters != null ) ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration(); boolean rep = reporterConfiguration.isTrimStackTrace(); File reportsDirectory = replaceForkThreadsInPath( reporterConfiguration.getReportsDirectory(), forkNumber ); properties.setProperty( USESYSTEMCLASSLOADER, toString( classLoaderConfig.isUseSystemClassLoader() ) ); properties.setProperty( USEMANIFESTONLYJAR, toString( classLoaderConfig.isUseManifestOnlyJar() ) ); properties.setProperty( FAILIFNOTESTS, toString( booterConfiguration.isFailIfNoTests() ) ); properties.setProperty( PROVIDER_CONFIGURATION, providerConfiguration.getProviderClassName() ); properties.setProperty( FAIL_FAST_COUNT, toString( booterConfiguration.getSkipAfterFailureCount() ) ); properties.setProperty( SHUTDOWN, booterConfiguration.getShutdown().name() ); List<CommandLineOption> mainCliOptions = booterConfiguration.getMainCliOptions(); if ( mainCliOptions != null ) properties.setNullableProperty( SYSTEM_EXIT_TIMEOUT, toString( booterConfiguration.getSystemExitTimeout() ) );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, actualFailIfNoTests, reporterConfiguration,