Search in sources :

Example 1 with ActorFactory

use of org.gradle.internal.actor.ActorFactory in project gradle by gradle.

the class DefaultTestExecuter method execute.

@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(getMaxParallelForks(testTask), 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().getParentId();
    new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider(), testTaskOperationId, testTask.getPath(), "Gradle Test Run " + testTask.getIdentityPath()).run();
}
Also used : WorkerTestClassProcessorFactory(org.gradle.api.internal.tasks.testing.WorkerTestClassProcessorFactory) BuildOperationWorkerRegistry(org.gradle.internal.operations.BuildOperationWorkerRegistry) WorkerProcessFactory(org.gradle.process.internal.worker.WorkerProcessFactory) Factory(org.gradle.internal.Factory) WorkerTestClassProcessorFactory(org.gradle.api.internal.tasks.testing.WorkerTestClassProcessorFactory) ActorFactory(org.gradle.internal.actor.ActorFactory) TestMainAction(org.gradle.api.internal.tasks.testing.processors.TestMainAction) TestClassProcessor(org.gradle.api.internal.tasks.testing.TestClassProcessor) RestartEveryNTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor) ForkingTestClassProcessor(org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor) MaxNParallelTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.MaxNParallelTestClassProcessor) RestartEveryNTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor) TestFramework(org.gradle.api.internal.tasks.testing.TestFramework) MaxNParallelTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.MaxNParallelTestClassProcessor) TrueTimeProvider(org.gradle.internal.time.TrueTimeProvider) ForkingTestClassProcessor(org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor) FileTree(org.gradle.api.file.FileTree) File(java.io.File)

Example 2 with ActorFactory

use of org.gradle.internal.actor.ActorFactory in project gradle by gradle.

the class DefaultTestExecuter method execute.

@Override
public void execute(final JvmTestExecutionSpec testExecutionSpec, TestResultProcessor testResultProcessor) {
    final TestFramework testFramework = testExecutionSpec.getTestFramework();
    final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
    final Set<File> classpath = ImmutableSet.copyOf(testExecutionSpec.getClasspath());
    final Set<File> modulePath = ImmutableSet.copyOf(testExecutionSpec.getModulePath());
    final List<String> testWorkerImplementationModules = testFramework.getTestWorkerImplementationModules();
    final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {

        @Override
        public TestClassProcessor create() {
            return new ForkingTestClassProcessor(workerLeaseService, workerFactory, testInstanceFactory, testExecutionSpec.getJavaForkOptions(), classpath, modulePath, testWorkerImplementationModules, testFramework.getWorkerConfigurationAction(), moduleRegistry, documentationRegistry);
        }
    };
    final Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {

        @Override
        public TestClassProcessor create() {
            return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testExecutionSpec.getForkEvery());
        }
    };
    processor = new PatternMatchTestClassProcessor(testFilter, new RunPreviousFailedFirstTestClassProcessor(testExecutionSpec.getPreviousFailedTestClasses(), new MaxNParallelTestClassProcessor(getMaxParallelForks(testExecutionSpec), reforkingProcessorFactory, actorFactory)));
    final FileTree testClassFiles = testExecutionSpec.getCandidateClassFiles();
    Runnable detector;
    if (testExecutionSpec.isScanForTestClasses() && testFramework.getDetector() != null) {
        TestFrameworkDetector testFrameworkDetector = testFramework.getDetector();
        testFrameworkDetector.setTestClasses(testExecutionSpec.getTestClassesDirs().getFiles());
        testFrameworkDetector.setTestClasspath(classpath);
        detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
    } else {
        detector = new DefaultTestClassScanner(testClassFiles, null, processor);
    }
    new TestMainAction(detector, processor, testResultProcessor, workerLeaseService, clock, testExecutionSpec.getPath(), "Gradle Test Run " + testExecutionSpec.getIdentityPath()).run();
}
Also used : WorkerTestClassProcessorFactory(org.gradle.api.internal.tasks.testing.WorkerTestClassProcessorFactory) RunPreviousFailedFirstTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.RunPreviousFailedFirstTestClassProcessor) ActorFactory(org.gradle.internal.actor.ActorFactory) WorkerProcessFactory(org.gradle.process.internal.worker.WorkerProcessFactory) Factory(org.gradle.internal.Factory) WorkerTestClassProcessorFactory(org.gradle.api.internal.tasks.testing.WorkerTestClassProcessorFactory) TestMainAction(org.gradle.api.internal.tasks.testing.processors.TestMainAction) ForkingTestClassProcessor(org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor) MaxNParallelTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.MaxNParallelTestClassProcessor) TestClassProcessor(org.gradle.api.internal.tasks.testing.TestClassProcessor) RunPreviousFailedFirstTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.RunPreviousFailedFirstTestClassProcessor) RestartEveryNTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor) PatternMatchTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.PatternMatchTestClassProcessor) RestartEveryNTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor) PatternMatchTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.PatternMatchTestClassProcessor) TestFramework(org.gradle.api.internal.tasks.testing.TestFramework) MaxNParallelTestClassProcessor(org.gradle.api.internal.tasks.testing.processors.MaxNParallelTestClassProcessor) ForkingTestClassProcessor(org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor) FileTree(org.gradle.api.file.FileTree) File(java.io.File)

Aggregations

File (java.io.File)2 FileTree (org.gradle.api.file.FileTree)2 TestClassProcessor (org.gradle.api.internal.tasks.testing.TestClassProcessor)2 TestFramework (org.gradle.api.internal.tasks.testing.TestFramework)2 WorkerTestClassProcessorFactory (org.gradle.api.internal.tasks.testing.WorkerTestClassProcessorFactory)2 MaxNParallelTestClassProcessor (org.gradle.api.internal.tasks.testing.processors.MaxNParallelTestClassProcessor)2 RestartEveryNTestClassProcessor (org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor)2 TestMainAction (org.gradle.api.internal.tasks.testing.processors.TestMainAction)2 ForkingTestClassProcessor (org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor)2 Factory (org.gradle.internal.Factory)2 ActorFactory (org.gradle.internal.actor.ActorFactory)2 WorkerProcessFactory (org.gradle.process.internal.worker.WorkerProcessFactory)2 PatternMatchTestClassProcessor (org.gradle.api.internal.tasks.testing.processors.PatternMatchTestClassProcessor)1 RunPreviousFailedFirstTestClassProcessor (org.gradle.api.internal.tasks.testing.processors.RunPreviousFailedFirstTestClassProcessor)1 BuildOperationWorkerRegistry (org.gradle.internal.operations.BuildOperationWorkerRegistry)1 TrueTimeProvider (org.gradle.internal.time.TrueTimeProvider)1