From 0b4dc95019787c48901b0a125605c9baffafd004 Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Thu, 27 Apr 2023 06:32:22 -0700 Subject: [PATCH] RemoteExecutionService: Action.Command to set output_paths This is a follow-up to https://github.com/bazelbuild/bazel/pull/18198/ Make Bazel compatible with newer version of Remote Api by setting output_paths along-side output_directories and output_files. The latter 2 are deprecated in newer REAPI specification. Closes #18202. PiperOrigin-RevId: 527560509 Change-Id: I14c80d69aa9a5e9bf29a8c5694412ecd58ea17bf --- .../devtools/build/lib/remote/RemoteExecutionService.java | 4 ++++ .../devtools/build/lib/remote/RemoteExecutionServiceTest.java | 2 ++ .../remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java | 1 + 3 files changed, 7 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java index 68e3277d774013..365977e9664fa4 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java @@ -222,6 +222,7 @@ static Command buildCommand( Command.Builder command = Command.newBuilder(); ArrayList outputFiles = new ArrayList<>(); ArrayList outputDirectories = new ArrayList<>(); + ArrayList outputPaths = new ArrayList<>(); for (ActionInput output : outputs) { String pathString = decodeBytestringUtf8(remotePathResolver.localPathToOutputPath(output)); if (output.isDirectory()) { @@ -229,11 +230,14 @@ static Command buildCommand( } else { outputFiles.add(pathString); } + outputPaths.add(pathString); } Collections.sort(outputFiles); Collections.sort(outputDirectories); + Collections.sort(outputPaths); command.addAllOutputFiles(outputFiles); command.addAllOutputDirectories(outputDirectories); + command.addAllOutputPaths(outputPaths); if (platform != null) { command.setPlatform(platform); diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java index 2ee40dc591f572..d5f310985e7a97 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java @@ -191,6 +191,7 @@ public void buildRemoteAction_withRegularFileAsOutput() throws Exception { RemoteAction remoteAction = service.buildRemoteAction(spawn, context); assertThat(remoteAction.getCommand().getOutputFilesList()).containsExactly(execPath.toString()); + assertThat(remoteAction.getCommand().getOutputPathsList()).containsExactly(execPath.toString()); assertThat(remoteAction.getCommand().getOutputDirectoriesList()).isEmpty(); } @@ -226,6 +227,7 @@ public void buildRemoteAction_withUnresolvedSymlinkAsOutput() throws Exception { assertThat(remoteAction.getCommand().getOutputFilesList()).containsExactly("path/to/link"); assertThat(remoteAction.getCommand().getOutputDirectoriesList()).isEmpty(); + assertThat(remoteAction.getCommand().getOutputPathsList()).containsExactly("path/to/link"); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java index 7088859f7653da..11a14cba5a7ff2 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerWithGrpcRemoteExecutorTest.java @@ -342,6 +342,7 @@ public int maxConcurrency() { .setValue("value") .build()) .addAllOutputFiles(ImmutableList.of("bar", "foo")) + .addAllOutputPaths(ImmutableList.of("bar", "foo")) .build(); cmdDigest = DIGEST_UTIL.compute(command); channel.release();