Skip to content

Commit

Permalink
Clear out OOM intentionally thrown in test case.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 388300629
  • Loading branch information
janakdr authored and copybara-github committed Aug 2, 2021
1 parent a03442d commit 262cd8a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertThrows;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
Expand All @@ -27,6 +28,7 @@
import com.google.common.util.concurrent.Uninterruptibles;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.analysis.ServerDirectories;
import com.google.devtools.build.lib.bugreport.BugReport;
import com.google.devtools.build.lib.bugreport.BugReporter;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventKind;
Expand Down Expand Up @@ -86,10 +88,14 @@ public final class BlazeCommandDispatcherTest {

@Before
public void initializeRuntime() throws Exception {

initializeRuntimeInternal();
}

@After
public void cleanUp() {
BugReport.maybePropagateUnprocessedThrowableIfInTest();
}

private void initializeRuntimeInternal(BlazeModule... additionalModules) throws Exception {
String productName = TestConstants.PRODUCT_NAME;
ServerDirectories serverDirectories =
Expand Down Expand Up @@ -271,6 +277,7 @@ public void testExecReportsHardCrashStatus() throws Exception {
assertThat(crash.getCauses(0).getStackTrace(0)).contains("BlazeCommandDispatcherTest.java");
assertThat(directResult.getExitCode()).isEqualTo(ExitCode.OOM_ERROR);
assertThat(directResult.shutdown()).isTrue();
assertThrows(OutOfMemoryError.class, BugReport::maybePropagateUnprocessedThrowableIfInTest);
}

@Test
Expand Down

0 comments on commit 262cd8a

Please sign in to comment.