Skip to content

Commit

Permalink
Rewrite tests that depend on System.exit being intercepted.
Browse files Browse the repository at this point in the history
If a test calls production code which ends up calling `System.exit`, that call will currently be intercepted by the `SecurityManager` that is installed when running tests. But `SecurityManager` [will be removed][]

PiperOrigin-RevId: 699181391
Change-Id: If50786d49911d306d016ac2beafe2c5c1612fd70
  • Loading branch information
eamonnmcmanus authored and copybara-github committed Nov 22, 2024
1 parent 44cdf01 commit 825e0d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/test/java/com/google/devtools/build/lib/worker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ java_test(
java_test(
name = "WorkRequestHandlerTest",
srcs = ["WorkRequestHandlerTest.java"],
jvm_flags = [
# TODO: b/222158599 - GoogleTestSecurityManager is being turned down
"-Dcom.google.testing.junit.runner.shouldInstallTestSecurityManager=true",
],
deps = [
"//src/main/java/com/google/devtools/build/lib/worker:work_request_handlers",
"//src/main/protobuf:worker_protocol_java_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -120,14 +121,14 @@ public void testMultiplexWorkRequest_stopsThreadsOnShutdown()
new WorkRequestHandler(
(args, err) -> {
// Each call to this runs in its own thread.
synchronized (workerThreads) {
workerThreads.add(Thread.currentThread());
}
started.release();
try {
synchronized (workerThreads) {
workerThreads.add(Thread.currentThread());
}
started.release();
eternity.acquire(); // This blocks forever.
eternity.acquire(); // This blocks until the thread is interrupted at shutdown.
} catch (InterruptedException e) {
throw new AssertionError("Unhandled exception", e);
Thread.currentThread().interrupt();
}
return 0;
},
Expand Down Expand Up @@ -165,6 +166,7 @@ public void testMultiplexWorkRequest_stopsThreadsOnShutdown()
}

@Test
@Ignore("b/380340632 - test currently relies on GoogleTestSecurityManager")
public void testMultiplexWorkRequest_stopsWorkerOnException()
throws IOException, InterruptedException {
PipedOutputStream src = new PipedOutputStream();
Expand Down

0 comments on commit 825e0d3

Please sign in to comment.