From ff559b4440fb36b63f3dd7ef0b2cf5517078069e Mon Sep 17 00:00:00 2001 From: ulfjack Date: Tue, 22 May 2018 09:14:10 -0700 Subject: Remove special handling of SpawnActionContext in Executor/ActionExecContext Instead, internally look up the correct context by mnemonic. This simplifies all the callers. We still need a little bit of special casing when constructing the action context map. PiperOrigin-RevId: 197572357 --- .../build/lib/exec/StandaloneTestStrategyTest.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java') diff --git a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java index 0f0a02363d..7c89da42ef 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java @@ -19,6 +19,7 @@ import static com.google.devtools.build.lib.testutil.TestConstants.WORKSPACE_NAM import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.same; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; @@ -135,7 +136,8 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { .build(); when(spawnActionContext.exec(any(), any())).thenReturn(ImmutableList.of(expectedSpawnResult)); - when(actionExecutionContext.getSpawnActionContext(any())).thenReturn(spawnActionContext); + when(actionExecutionContext.getContext(same(SpawnActionContext.class))) + .thenReturn(spawnActionContext); // actual StandaloneTestStrategy execution List spawnResults = @@ -221,7 +223,8 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { .thenThrow(new SpawnExecException("test failed", failSpawnResult, false)) .thenReturn(ImmutableList.of(passSpawnResult)); - when(actionExecutionContext.getSpawnActionContext(any())).thenReturn(spawnActionContext); + when(actionExecutionContext.getContext(same(SpawnActionContext.class))) + .thenReturn(spawnActionContext); // actual StandaloneTestStrategy execution List spawnResults = @@ -306,7 +309,8 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { .build(); when(spawnActionContext.exec(any(), any())).thenReturn(ImmutableList.of(expectedSpawnResult)); - when(actionExecutionContext.getSpawnActionContext(any())).thenReturn(spawnActionContext); + when(actionExecutionContext.getContext(same(SpawnActionContext.class))) + .thenReturn(spawnActionContext); // actual StandaloneTestStrategy execution List spawnResults = @@ -383,7 +387,8 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { .build(); when(spawnActionContext.exec(any(), any())).thenReturn(ImmutableList.of(expectedSpawnResult)); - when(actionExecutionContext.getSpawnActionContext(any())).thenReturn(spawnActionContext); + when(actionExecutionContext.getContext(same(SpawnActionContext.class))) + .thenReturn(spawnActionContext); // actual StandaloneTestStrategy execution List spawnResults = @@ -485,7 +490,8 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { expectedSpawnResult, /*forciblyRunRemotely=*/ false, /*catastrophe=*/ false)); - when(actionExecutionContext.getSpawnActionContext(any())).thenReturn(spawnActionContext); + when(actionExecutionContext.getContext(same(SpawnActionContext.class))) + .thenReturn(spawnActionContext); // actual StandaloneTestStrategy execution List spawnResults = @@ -563,7 +569,8 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { SpawnResult expectedSpawnResult = new SpawnResult.Builder().setStatus(Status.SUCCESS).setRunnerName("test").build(); when(spawnActionContext.exec(any(), any())).thenReturn(ImmutableList.of(expectedSpawnResult)); - when(actionExecutionContext.getSpawnActionContext(any())).thenReturn(spawnActionContext); + when(actionExecutionContext.getContext(same(SpawnActionContext.class))) + .thenReturn(spawnActionContext); // actual StandaloneTestStrategy execution List spawnResults = -- cgit v1.2.3