aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar shahan <shahan@google.com>2018-03-15 14:18:46 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-15 14:20:29 -0700
commit18726b7e62ab40fa7d1531af7f72fca17abcdb0a (patch)
tree5da2d9407b172bfefc58202ca6901bc54040490b /src/test/java
parent31032f5a089ded7ebeeb2786eb91864ac58e3306 (diff)
Begins cleanup to allow ActionFS to be injected into all action executions.
PiperOrigin-RevId: 189244665
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java12
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java10
2 files changed, 21 insertions, 1 deletions
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());
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
index f24f200509..75d05ce460 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
@@ -18,9 +18,11 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.NULL_ACTION_OWNER;
import com.google.common.collect.ImmutableMap;
+import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionKeyContext;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ArtifactRoot;
+import com.google.devtools.build.lib.actions.util.DummyExecutor;
import com.google.devtools.build.lib.testutil.FoundationTestCase;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.vfs.Path;
@@ -103,13 +105,19 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
Artifact b = new Artifact(PathFragment.create("b"), root);
CreateIncSymlinkAction action = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(a, b), outputDir);
- action.execute(null);
+ action.execute(makeDummyContext());
symlink.stat(Symlinks.NOFOLLOW);
assertThat(symlink.isSymbolicLink()).isTrue();
assertThat(b.getPath().asFragment()).isEqualTo(symlink.readSymbolicLink());
assertThat(rootDirectory.getRelative("a").exists()).isFalse();
}
+ private ActionExecutionContext makeDummyContext() {
+ DummyExecutor executor = new DummyExecutor(fileSystem, rootDirectory);
+ return new ActionExecutionContext(
+ executor, null, null, null, null, null, ImmutableMap.of(), null);
+ }
+
@Test
public void testFileRemoved() throws Exception {
Path outputDir = rootDirectory.getRelative("out");