Skip to content

Commit

Permalink
Fix BazelTestRunner compatibility with jre8
Browse files Browse the repository at this point in the history
Removes usages of Set.of() that were introduced in javase9

Fixes #18300

Closes #18307.

PiperOrigin-RevId: 529369593
Change-Id: Id45afbb1bdee46910f4a9b632f479773c561c0a3
  • Loading branch information
hvadehra authored and copybara-github committed May 4, 2023
1 parent 8d1db5b commit 275c8bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.testing.junit.runner.sharding.ShardingFilters;
import com.google.testing.junit.runner.util.MemoizingSupplier;
import java.io.PrintStream;
import java.util.Collections;
import java.util.Set;
import java.util.function.Supplier;
import org.junit.runner.Request;
Expand Down Expand Up @@ -83,7 +84,7 @@ public JUnit4Runner runner() {
stdoutStream,
config,
setOfRunListeners,
Set.of());
Collections.emptySet());
}

/** A builder for instantiating {@link JUnit4Bazel}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -127,17 +129,20 @@ Set<RunListener> setOfRunListeners(
JUnit4Config config,
Supplier<TestSuiteModel> testSuiteModelSupplier,
CancellableRequestFactory cancellableRequestFactory) {
return Set.of(
Set<RunListener> listeners = new HashSet<>();
listeners.add(
new JUnit4TestStackTraceListener(
new SignalHandlers(SignalHandlers.createRealHandlerInstaller()), System.err),
new SignalHandlers(SignalHandlers.createRealHandlerInstaller()), System.err));
listeners.add(
new JUnit4TestXmlListener(
testSuiteModelSupplier,
cancellableRequestFactory,
new SignalHandlers(SignalHandlers.createRealHandlerInstaller()),
new ProvideXmlStreamFactory(() -> config).get(),
System.err),
new JUnit4TestNameListener(provideCurrentRunningTest()),
JUnit4RunnerBaseModule.provideTextListener(stdout()));
System.err));
listeners.add(new JUnit4TestNameListener(provideCurrentRunningTest()));
listeners.add(JUnit4RunnerBaseModule.provideTextListener(stdout()));
return Collections.unmodifiableSet(listeners);
}

CancellableRequestFactory cancellableRequestFactory() {
Expand Down

0 comments on commit 275c8bd

Please sign in to comment.