gnodet-bot commented on code in PR #14071:
URL: https://github.com/apache/maven/pull/14071#discussion_r4621013221


##########
impl/maven-cli/src/test/java/org/apache/maven/cling/event/ExecutionEventLoggerTest.java:
##########
@@ -631,6 +616,75 @@ void testProjectSkippedBecauseADependencyFailed() {
                 .info("{} was not built because a module it depends on failed 
to build.", "Maven Project artifact2");
     }
 
+    @Test
+    void testFinalResultLineLayout() {
+        MavenExecutionRequest executionRequest = new 
DefaultMavenExecutionRequest();
+        executionRequest.setDegreeOfConcurrency(4);
+        ExecutionEvent event = sessionEndedEvent(new 
DefaultMavenExecutionResult(), executionRequest);
+
+        ExecutionEventLogger loggerWithWidth = new 
ExecutionEventLogger(messageBuilderFactory, logger, 130);
+        loggerWithWidth.sessionEnded(event);
+
+        String result = captureSuccessResultLine();
+        int totalIndex = result.indexOf("Total time:  ");
+        int finishedIndex = result.indexOf("Finished at: ");
+        int finishedLength = result.length() - finishedIndex;
+        int lineLength = 130 - 8;
+        assertTrue(totalIndex >= 0);
+        assertTrue(result.contains(" (Wall Clock)"));
+        assertEquals((lineLength - finishedLength) / 2, totalIndex);
+        assertEquals(lineLength - finishedLength, finishedIndex);
+    }
+
+    @Test
+    void testFinalResultLineOnNarrowTerminal() {

Review Comment:
   The name suggests a narrow terminal test, but the effective `lineLength` 
here is 52 — the minimum (`MIN_TERMINAL_WIDTH=60`, minus 8). A width of 30 is 
clamped before it has any effect. Consider 
`testFinalResultLineAtMinimumTerminalWidth` to reflect what this actually 
covers.



##########
impl/maven-cli/src/main/java/org/apache/maven/cling/event/ExecutionEventLogger.java:
##########
@@ -295,15 +293,36 @@ private void formatBuildTime(StringBuilder buffer, 
BuildSummary buildSummary) {
     }
 
     private void logResult(MavenSession session) {
-        infoLine('-');
-        MessageBuilder buffer = builder();
-
         boolean failure = session.getResult().hasExceptions();
+        String status = failure ? "BUILD FAILURE" : "BUILD SUCCESS";
+
+        Instant finish = MonotonicClock.now();
+        Duration time = 
Duration.between(session.getRequest().getStartInstant(), finish);
+        String wallClock = session.getRequest().getDegreeOfConcurrency() > 1 ? 
" (Wall Clock)" : "";
+        String totalTime = "Total time:  " + formatDuration(time) + wallClock;
+
+        ZonedDateTime rounded = 
finish.truncatedTo(ChronoUnit.SECONDS).atZone(ZoneId.systemDefault());
+        String finishedAt = "Finished at: " + formatTimestamp(rounded);
+
+        int leftWidth = Math.max(0, (lineLength - finishedAt.length()) / 2);
+        int middleWidth = Math.max(0, lineLength - leftWidth - 
finishedAt.length());
+
+        int statusPadding = Math.max(0, leftWidth - status.length());
+        int totalTimePadding = Math.max(0, middleWidth - totalTime.length());
+        int overflow = Math.max(0, totalTime.length() - middleWidth);
+        statusPadding = Math.max(0, statusPadding - overflow);
+
+        MessageBuilder buffer = builder();
         if (failure) {
-            buffer.failure("BUILD FAILURE");
+            buffer.failure(status);
         } else {
-            buffer.success("BUILD SUCCESS");
+            buffer.success(status);
         }
+        buffer.a(chars(' ', statusPadding));
+        buffer.a(totalTime);

Review Comment:
   By merging `totalTime` and `finishedAt` into the same `buffer`, these fields 
now log at `ERROR` level on BUILD FAILURE (via the 
`logger.error(buffer.toString())` branch below). Previously `logStats()` always 
used `logger.info()` for timing. Is the log-level promotion intentional? If so, 
a note in the PR description would help.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to