Make SourceManifestAction support `Action.content`
This makes it easier to check the manifest that it writes. Otherwise, custom
Java helpers are needed for what are otherwise simple Starlark tests.
RELNOTES: SourceManifestAction supports `Action.content`
@@ -178,7 +178,8 @@ public final class SourceManifestAction extends AbstractFileWriteAction {
}
@VisibleForTesting
- public void writeOutputFile(OutputStream out, EventHandler eventHandler) throws IOException {
+ public void writeOutputFile(OutputStream out, @Nullable EventHandler eventHandler)
+ throws IOException {
writeFile(out, runfiles.getRunfilesInputs(eventHandler, getOwner().getLocation()));
}
@@ -187,12 +188,17 @@ public final class SourceManifestAction extends AbstractFileWriteAction {
*
* @return returns the file contents as a string.
*/
- public String getFileContentsAsString(EventHandler eventHandler) throws IOException {
+ public String getFileContentsAsString(@Nullable EventHandler eventHandler) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
writeOutputFile(stream, eventHandler);
return stream.toString(UTF_8);
}
+ @Override
+ public String getStarlarkContent() throws IOException {
+ return getFileContentsAsString(null);
+ }
+
@Override
public DeterministicWriter newDeterministicWriter(ActionExecutionContext ctx) {
final Map<PathFragment, Artifact> runfilesInputs =
