aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar shahan <shahan@google.com>2018-04-05 08:03:04 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-05 08:05:03 -0700
commite483df35c30cfb7b77fe46b9c2dee8114d4b5748 (patch)
treeee014ac7b592c28f3ae61a2672c23bd1d9843c62
parent0c148f361388369249b13cf5618a27873ac46bfb (diff)
Avoids calling getPath() in Artifact.toDetailString().
Also deletes obsolete Artifact.serializeToString() method. "Semantic" change: replaces the actual exec root with <execution_root> in the toString() representation. PiperOrigin-RevId: 191742669
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/Artifact.java25
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java37
2 files changed, 7 insertions, 55 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index f0eca50638..bb8cd9875c 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -676,30 +676,13 @@ public class Artifact
return "[" + root + "]" + rootRelativePath;
} else {
// Derived Artifact: path and root are under execRoot
- PathFragment execRoot = trimTail(getPath().asFragment(), execPath);
- return "[["
- + execRoot
- + "]"
- + root.getRoot().asPath().asFragment().relativeTo(execRoot)
- + "]"
- + rootRelativePath;
+ //
+ // TODO(blaze-team): this is misleading beacuse execution_root isn't unique. Dig the
+ // workspace name out and print that also.
+ return "[[<execution_root>]" + root.getExecPath() + "]" + rootRelativePath;
}
}
- /**
- * Serializes this artifact to a string that has enough data to reconstruct the artifact.
- */
- public final String serializeToString() {
- // In theory, it should be enough to serialize execPath and rootRelativePath (which is a suffix
- // of execPath). However, in practice there is code around that uses other attributes which
- // needs cleaning up.
- String result = execPath + " /" + rootRelativePath.toString().length();
- if (getOwner() != null) {
- result += " " + getOwner();
- }
- return result;
- }
-
// ---------------------------------------------------------------------------
// Static methods to assist in working with Artifacts
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
index e7ead54483..ccec35005a 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
@@ -285,12 +285,12 @@ public class ArtifactTest {
@Test
public void testToDetailString() throws Exception {
- Path execRoot = scratch.getFileSystem().getPath("/a");
+ Path execRoot = scratch.getFileSystem().getPath("/execroot/workspace");
Artifact a =
new Artifact(
- ArtifactRoot.asDerivedRoot(execRoot, scratch.dir("/a/b")),
+ ArtifactRoot.asDerivedRoot(execRoot, scratch.dir("/execroot/workspace/b")),
PathFragment.create("b/c"));
- assertThat(a.toDetailString()).isEqualTo("[[/a]b]c");
+ assertThat(a.toDetailString()).isEqualTo("[[<execution_root>]b]c");
}
@Test
@@ -304,37 +304,6 @@ public class ArtifactTest {
}
@Test
- public void testSerializeToString() throws Exception {
- Path execRoot = scratch.getFileSystem().getPath("/");
- assertThat(
- new Artifact(
- scratch.file("/a/b/c"), ArtifactRoot.asDerivedRoot(execRoot, scratch.dir("/a")))
- .serializeToString())
- .isEqualTo("a/b/c /3");
- }
-
- @Test
- public void testSerializeToStringWithExecPath() throws Exception {
- Path execRoot = scratch.getFileSystem().getPath("/aaa");
- ArtifactRoot root = ArtifactRoot.asDerivedRoot(execRoot, scratch.dir("/aaa/bbb"));
- PathFragment execPath = PathFragment.create("bbb/ccc");
-
- assertThat(new Artifact(root, execPath).serializeToString()).isEqualTo("bbb/ccc /3");
- }
-
- @Test
- public void testSerializeToStringWithOwner() throws Exception {
- Path execRoot = scratch.getFileSystem().getPath("/aa");
- assertThat(
- new Artifact(
- ArtifactRoot.asDerivedRoot(execRoot, scratch.dir("/aa/b")),
- PathFragment.create("b/c"),
- new LabelArtifactOwner(Label.parseAbsoluteUnchecked("//foo:bar")))
- .serializeToString())
- .isEqualTo("b/c /1 //foo:bar");
- }
-
- @Test
public void testCodec() throws Exception {
new SerializationTester(
new Artifact(PathFragment.create("src/a"), rootDir),