Skip to content

Commit

Permalink
Apply comment
Browse files Browse the repository at this point in the history
  • Loading branch information
YongGoose committed Jan 15, 2025
1 parent 6e679dc commit 4da4954
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.TestEngine;
import org.junit.platform.engine.UniqueId;
import org.junit.vintage.engine.descriptor.RunnerScheduler;
import org.junit.runners.model.RunnerScheduler;
import org.junit.vintage.engine.descriptor.RunnerTestDescriptor;
import org.junit.vintage.engine.descriptor.VintageEngineDescriptor;
import org.junit.vintage.engine.discovery.VintageDiscoverer;
Expand Down Expand Up @@ -124,14 +124,14 @@ private boolean executeInParallel(VintageEngineDescriptor engineDescriptor,
List<RunnerTestDescriptor> runnerTestDescriptors = collectRunnerTestDescriptors(engineDescriptor,
executorService);

List<CompletableFuture<Void>> futures = new ArrayList<>();
if (!classes) {
for (RunnerTestDescriptor runnerTestDescriptor : runnerTestDescriptors) {
runnerExecutor.execute(runnerTestDescriptor);
}
return false;
}

List<CompletableFuture<Void>> futures = new ArrayList<>();
for (RunnerTestDescriptor runnerTestDescriptor : runnerTestDescriptors) {
CompletableFuture<Void> future = CompletableFuture.runAsync(
() -> runnerExecutor.execute(runnerTestDescriptor), executorService);
Expand Down Expand Up @@ -166,13 +166,7 @@ public void schedule(Runnable childStatement) {

@Override
public void finished() {
try {
executorService.shutdown();
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
}
catch (InterruptedException e) {
logger.warn(e, () -> "Interruption while waiting for parallel test execution to finish");
}
// do nothing
}
});

Expand All @@ -184,9 +178,11 @@ private List<RunnerTestDescriptor> collectRunnerTestDescriptors(VintageEngineDes
List<RunnerTestDescriptor> runnerTestDescriptors = new ArrayList<>();
for (TestDescriptor descriptor : engineDescriptor.getModifiableChildren()) {
RunnerTestDescriptor runnerTestDescriptor = (RunnerTestDescriptor) descriptor;

if (methods) {
runnerTestDescriptors.add(parallelMethodExecutor(runnerTestDescriptor, executorService));
}
runnerTestDescriptors.add(runnerTestDescriptor);
}
return runnerTestDescriptors;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.Filterable;
import org.junit.runner.manipulation.NoTestsRemainException;
import org.junit.runners.ParentRunner;
import org.junit.runners.model.RunnerScheduler;

/**
* @since 4.12
Expand All @@ -47,16 +49,6 @@ public class RunnerTestDescriptor extends VintageTestDescriptor {
private boolean wasFiltered;
private List<Filter> filters = new ArrayList<>();

private volatile RunnerScheduler scheduler = new RunnerScheduler() {
public void schedule(Runnable childStatement) {
childStatement.run();
}

public void finished() {
// do nothing
}
};

public RunnerTestDescriptor(UniqueId uniqueId, Class<?> testClass, Runner runner, boolean ignored) {
super(uniqueId, runner.getDescription(), testClass.getSimpleName(), ClassSource.from(testClass));
this.runner = runner;
Expand Down Expand Up @@ -171,8 +163,8 @@ public boolean isIgnored() {
return ignored;
}

public void setScheduler(org.junit.runners.model.RunnerScheduler scheduler) {
Runner runner = getRunnerToReport();
public void setScheduler(RunnerScheduler scheduler) {
Runner runner = getRunnerToReport();
if (runner instanceof ParentRunner) {
((ParentRunner<?>) runner).setScheduler(scheduler);
}
Expand Down

0 comments on commit 4da4954

Please sign in to comment.