olamy commented on code in PR #3651:
URL: https://github.com/apache/maven-surefire/pull/3651#discussion_r4745530111


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java:
##########
@@ -183,6 +210,48 @@ public void writeTestOutput(TestOutputReportEntry 
reportEntry) {
         }
     }
 
+    private TestOutput outputOf(Long testRunId) {
+        if (testRunId != null) {
+            TestOutput testOutput = runningTestsOutput.get(testRunId);
+            if (testOutput != null) {
+                return testOutput;
+            }
+            // printed outside a test, in @BeforeAll or between two tests, the 
thread still has the id of the last one
+            testOutput = classOutput.get(classOfRunId.get(testRunId));
+            if (testOutput != null) {
+                return testOutput;
+            }
+        }
+        // A thread the provider doesn't know, like a logger. The test that 
started last gets it, so it isn't lost.
+        TestOutput lastStarted = null;
+        for (TestOutput testOutput : runningTestsOutput.values()) {
+            lastStarted = testOutput;
+        }
+        if (lastStarted == null && classOutput.size() == 1) {
+            return classOutput.values().iterator().next();
+        }
+        return lastStarted;

Review Comment:
   Fixed in 896894a22. Output with no test id while no test runs now goes to 
the class that started last, so it isn't parked in the shared buffers anymore. 
The shared buffers are only used while no class runs, and the next class to 
start takes them. `outputOfAnUnknownThreadBeforeATestGoesToTheClassStartedLast` 
is the regression case: it logs after both classes started and before any test 
starts, and checks that the line lands in the first test.
   



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