New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SUREFIRE-1926] Console logs should be synchronized #419
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ | |
* @author Kristian Rosenvold | ||
*/ | ||
public class DefaultReporterFactory | ||
implements ReporterFactory | ||
implements ReporterFactory, ReportsMerger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. next responsibility for this class - maybe will be possible create separate class |
||
{ | ||
private final Collection<TestSetRunListener> listeners = new ConcurrentLinkedQueue<>(); | ||
private final StartupReportConfiguration reportConfiguration; | ||
|
@@ -107,11 +107,13 @@ public RunListener createReporter() | |
createStatisticsReporter(), | ||
reportConfiguration.isTrimStackTrace(), | ||
PLAIN.equals( reportConfiguration.getReportFormat() ), | ||
reportConfiguration.isBriefOrPlainFormat() ); | ||
reportConfiguration.isBriefOrPlainFormat(), | ||
consoleLogger ); | ||
addListener( testSetRunListener ); | ||
return testSetRunListener; | ||
} | ||
|
||
@Override | ||
public File getReportsDirectory() | ||
{ | ||
return reportConfiguration.getReportsDirectory(); | ||
|
@@ -151,6 +153,7 @@ private StatisticsReporter createStatisticsReporter() | |
return useNonNull( statisticsReporter, NullStatisticsReporter.INSTANCE ); | ||
} | ||
|
||
@Override | ||
public void mergeFromOtherFactories( Collection<DefaultReporterFactory> factories ) | ||
{ | ||
for ( DefaultReporterFactory factory : factories ) | ||
|
@@ -176,6 +179,7 @@ public RunResult close() | |
return globalStats.getRunResult(); | ||
} | ||
|
||
@Override | ||
public void runStarting() | ||
{ | ||
if ( reportConfiguration.isPrintSummary() ) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name of method is not corresponding to what is doing ... inside
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
than we can remove this method from
ReportsMerger
interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reportMerger
andstartupReportConfiguration
are final variablestartupReportConfiguration
is pass toreportMerger
constructor ...CloseableCloser
is inner class which use variable from ForkStarter instanceis it possible that we have different instance of
startupReportConfiguration
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I don't see something ...