Skip to content

Cleanup WorkerTest after SecurityManager was removed #1721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions src/java/io/bazel/rulesscala/worker/WorkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.nio.file.Path;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -22,60 +21,6 @@
@RunWith(JUnit4.class)
public class WorkerTest {

@Test
public void testEphemeralWorkerSystemExit() throws Exception {

// An ephemeral worker behaves like a regular main method,
// so we expect the worker to system exit normally

Worker.Interface worker =
new Worker.Interface() {
@Override
public void work(String[] args) {
System.exit(99);
}
};

int code =
assertThrows(Worker.ExitTrapped.class, () -> Worker.workerMain(new String[] {}, worker))
.code;

assert (code == 99);
}

@Test
public void testPersistentWorkerSystemExit() throws Exception {
// We're going to spin up a persistent worker and run a single
// work request. We expect System.exit calls to impact the
// worker request lifecycle without exiting the overall worker
// process.

try (PersistentWorkerHelper helper = new PersistentWorkerHelper(); ) {
WorkerProtocol.WorkRequest.newBuilder().build().writeDelimitedTo(helper.requestOut);

Worker.Interface worker =
new Worker.Interface() {
@Override
public void work(String[] args) {
// we should see this print statement
System.out.println("before exit");
System.exit(100);
// we should not see this print statement
System.out.println("after exit");
}
};

helper.runWorker(worker);

WorkerProtocol.WorkResponse response =
WorkerProtocol.WorkResponse.parseDelimitedFrom(helper.responseIn);

assert (response.getOutput().contains("before"));
assert (response.getExitCode() == 100);
assert (!response.getOutput().contains("after"));
}
}

@Test
public void testPersistentWorkerNoStdin() throws Exception {
try (PersistentWorkerHelper helper = new PersistentWorkerHelper(); ) {
Expand Down