aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2016-01-15 13:21:05 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-01-15 14:45:30 +0000
commit25217c0dc90f5f9ade9950d178db30b4ce41cbdd (patch)
tree8579f2fdc1fcf17c7a3ed5168b1e7f2e3f2dafc1 /src/main/java/com/google
parent12c68aa5bfebd827bba8dc094546e4f516438096 (diff)
Refactor action output dumping to go through a single method.
This is in preparation for moving the output dumping to the Reporter for two reasons: - we're currently relying on there being a Reporter which locks on itself; i.e., this code is tightly coupled with the Reporter code - the current Blaze output is confusing; we first print an info event, then the actual output, and then an error event - putting the Reporter in control allows us to fix that -- MOS_MIGRATED_REVID=112240684
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
index c4f2938d10..cf8556d2b6 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
@@ -953,13 +953,11 @@ public final class SkyframeActionExecutor implements ActionExecutionContextFacto
*/
private void printError(String message, Action action, FileOutErr actionOutput) {
synchronized (reporter) {
- if (actionOutput != null && actionOutput.hasRecordedOutput()) {
- dumpRecordedOutErr(action, actionOutput);
- }
if (keepGoing) {
message = "Couldn't " + describeAction(action) + ": " + message;
}
- reporter.handle(Event.error(action.getOwner().getLocation(), message));
+ Event event = Event.error(action.getOwner().getLocation(), message);
+ dumpRecordedOutErr(event, actionOutput);
recordExecutionError();
}
}
@@ -986,7 +984,17 @@ public final class SkyframeActionExecutor implements ActionExecutionContextFacto
message.append("From ");
message.append(action.describe());
message.append(":");
+ Event event = Event.info(message.toString());
+ dumpRecordedOutErr(event, outErrBuffer);
+ }
+ /**
+ * Dump the output from the action.
+ *
+ * @param prefixEvent An event to post before dumping the output
+ * @param outErrBuffer The OutErr that recorded the actions output
+ */
+ private void dumpRecordedOutErr(Event prefixEvent, FileOutErr outErrBuffer) {
// Synchronize this on the reporter, so that the output from multiple
// actions will not be interleaved.
synchronized (reporter) {
@@ -994,11 +1002,13 @@ public final class SkyframeActionExecutor implements ActionExecutionContextFacto
if (isBuilderAborting()) {
return;
}
- reporter.handle(Event.info(message.toString()));
+ reporter.handle(prefixEvent);
- OutErr outErr = this.reporter.getOutErr();
- outErrBuffer.dumpOutAsLatin1(outErr.getOutputStream());
- outErrBuffer.dumpErrAsLatin1(outErr.getErrorStream());
+ if (outErrBuffer != null && outErrBuffer.hasRecordedOutput()) {
+ OutErr outErr = this.reporter.getOutErr();
+ outErrBuffer.dumpOutAsLatin1(outErr.getOutputStream());
+ outErrBuffer.dumpErrAsLatin1(outErr.getErrorStream());
+ }
}
}