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


##########
its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java:
##########
@@ -655,6 +655,14 @@ public void verifyTextInLog(String text) throws 
VerificationException {
                 break;
             }
         }
+        if (!result && stdout != null) {
+            for (String line : getStdout().lines().toList()) {
+                if (stripAnsi(line).contains(text)) {
+                    result = true;
+                    break;
+                }
+            }
+        }

Review Comment:
   ⚠️ **Semantic gap: `verifyTextInLog` now checks stdout for all execution 
modes**
   
   This fallback applies unconditionally — not just in embedded mode. In forked 
mode, `stdout` is typically empty, but if it isn't, any IT where the expected 
text appears in stdout but is absent from the log file will silently pass, 
masking real regressions.
   
   Worse, `verifyTextNotInLog` has no symmetric change — it only scans the log 
file. This creates a logical inconsistency: `verifyTextInLog("X")` can succeed 
(text in stdout) while `verifyTextNotInLog("X")` also succeeds (text absent 
from log). Both returning success for the same text is a silent correctness 
hole.
   
   If this is only needed for embedded mode, guard on `stdout.size() > 0` to 
avoid scanning in forked mode, and document the asymmetry or add the same 
fallback to `verifyTextNotInLog`:
   ```suggestion
           if (!result && stdout != null && stdout.size() > 0) {
               // Embedded mode may not redirect log output to the log file, so 
also check
               // captured stdout.  In forked mode stdout is typically empty.
               for (String line : getStdout().lines().toList()) {
                   if (stripAnsi(line).contains(text)) {
                       result = true;
                       break;
                   }
               }
           }
   ```



##########
compat/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliLoggingTest.java:
##########
@@ -338,22 +331,19 @@ private void cachesOutputAfterTerminalInstallation(String 
color) throws Exceptio
             loggingThread.start();
 
             // Wait until the logging thread is blocked on 
awaitTerminalInitialization() →
-            // FastTerminal.getTerminal() → CompletableFuture.get().  At this 
point,
-            // config.init() has NOT yet run (it comes after 
awaitTerminalInitialization()).
+            // terminalReady.join(). At this point, config.init() has NOT yet 
run (it
+            // comes after awaitTerminalInitialization()).
             awaitThreadState(loggingThread, Thread.State.WAITING, 10_000);
 
-            // Release the terminal — the consumer sets 
System.out=terminalStream.
-            // awaitTerminalInitialization() returns, then config.init() 
captures terminalStream.
+            // Release the terminal — the onComplete callback sets 
System.out=terminalStream
+            // and completes terminalReady. awaitTerminalInitialization() 
returns only after
+            // onComplete finishes, then config.init() captures terminalStream.
             releaseTerminal.countDown();
             logging.get(10, SECONDS);
 
             
LoggerFactory.getLogger(MavenCliLoggingTest.class).warn("terminal-output-marker");
-            assertTrue(
-                    
terminalOutput.toString(UTF_8.name()).contains("terminal-output-marker"),
-                    "Logger must write to the stream installed by the terminal 
consumer");
-            assertFalse(
-                    
earlyOutput.toString(UTF_8.name()).contains("terminal-output-marker"),
-                    "Logger must not write to the early stream that was active 
before terminal installation");
+            
assertTrue(terminalOutput.toString(UTF_8.name()).contains("terminal-output-marker"));
+            
assertFalse(earlyOutput.toString(UTF_8.name()).contains("terminal-output-marker"));

Review Comment:
   💡 **Nit:** Assertion messages were removed — this makes failures harder to 
diagnose. Other assertions in this file (e.g. the `color-always` case at line 
~175) retain their messages. Restore them:
   ```suggestion
               assertTrue(
                       
terminalOutput.toString(UTF_8.name()).contains("terminal-output-marker"),
                       "Logger must write to the stream installed by the 
terminal consumer");
               assertFalse(
                       
earlyOutput.toString(UTF_8.name()).contains("terminal-output-marker"),
                       "Logger must not write to the early stream that was 
active before terminal installation");
   ```



-- 
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