Skip to content

Commit 11797b6

Browse files
meisterTcopybara-github
authored andcommitted
Remove the number of actions from the build completed message when the new stats summary is enabled.
The new stats summary already shows the number of actions, so it's redundant to include it in the build completed message. This has no effect unless `--experimental_stats_summary` is passed. PiperOrigin-RevId: 671754216 Change-Id: Ib78988670ef226723a80425be50dfd870eb8035f
1 parent 8683da9 commit 11797b6

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,11 @@ private BlazeCommandResult execExclusively(
487487

488488
DebugLoggerConfigurator.setupLogging(commonOptions.verbosity);
489489

490-
EventHandler handler = createEventHandler(outErr, eventHandlerOptions, env);
490+
boolean newStatsSummary =
491+
options.getOptions(ExecutionOptions.class) != null
492+
&& options.getOptions(ExecutionOptions.class).statsSummary;
493+
EventHandler handler =
494+
createEventHandler(outErr, eventHandlerOptions, env, newStatsSummary);
491495
reporter.addHandler(handler);
492496
env.getEventBus().register(handler);
493497

@@ -497,7 +501,7 @@ private BlazeCommandResult execExclusively(
497501
// modified.
498502
if (!eventHandlerOptions.useColor()) {
499503
UiEventHandler ansiAllowingHandler =
500-
createEventHandler(colorfulOutErr, eventHandlerOptions, env);
504+
createEventHandler(colorfulOutErr, eventHandlerOptions, env, newStatsSummary);
501505
reporter.registerAnsiAllowingHandler(handler, ansiAllowingHandler);
502506
env.getEventBus().register(new PassiveExperimentalEventHandler(ansiAllowingHandler));
503507
}
@@ -867,7 +871,7 @@ private OptionsParser createOptionsParser(BlazeCommand command)
867871

868872
/** Returns the event handler to use for this Blaze command. */
869873
private UiEventHandler createEventHandler(
870-
OutErr outErr, UiOptions eventOptions, CommandEnvironment env) {
874+
OutErr outErr, UiOptions eventOptions, CommandEnvironment env, boolean newStatsSummary) {
871875
Path workspacePath = runtime.getWorkspace().getDirectories().getWorkspace();
872876
PathFragment workspacePathFragment = workspacePath == null ? null : workspacePath.asFragment();
873877
return new UiEventHandler(
@@ -876,7 +880,8 @@ private UiEventHandler createEventHandler(
876880
runtime.getClock(),
877881
env.getEventBus(),
878882
workspacePathFragment,
879-
env.withMergedAnalysisAndExecutionSourceOfTruth());
883+
env.withMergedAnalysisAndExecutionSourceOfTruth(),
884+
newStatsSummary);
880885
}
881886

882887
/** Returns the runtime instance shared by the commands that this dispatcher dispatches to. */

src/main/java/com/google/devtools/build/lib/runtime/UiEventHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public UiEventHandler(
166166
Clock clock,
167167
EventBus eventBus,
168168
@Nullable PathFragment workspacePathFragment,
169-
boolean skymeldMode) {
169+
boolean skymeldMode,
170+
boolean newStatsSummary) {
170171
this.terminalWidth = (options.terminalColumns > 0 ? options.terminalColumns : 80);
171172
this.maxStdoutErrBytes = options.maxStdoutErrBytes;
172173
this.outErr =
@@ -202,6 +203,7 @@ public UiEventHandler(
202203
: new UiStateTracker(clock);
203204
}
204205
this.stateTracker.setProgressSampleSize(options.uiActionsShown);
206+
this.stateTracker.setNewStatsSummary(newStatsSummary);
205207
this.numLinesProgressBar = 0;
206208
if (this.cursorControl) {
207209
this.progressRateLimitMillis = Math.round(options.showProgressRateLimit * 1000);

src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class UiStateTracker {
9999

100100
private int sampleSize = 3;
101101

102+
private boolean newStatsSummary = false;
103+
102104
protected String status;
103105
protected String additionalMessage = "";
104106
// Not null after the loading phase has completed.
@@ -412,6 +414,10 @@ void setProgressSampleSize(int sampleSize) {
412414
this.sampleSize = Math.max(1, sampleSize);
413415
}
414416

417+
void setNewStatsSummary(boolean newStatsSummary) {
418+
this.newStatsSummary = newStatsSummary;
419+
}
420+
415421
void mainRepoMappingComputationStarted() {
416422
status = "Computing main repo mapping";
417423
additionalMessage = "";
@@ -478,20 +484,23 @@ Event buildComplete(BuildCompleteEvent event) {
478484
additionalMessage = "";
479485
if (event.getResult().getSuccess()) {
480486
int actionsCompleted = this.actionsCompleted.get();
487+
StringBuilder completedStringBuilder = new StringBuilder().append("Build completed");
481488
if (failedTests == 0) {
482-
return Event.info(
483-
"Build completed successfully, "
484-
+ actionsCompleted
485-
+ pluralize(" total action", actionsCompleted));
489+
completedStringBuilder.append(" successfully");
486490
} else {
487-
return Event.info(
488-
"Build completed, "
489-
+ failedTests
490-
+ pluralize(" test", failedTests)
491-
+ " FAILED, "
492-
+ actionsCompleted
493-
+ pluralize(" total action", actionsCompleted));
491+
completedStringBuilder
492+
.append(", ")
493+
.append(failedTests)
494+
.append(pluralize(" test", failedTests))
495+
.append(" FAILED");
496+
}
497+
if (!newStatsSummary) {
498+
completedStringBuilder
499+
.append(", ")
500+
.append(actionsCompleted)
501+
.append(pluralize(" total action", actionsCompleted));
494502
}
503+
return Event.info(completedStringBuilder.toString());
495504
} else {
496505
ok = false;
497506
return Event.error("Build did NOT complete successfully");

src/test/java/com/google/devtools/build/lib/runtime/UiEventHandlerStdOutAndStdErrTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ private void createUiEventHandler(UiOptions uiOptions) {
9292
new ManualClock(),
9393
new EventBus(),
9494
/* workspacePathFragment= */ null,
95-
/* skymeldMode= */ skymeldMode);
95+
/* skymeldMode= */ skymeldMode,
96+
/* newStatsSummary= */ false);
9697
uiEventHandler.mainRepoMappingComputationStarted(new MainRepoMappingComputationStartingEvent());
9798
uiEventHandler.buildStarted(
9899
BuildStartingEvent.create(

0 commit comments

Comments
 (0)