MNG-618: We know make sure test coverage data is flushed before running the test coverage check.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@328760 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vincent Massol 2005-10-26 23:18:55 +00:00
parent 0b5ce92e93
commit aabeb4dcb0
3 changed files with 36 additions and 3 deletions

View File

@ -38,9 +38,23 @@ public abstract class AbstractCloverMojo extends AbstractMojo
* When the Clover Flush Policy is set to "interval" or threaded this value is the minimum
* period between flush operations (in milliseconds).
*
* @parameter default-value="5000"
* @parameter default-value="500"
*/
protected int flushInterval;
/**
* If true we'll wait 2*flushInterval to ensure coverage data is flushed to the Clover
* database before running any query on it.
*
* Note: The only use case where you would want to turn this off is if you're running your
* tests in a separate JVM. In that case the coverage data will be flushed by default upon
* the JVM shutdown and there would be no need to wait for the data to be flushed. As we
* can't control whether users want to fork their tests or not, we're offering this parameter
* to them.
*
* @parameter default-value="true"
*/
protected boolean waitForFlush;
/**
* Whether the Clover instrumentation should use the Clover <code>jdk14</code> or
@ -80,4 +94,21 @@ public abstract class AbstractCloverMojo extends AbstractMojo
return antProject;
}
/**
* Wait 2*'flush interval' milliseconds to ensure that the coverage data have been flushed.
*/
protected void waitForFlush()
{
if ( this.waitForFlush )
{
try
{
Thread.sleep( 2 * this.flushInterval );
}
catch ( InterruptedException e )
{
// Nothing to do... Just go on and try to check for coverage.
}
}
}
}

View File

@ -50,6 +50,8 @@ public class CloverCheckMojo
public void execute()
throws MojoExecutionException
{
waitForFlush();
Project antProject = registerCloverAntTasks();
getLog().info( "Checking for coverage of " + targetPercentage);

View File

@ -141,9 +141,9 @@ public class CloverInstrumentMojo
cloverArtifact.getType() );
// TODO: use addArtifacts
Set set = new HashSet( project.getDependencyArtifacts() );
Set set = new HashSet( this.project.getDependencyArtifacts() );
set.add( cloverArtifact );
project.setDependencyArtifacts( set );
this.project.setDependencyArtifacts( set );
}
/**