You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/12/28 21:27:00 UTC

[GitHub] [maven-surefire] Tibor17 opened a new pull request #419: synchronized logs

Tibor17 opened a new pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419


   The point is to get logger operations in semi-sequential order across multiple threads.
   The messages will not be mixed up, especially out and err.
   `PluginConsoleLogger` is synchronized. This instance is only one and it is passed to `DefaultReporterFactory` and `TestSetRunListener` as a monitor object.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] Tibor17 commented on a change in pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on a change in pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#discussion_r777135263



##########
File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ReportsMerger.java
##########
@@ -0,0 +1,36 @@
+package org.apache.maven.plugin.surefire.report;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.api.suite.RunResult;
+
+import java.io.File;
+import java.util.Collection;
+
+/**
+ * This interface is used to merge reports in {@link org.apache.maven.plugin.surefire.booterclient.ForkStarter}.
+ */
+public interface ReportsMerger
+{
+    void runStarting();
+    void mergeFromOtherFactories( Collection<DefaultReporterFactory> factories );
+    File getReportsDirectory();
+    RunResult close();

Review comment:
       The close method is closing the status, no matter that the class name is factory, it really does closing the reports after JVM exit. But I do not want to spend time on talking about theory with design patterns. I was aiming for not giving the developer a chance to call the method I am reimplementing since this class is polymorphic - it has two usages in ForkStarter. 




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] Tibor17 merged pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
Tibor17 merged pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419


   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] Tibor17 edited a comment on pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
Tibor17 edited a comment on pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#issuecomment-1019367621


   @slawekjaranowski 
   The feeling about the methods in the interface `ReportsMerger` would mean a refactoring and it is not my goal to make here. 
   
   If you see the usages of `DefaultReporterFactory` in `ForkStarter` you would notice that `DefaultReporterFactory` has three purposes, one is an aggregator of listeners which is `ReportsMerger`, second is Fork Reporter and the third purpose is a factory which is constructed in `ForkStarter` and passed into `ForkClient`.
   
   Of course it is possible to make a refactoring and rename few methods, which is your main whish coming from your feeling, but it is not the goal of this ticket. The fact is that the field `listeners` have to be shared and the private method `mergeTestHistoryResult()` must become protected and therefore the abstraction would contain an abstract class, three interfaces and implementation classes.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] Tibor17 commented on a change in pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on a change in pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#discussion_r777108528



##########
File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
##########
@@ -206,7 +207,7 @@ public void run()
                     // if tests failed, but if this does not happen then printing warning to console is the only way to
                     // inform the users.
                     String msg = "ForkStarter IOException: " + e.getLocalizedMessage() + ".";
-                    File reportsDir = defaultReporterFactory.getReportsDirectory();
+                    File reportsDir = reportMerger.getReportsDirectory();

Review comment:
       Because there must be abstraction. There are two DefaultReporterFactory instances. One is per fork, and another is the "merger".
   We simply cannot allow ForkStarter or the developer who is not aware of Surefire insides to call other methods than the "merger" can expose.
   Now, the answer for the following questions why this interface ReportsMerger exists in here is the fact that I implement the method writeTestOutput(). Of course I cannot allow the "merger" to call this method by any reason even if by mistake. So the ReportsMerger becomes a subinterface with limitted access excluding writeTestOutput() to prevent from calling it, to prevent from calling new implementation of this method, so that it will be called only in ForkClient and not in ForkStarter.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] slawekjaranowski commented on a change in pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on a change in pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#discussion_r777111725



##########
File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
##########
@@ -206,7 +207,7 @@ public void run()
                     // if tests failed, but if this does not happen then printing warning to console is the only way to
                     // inform the users.
                     String msg = "ForkStarter IOException: " + e.getLocalizedMessage() + ".";
-                    File reportsDir = defaultReporterFactory.getReportsDirectory();
+                    File reportsDir = reportMerger.getReportsDirectory();

