From 7a90b9a409bea4a69e0c80d418c6193d64c8eb3f Mon Sep 17 00:00:00 2001 From: ulfjack Date: Tue, 18 Apr 2017 16:03:40 +0200 Subject: Write stdout and stderr to the remote cache Only write a cache entry when the spawn executed successfully, and with a 0 exit code. In the test, we only check that uploadFileContents is called exactly twice. Progress on #1413. PiperOrigin-RevId: 153458240 --- .../devtools/build/lib/remote/CachedLocalSpawnRunner.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/remote/CachedLocalSpawnRunner.java') diff --git a/src/main/java/com/google/devtools/build/lib/remote/CachedLocalSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/CachedLocalSpawnRunner.java index 3a10aa490d..fb7241eb7b 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/CachedLocalSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/remote/CachedLocalSpawnRunner.java @@ -126,8 +126,10 @@ final class CachedLocalSpawnRunner implements SpawnRunner { } } SpawnResult spawnResult = delegate.exec(spawn, policy); - if (options.remoteLocalExecUploadResults && spawnResult.setupSuccess()) { - writeCacheEntry(spawn, actionKey); + if (options.remoteLocalExecUploadResults + && spawnResult.status() == Status.SUCCESS + && spawnResult.exitCode() == 0) { + writeCacheEntry(spawn, policy.getFileOutErr(), actionKey); } return spawnResult; } catch (StatusRuntimeException e) { @@ -172,7 +174,7 @@ final class CachedLocalSpawnRunner implements SpawnRunner { outErr.printErr(new String(streams.get(1), UTF_8)); } - private void writeCacheEntry(Spawn spawn, ActionKey actionKey) + private void writeCacheEntry(Spawn spawn, FileOutErr outErr, ActionKey actionKey) throws IOException, InterruptedException { ArrayList outputFiles = new ArrayList<>(); for (ActionInput output : spawn.getOutputFiles()) { @@ -185,6 +187,10 @@ final class CachedLocalSpawnRunner implements SpawnRunner { } ActionResult.Builder result = ActionResult.newBuilder(); actionCache.uploadAllResults(execRoot, outputFiles, result); + ContentDigest stderr = actionCache.uploadFileContents(outErr.getErrorPath()); + ContentDigest stdout = actionCache.uploadFileContents(outErr.getOutputPath()); + result.setStderrDigest(stderr); + result.setStdoutDigest(stdout); actionCache.setCachedActionResult(actionKey, result.build()); } } -- cgit v1.2.3