aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2017-03-21 17:28:39 +0000
committerGravatar Yue Gan <yueg@google.com>2017-03-22 10:53:58 +0000
commita5578af6fdddd643f3be4d1de14d026c73b4f3e2 (patch)
treea6bb56f327913d9a971ebf415b69b8c2b460c299 /src/test/java/com/google/devtools
parent4b448064cca224970c80e962b9ba14042a7b992b (diff)
Make ArtifactFunctionTest#testMiddlemanArtifact more realistic by making the output artifact of a middleman action a middleman artifact.
Step -0.5. -- PiperOrigin-RevId: 150769517 MOS_MIGRATED_REVID=150769517
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java18
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java6
2 files changed, 14 insertions, 10 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
index 7ceec1b936..71bb32abbc 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.skyframe.FileArtifactValue.create;
import static org.junit.Assert.assertArrayEquals;
@@ -54,7 +55,6 @@ import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
@@ -165,19 +165,12 @@ public class ArtifactFunctionTest extends ArtifactFunctionTestCase {
@Test
public void testMiddlemanArtifact() throws Throwable {
- Artifact output = createDerivedArtifact("output");
+ Artifact output = createMiddlemanArtifact("output");
Artifact input1 = createSourceArtifact("input1");
Artifact input2 = createDerivedArtifact("input2");
Action action =
new DummyAction(
ImmutableList.of(input1, input2), output, MiddlemanType.AGGREGATING_MIDDLEMAN);
- // Overwrite default generating action with this one.
- for (Iterator<ActionAnalysisMetadata> it = actions.iterator(); it.hasNext(); ) {
- if (it.next().getOutputs().contains(output)) {
- it.remove();
- break;
- }
- }
actions.add(action);
file(input2.getPath(), "contents");
file(input1.getPath(), "source contents");
@@ -407,6 +400,13 @@ public class ArtifactFunctionTest extends ArtifactFunctionTestCase {
return output;
}
+ private Artifact createMiddlemanArtifact(String path) {
+ Root middlemanRoot = Root.middlemanRoot(middlemanPath, middlemanPath.getRelative("out"));
+ Path fullPath = middlemanRoot.getPath().getRelative(path);
+ return new Artifact(
+ fullPath, middlemanRoot, fullPath.relativeTo(middlemanRoot.getExecRoot()), ALL_OWNER);
+ }
+
private Artifact createDerivedTreeArtifactWithAction(String path) {
Artifact treeArtifact = createDerivedTreeArtifactOnly(path);
actions.add(new DummyAction(ImmutableList.<Artifact>of(), treeArtifact));
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
index bea29c1d9f..a5989761a8 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
@@ -60,6 +60,7 @@ abstract class ArtifactFunctionTestCase {
protected SequentialBuildDriver driver;
protected MemoizingEvaluator evaluator;
protected Path root;
+ protected Path middlemanPath;
/**
* The test action execution function. The Skyframe evaluator's action execution function
@@ -119,9 +120,12 @@ abstract class ArtifactFunctionTestCase {
}
protected void setupRoot(CustomInMemoryFs fs) throws IOException {
- root = fs.getPath(TestUtils.tmpDir());
+ Path tmpDir = fs.getPath(TestUtils.tmpDir());
+ root = tmpDir.getChild("root");
FileSystemUtils.createDirectoryAndParents(root);
FileSystemUtils.createEmptyFile(root.getRelative("WORKSPACE"));
+ middlemanPath = tmpDir.getChild("middlemanRoot");
+ FileSystemUtils.createDirectoryAndParents(middlemanPath);
}
protected static void writeFile(Path path, String contents) throws IOException {