private void startReceivingTests(WorkerProcessContext workerProcessContext, ServiceRegistry testServices) { TestClassProcessor targetProcessor = factory.create(testServices); IdGenerator<Object> idGenerator = testServices.get(IdGenerator.class); targetProcessor = new WorkerTestClassProcessor(targetProcessor, idGenerator.generateId(), workerProcessContext.getDisplayName(), testServices.get(TimeProvider.class)); ContextClassLoaderProxy<TestClassProcessor> proxy = new ContextClassLoaderProxy<TestClassProcessor>( TestClassProcessor.class, targetProcessor, workerProcessContext.getApplicationClassLoader()); processor = proxy.getSource(); ObjectConnection serverConnection = workerProcessContext.getServerConnection(); serverConnection.useParameterSerializers(TestEventSerializer.create()); this.resultProcessor = serverConnection.addOutgoing(TestResultProcessor.class); serverConnection.addIncoming(RemoteTestClassProcessor.class, this); serverConnection.connect(); }
RemoteTestClassProcessor forkProcess() { WorkerProcessBuilder builder = workerFactory.create(new TestWorker(processorFactory)); builder.setBaseName("Gradle Test Executor"); builder.setImplementationClasspath(getTestWorkerImplementationClasspath()); builder.applicationClasspath(classPath); options.copyTo(builder.getJavaCommand()); buildConfigAction.execute(builder); workerProcess = builder.build(); workerProcess.start(); ObjectConnection connection = workerProcess.getConnection(); connection.useParameterSerializers(TestEventSerializer.create()); connection.addIncoming(TestResultProcessor.class, resultProcessor); RemoteTestClassProcessor remoteProcessor = connection.addOutgoing(RemoteTestClassProcessor.class); connection.connect(); remoteProcessor.startProcessing(); return remoteProcessor; }
@Override public void startProcessing(TestResultProcessor resultProcessor) { // Build a result processor chain ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader(); TestResultProcessor resultProcessorChain = new AttachParentTestResultProcessor(resultProcessor); TestClassExecutionEventGenerator eventGenerator = new TestClassExecutionEventGenerator(resultProcessorChain, idGenerator, timeProvider); // Wrap the result processor chain up in a blocking actor, to make the whole thing thread-safe resultProcessorActor = actorFactory.createBlockingActor(eventGenerator); TestResultProcessor threadSafeResultProcessor = resultProcessorActor.getProxy(TestResultProcessor.class); TestClassExecutionListener threadSafeTestClassListener = resultProcessorActor.getProxy(TestClassExecutionListener.class); // Build the JUnit adaptor stuff JUnitTestEventAdapter junitEventAdapter = new JUnitTestEventAdapter(threadSafeResultProcessor, timeProvider, idGenerator); executer = new JUnitTestClassExecuter(applicationClassLoader, spec, junitEventAdapter, threadSafeTestClassListener); }
RemoteTestClassProcessor forkProcess() { WorkerProcessBuilder builder = workerFactory.create(new ForciblyStoppableTestWorker(processorFactory)); builder.setBaseName("Gradle Test Executor"); builder.setImplementationClasspath(getTestWorkerImplementationClasspath()); builder.applicationClasspath(classPath); options.copyTo(builder.getJavaCommand()); buildConfigAction.execute(builder); workerProcess = builder.build(); workerProcess.start(); ObjectConnection connection = workerProcess.getConnection(); connection.useParameterSerializers(TestEventSerializer.create()); connection.addIncoming(TestResultProcessor.class, resultProcessor); RemoteTestClassProcessor remoteProcessor = connection.addOutgoing(RemoteTestClassProcessor.class); connection.connect(); remoteProcessor.startProcessing(); return remoteProcessor; }
private void startReceivingTests(WorkerProcessContext workerProcessContext, ServiceRegistry testServices) { TestClassProcessor targetProcessor = factory.create(testServices); IdGenerator<Object> idGenerator = testServices.get(IdGenerator.class); targetProcessor = new WorkerTestClassProcessor(targetProcessor, idGenerator.generateId(), workerProcessContext.getDisplayName(), new TrueTimeProvider()); ContextClassLoaderProxy<TestClassProcessor> proxy = new ContextClassLoaderProxy<TestClassProcessor>( TestClassProcessor.class, targetProcessor, workerProcessContext.getApplicationClassLoader()); processor = proxy.getSource(); ObjectConnection serverConnection = workerProcessContext.getServerConnection(); serverConnection.useParameterSerializer(new TestEventSerializer()); this.resultProcessor = serverConnection.addOutgoing(TestResultProcessor.class); serverConnection.addIncoming(RemoteTestClassProcessor.class, this); serverConnection.connect(); }
RemoteTestClassProcessor forkProcess() { WorkerProcessBuilder builder = workerFactory.create(); builder.setBaseName("Gradle Test Executor"); builder.applicationClasspath(classPath); builder.setLoadApplicationInSystemClassLoader(true); builder.worker(new TestWorker(processorFactory)); options.copyTo(builder.getJavaCommand()); buildConfigAction.execute(builder); workerProcess = builder.build(); workerProcess.start(); ObjectConnection connection = workerProcess.getConnection(); connection.useParameterSerializer(new TestEventSerializer()); connection.addIncoming(TestResultProcessor.class, resultProcessor); RemoteTestClassProcessor remoteProcessor = connection.addOutgoing(RemoteTestClassProcessor.class); connection.connect(); remoteProcessor.startProcessing(); return remoteProcessor; }
@Override public void startProcessing(TestResultProcessor resultProcessor) { // Wrap the processor in an actor, to make it thread-safe resultProcessorActor = actorFactory.createBlockingActor(resultProcessor); this.resultProcessor = resultProcessorActor.getProxy(TestResultProcessor.class); applicationClassLoader = Thread.currentThread().getContextClassLoader(); }
@Override public void execute(final Test testTask, TestResultProcessor testResultProcessor) { final TestFramework testFramework = testTask.getTestFramework(); final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory(); final BuildOperationWorkerRegistry.Operation currentOperation = buildOperationWorkerRegistry.getCurrent(); final Set<File> classpath = ImmutableSet.copyOf(testTask.getClasspath()); final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() { public TestClassProcessor create() { return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask, classpath, testFramework.getWorkerConfigurationAction(), moduleRegistry, currentOperation); } }; Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() { public TestClassProcessor create() { return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery()); } }; TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(), reforkingProcessorFactory, actorFactory); final FileTree testClassFiles = testTask.getCandidateClassFiles(); Runnable detector; if (testTask.isScanForTestClasses()) { TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector(); testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir()); testFrameworkDetector.setTestClasspath(classpath); detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor); } else { detector = new DefaultTestClassScanner(testClassFiles, null, processor); } final Object testTaskOperationId = buildOperationExecutor.getCurrentOperation().getId(); new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider(), testTaskOperationId, testTask.getPath(), "Gradle Test Run " + testTask.getIdentityPath()).run(); }
@Override public void execute(Test test, TestResultProcessor testResultProcessor) { LOGGER.info("Executing tests in Eclipse"); int pdeTestPort = new PDETestPortLocator().locatePDETestPortNumber(); if (pdeTestPort == -1) { throw new GradleException("Cannot allocate port for PDE test run"); } LOGGER.info("Will use port {} to communicate with Eclipse.", pdeTestPort); runPDETestsInEclipse(test, testResultProcessor, pdeTestPort); }
public EclipseTestListener(TestResultProcessor testResultProcessor, String suite, Object waitMonitor, Object testTaskOperationId, Object rootTestSuiteId) { this.resultProcessor = new AttachParentTestResultProcessor(testResultProcessor); this.waitMonitor = waitMonitor; this.suiteName = suite; this.testTaskOperationId = testTaskOperationId; this.rootTestSuiteId = rootTestSuiteId; }
public void startProcessing(TestResultProcessor resultProcessor) { // Build a result processor chain ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader(); TestResultProcessor resultProcessorChain = new AttachParentTestResultProcessor(new CaptureTestOutputTestResultProcessor(resultProcessor, outputRedirector)); TestClassExecutionEventGenerator eventGenerator = new TestClassExecutionEventGenerator(resultProcessorChain, idGenerator, timeProvider); // Wrap the result processor chain up in a blocking actor, to make the whole thing thread-safe resultProcessorActor = actorFactory.createBlockingActor(eventGenerator); TestResultProcessor threadSafeResultProcessor = resultProcessorActor.getProxy(TestResultProcessor.class); TestClassExecutionListener threadSafeTestClassListener = resultProcessorActor.getProxy(TestClassExecutionListener.class); // Build the JUnit adaptor stuff JUnitTestEventAdapter junitEventAdapter = new JUnitTestEventAdapter(threadSafeResultProcessor, timeProvider, idGenerator); executer = new JUnitTestClassExecuter(applicationClassLoader, spec, junitEventAdapter, threadSafeTestClassListener); }
public void execute(final Test testTask, TestResultProcessor testResultProcessor) { final TestFramework testFramework = testTask.getTestFramework(); final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory(); final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() { public TestClassProcessor create() { return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask, testTask.getClasspath(), testFramework.getWorkerConfigurationAction()); } }; Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() { public TestClassProcessor create() { return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery()); } }; TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(), reforkingProcessorFactory, actorFactor); final FileTree testClassFiles = testTask.getCandidateClassFiles(); Runnable detector; if (testTask.isScanForTestClasses()) { TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector(); testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir()); testFrameworkDetector.setTestClasspath(testTask.getClasspath()); detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor); } else { detector = new DefaultTestClassScanner(testClassFiles, null, processor); } new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider()).run(); }
@Override public void startProcessing(TestResultProcessor resultProcessor) { this.resultProcessor = resultProcessor; }
@Override public void startProcessing(TestResultProcessor resultProcessor) { // Create a processor that processes events in its own thread resultProcessorActor = actorFactory.createActor(resultProcessor); this.resultProcessor = resultProcessorActor.getProxy(TestResultProcessor.class); }
public CaptureTestOutputTestResultProcessor(TestResultProcessor processor, StandardOutputRedirector outputRedirector) { this(processor, new TestOutputRedirector(processor, outputRedirector)); }
CaptureTestOutputTestResultProcessor(TestResultProcessor processor, TestOutputRedirector outputRedirector) { this.processor = processor; this.outputRedirector = outputRedirector; }
TestOutputRedirector(TestResultProcessor processor, StandardOutputRedirector redirector) { this.redirector = redirector; this.outForwarder = new Forwarder(processor, TestOutputEvent.Destination.StdOut); this.errForwarder = new Forwarder(processor, TestOutputEvent.Destination.StdErr); }
public Forwarder(TestResultProcessor processor, TestOutputEvent.Destination dest) { this.processor = processor; this.dest = dest; }
@Override public void startProcessing(TestResultProcessor testResultProcessor) { // no-op }
public JovialOutputHandler(FileCollection classpath, Pipe pipe, TestResultProcessor testResultProcessor) { this.classpath = classpath; this.pipe = pipe; this.testResultProcessor = testResultProcessor; }
@Override public void execute(final Test testTask, TestResultProcessor testResultProcessor) { final TestFramework testFramework = testTask.getTestFramework(); final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory(); final Set<File> classpath = ImmutableSet.copyOf(testTask.getClasspath()); final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() { public TestClassProcessor create() { return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask, classpath, testFramework.getWorkerConfigurationAction(), moduleRegistry); } }; Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() { public TestClassProcessor create() { return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery()); } }; TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(), reforkingProcessorFactory, actorFactory); final FileTree testClassFiles = testTask.getCandidateClassFiles(); Runnable detector; if (testTask.isScanForTestClasses()) { TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector(); testFrameworkDetector.setTestClasses(testTask.getTestClassesDirs().getFiles()); testFrameworkDetector.setTestClasspath(classpath); detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor); } else { detector = new DefaultTestClassScanner(testClassFiles, null, processor); } Object testTaskOperationId; try { testTaskOperationId = buildOperationExecutor.getCurrentOperation().getParentId(); } catch (Exception e) { testTaskOperationId = UUID.randomUUID(); } new TestMainAction(detector, processor, testResultProcessor, clock, testTaskOperationId, testTask.getPath(), "Gradle Test Run " + testTask.getIdentityPath()).run(); }
@TaskAction public void executeTests() { LogLevel currentLevel = getCurrentLogLevel(); TestLogging levelLogging = testLogging.get(currentLevel); TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging); TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter); addTestListener(eventLogger); addTestOutputListener(eventLogger); if (!getFilter().getIncludePatterns().isEmpty()) { addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns())); } File binaryResultsDir = getBinResultsDir(); getProject().delete(binaryResultsDir); getProject().mkdir(binaryResultsDir); Map<String, TestClassResult> results = new HashMap<String, TestClassResult>(); TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir); TestOutputStore.Writer outputWriter = testOutputStore.writer(); TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter); addTestListener(testReportDataCollector); addTestOutputListener(testReportDataCollector); TestCountLogger testCountLogger = new TestCountLogger(getProgressLoggerFactory()); addTestListener(testCountLogger); TestResultProcessor resultProcessor = new TestListenerAdapter( getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource()); if (testExecuter == null) { testExecuter = new DefaultTestExecuter(getProcessBuilderFactory(), getActorFactory()); } try { testExecuter.execute(this, resultProcessor); } finally { testExecuter = null; testListenerBroadcaster.removeAll(); testOutputListenerBroadcaster.removeAll(); outputWriter.close(); } new TestResultSerializer(binaryResultsDir).write(results.values()); TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader()); try { if (testReporter == null) { testReporter = new DefaultTestReport(); } JUnitXmlReport junitXml = reports.getJunitXml(); if (junitXml.isEnabled()) { TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase() ? TestOutputAssociation.WITH_TESTCASE : TestOutputAssociation.WITH_SUITE; Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation); binary2JUnitXmlReportGenerator.generate(); } DirectoryReport html = reports.getHtml(); if (!html.isEnabled()) { getLogger().info("Test report disabled, omitting generation of the HTML test report."); } else { testReporter.generateReport(testResultsProvider, html.getDestination()); } } finally { CompositeStoppable.stoppable(testResultsProvider).stop(); testReporter = null; testFramework = null; } if (testCountLogger.hadFailures()) { handleTestFailures(); } }
public void startProcessing(TestResultProcessor resultProcessor) { this.resultProcessor = resultProcessor; }
public void startProcessing(TestResultProcessor resultProcessor) { resultProcessorActor = actorFactory.createActor(resultProcessor); this.resultProcessor = resultProcessorActor.getProxy(TestResultProcessor.class); }
@TaskAction public void executeTests() { LogLevel currentLevel = getCurrentLogLevel(); TestLogging levelLogging = testLogging.get(currentLevel); TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging); TestEventLogger eventLogger = new TestEventLogger(textOutputFactory, currentLevel, levelLogging, exceptionFormatter); addTestListener(eventLogger); addTestOutputListener(eventLogger); if (!getFilter().getIncludePatterns().isEmpty()) { addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns())); } File binaryResultsDir = getBinResultsDir(); getProject().delete(binaryResultsDir); getProject().mkdir(binaryResultsDir); Map<String, TestClassResult> results = new HashMap<String, TestClassResult>(); TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir); TestOutputStore.Writer outputWriter = testOutputStore.writer(); TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter); addTestListener(testReportDataCollector); addTestOutputListener(testReportDataCollector); TestCountLogger testCountLogger = new TestCountLogger(progressLoggerFactory); addTestListener(testCountLogger); TestResultProcessor resultProcessor = new TestListenerAdapter( getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource()); try { testExecuter.execute(this, resultProcessor); } finally { testListenerBroadcaster.removeAll(); testOutputListenerBroadcaster.removeAll(); outputWriter.close(); } new TestResultSerializer(binaryResultsDir).write(results.values()); TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader()); try { JUnitXmlReport junitXml = reports.getJunitXml(); if (junitXml.isEnabled()) { TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase() ? TestOutputAssociation.WITH_TESTCASE : TestOutputAssociation.WITH_SUITE; Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation); binary2JUnitXmlReportGenerator.generate(); } DirectoryReport html = reports.getHtml(); if (!html.isEnabled()) { getLogger().info("Test report disabled, omitting generation of the HTML test report."); } else { testReporter.generateReport(testResultsProvider, html.getDestination()); } } finally { CompositeStoppable.stoppable(testResultsProvider).stop(); } testFramework = null; if (testCountLogger.hadFailures()) { handleTestFailures(); } }
public void startProcessing(TestResultProcessor resultProcessor) { TestResultProcessor resultProcessorChain = new CaptureTestOutputTestResultProcessor(resultProcessor, outputRedirector); testResultProcessor = new TestNGTestResultProcessorAdapter(resultProcessorChain, idGenerator); applicationClassLoader = Thread.currentThread().getContextClassLoader(); }
void execute(Test testTask, TestResultProcessor testResultProcessor);