From 18726b7e62ab40fa7d1531af7f72fca17abcdb0a Mon Sep 17 00:00:00 2001 From: shahan Date: Thu, 15 Mar 2018 14:18:46 -0700 Subject: Begins cleanup to allow ActionFS to be injected into all action executions. PiperOrigin-RevId: 189244665 --- .../devtools/build/lib/exec/StandaloneTestStrategyTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/test/java/com/google/devtools/build/lib/exec') 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 856f000ccd..57ad24332d 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 @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.exec; import static com.google.common.truth.Truth.assertThat; +import static com.google.devtools.build.lib.testutil.TestConstants.WORKSPACE_NAME; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; @@ -24,6 +25,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.ActionExecutionContext; +import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.SpawnActionContext; import com.google.devtools.build.lib.actions.SpawnResult; @@ -117,6 +119,7 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { when(actionExecutionContext.getClientEnv()).thenReturn(ImmutableMap.of()); when(actionExecutionContext.getEventHandler()).thenReturn(reporter); when(actionExecutionContext.getEventBus()).thenReturn(eventBus); + when(actionExecutionContext.getInputPath(any())).thenAnswer(this::getInputPathMock); SpawnResult expectedSpawnResult = new SpawnResult.Builder() @@ -189,6 +192,8 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { when(actionExecutionContext.getClientEnv()).thenReturn(ImmutableMap.of()); when(actionExecutionContext.getEventHandler()).thenReturn(reporter); when(actionExecutionContext.getEventBus()).thenReturn(eventBus); + when(actionExecutionContext.getInputPath(any())).thenAnswer(this::getInputPathMock); + Path outPath = tmpDirRoot.getRelative("test-out.txt"); Path errPath = tmpDirRoot.getRelative("test-err.txt"); FileOutErr outErr = new FileOutErr(outPath, errPath); @@ -272,6 +277,7 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { when(actionExecutionContext.getClientEnv()).thenReturn(ImmutableMap.of()); when(actionExecutionContext.getEventHandler()).thenReturn(reporter); when(actionExecutionContext.getEventBus()).thenReturn(eventBus); + when(actionExecutionContext.getInputPath(any())).thenAnswer(this::getInputPathMock); Path outPath = tmpDirRoot.getRelative("test-out.txt"); Path errPath = tmpDirRoot.getRelative("test-err.txt"); FileOutErr outErr = new FileOutErr(outPath, errPath); @@ -307,4 +313,10 @@ public final class StandaloneTestStrategyTest extends BuildViewTestCase { } assertThat(errPath.exists()).isFalse(); } + + private Path getInputPathMock(InvocationOnMock invocation) { + return outputBase + .getRelative("execroot/" + WORKSPACE_NAME) + .getRelative(invocation.getArgumentAt(0, ActionInput.class).getExecPath()); + } } -- cgit v1.2.3