Let artifacts declare that they use content-based paths.
This is basic infrastructure for supporting --experiment_output_paths=content. This change does not implement any actual uses.
The intention is that we can incrementally opt in content-mapping support, i.e. rules can declare which of their outputs should do content mapping. The first test goal will be to opt in java_library compilation.
"Experimental Content-Based Output Paths" design: https://docs.google.com/document/d/17snvmic26-QdGuwVw55Gl0oOufw9sCVuOAvHqGZJFr4/edit
See https://github.com/bazelbuild/bazel/issues/8339
PiperOrigin-RevId: 252148134
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 4dd23eb..6e05f61 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
@@ -491,4 +491,18 @@
ArtifactRoot.asSourceRoot(Root.fromPath(scratch.dir("/"))),
scratch.file("/aaa/bbb/ccc/ddd"));
}
+
+ @Test
+ public void canDeclareContentBasedOutput() throws Exception {
+ Path execRoot = scratch.getFileSystem().getPath("/");
+ ArtifactRoot root = ArtifactRoot.asDerivedRoot(execRoot, scratch.dir("/newRoot"));
+ assertThat(
+ new Artifact.DerivedArtifact(
+ root,
+ PathFragment.create("newRoot/my.output"),
+ ActionsTestUtil.NULL_ARTIFACT_OWNER,
+ /*contentBasedPath=*/ true)
+ .contentBasedPath())
+ .isTrue();
+ }
}