Review comment:
       maybe I don't see something ...




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] slawekjaranowski commented on pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#issuecomment-1006494389


   I'm still not comfortable for adding next responsibility `ReportsMerger` for  `DefaultReporterFactory`


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] slawekjaranowski commented on a change in pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on a change in pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#discussion_r777111661



##########
File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
##########
@@ -206,7 +207,7 @@ public void run()
                     // if tests failed, but if this does not happen then printing warning to console is the only way to
                     // inform the users.
                     String msg = "ForkStarter IOException: " + e.getLocalizedMessage() + ".";
-                    File reportsDir = defaultReporterFactory.getReportsDirectory();
+                    File reportsDir = reportMerger.getReportsDirectory();

Review comment:
       `reportMerger` and `startupReportConfiguration` are final variable 
    `startupReportConfiguration` is pass to `reportMerger` constructor ...
   `CloseableCloser` is inner class which use variable from  ForkStarter instance 
   
   is it possible that we have different instance of `startupReportConfiguration`?




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] Tibor17 commented on pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#issuecomment-1019367621


   @slawekjaranowski 
   The feeling about the methods in the interface `ReportsMerger` would mean a refactoring and it is not my goal to make. 
   
   If you see the usages of `DefaultReporterFactory` in `ForkStarter` you would notice that `DefaultReporterFactory` has three purposes, one is an aggregator of listeners which is `ReportsMerger`, second is Fork Reporter and the third purpose is a factory which is constructed in `ForkStarter` and passed into `ForkClient`.
   
   Of course it is possible to make a refactoring and rename few methods, which is your main whish coming from your feeling, but it is not the goal of this ticket. The fact is that the field `listeners` have to be shared and the private method `mergeTestHistoryResult()` must become protected and therefore the abstraction would contain an abstract class, three interfaces and implementation classes.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] Tibor17 commented on pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#issuecomment-1003430257


   @slawekjaranowski
   Pls finish this review and I would like to close the Jira ticket.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-surefire] slawekjaranowski commented on a change in pull request #419: [SUREFIRE-1926] Console logs should be synchronized

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on a change in pull request #419:
URL: https://github.com/apache/maven-surefire/pull/419#discussion_r777105793



##########
File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
##########
@@ -65,7 +65,7 @@
  * @author Kristian Rosenvold
  */
 public class DefaultReporterFactory
-    implements ReporterFactory
+    implements ReporterFactory, ReportsMerger

Review comment:
       next responsibility for this class - maybe will be possible create separate class

##########
File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
##########
@@ -206,7 +207,7 @@ public void run()
                     // if tests failed, but if this does not happen then printing warning to console is the only way to
                     // inform the users.
                     String msg = "ForkStarter IOException: " + e.getLocalizedMessage() + ".";
-                    File reportsDir = defaultReporterFactory.getReportsDirectory();
+                    File reportsDir = reportMerger.getReportsDirectory();

Review comment:
       why not
   ```
   startupReportConfiguration.getReportsDirectory();
   ```
   than we can remove this method from `ReportsMerger` interface.

##########
File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ReportsMerger.java
##########
@@ -0,0 +1,36 @@
+package org.apache.maven.plugin.surefire.report;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.api.suite.RunResult;
+
+import java.io.File;
+import java.util.Collection;
+
+/**
+ * This interface is used to merge reports in {@link org.apache.maven.plugin.surefire.booterclient.ForkStarter}.
+ */
+public interface ReportsMerger
+{
+    void runStarting();
+    void mergeFromOtherFactories( Collection<DefaultReporterFactory> factories );
+    File getReportsDirectory();
+    RunResult close();

Review comment:
       Name of method is not corresponding to what is doing ... inside `close` method -  there are calling
    - `mergeTestHistoryResult`
    - `runCompleted`
    - and `close` on all listerneres colected in `mergeFromOtherFactories`




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org