Adding file-pattern matching for expected results, along with ability to suppress the default maven.repo.local specification from verifier.properties...also, adding a test case for MNG-1021, to ensure the source artifact has the same build number as the main jar...I cannot reproduce the problem using this test...

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292286 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-09-28 20:14:35 +00:00
parent 03b6c44316
commit 5ebaf148da
10 changed files with 129 additions and 12 deletions

View File

@ -518,19 +518,63 @@ public class Verifier
{
expectedFile = new File( basedir, line );
}
if ( !expectedFile.exists() )
if ( line.indexOf( '*' ) > -1 )
{
if ( wanted )
File parent = expectedFile.getParentFile();
if ( !parent.exists() )
{
throw new VerificationException( "Expected file was not found: " + expectedFile.getPath() );
if ( wanted )
{
throw new VerificationException( "Expected file was not found: " + expectedFile.getPath() );
}
}
else
{
String shortNamePattern = expectedFile.getName().replaceAll( "\\*", ".*" );
String[] candidates = parent.list();
boolean found = false;
if ( candidates != null )
{
for ( int i = 0; i < candidates.length; i++ )
{
if ( candidates[i].matches( shortNamePattern ) )
{
found = true;
break;
}
}
}
if ( !found && wanted )
{
throw new VerificationException( "Expected file pattern was not found: " + expectedFile.getPath() );
}
else if ( found && !wanted )
{
throw new VerificationException( "Unwanted file pattern was found: " + expectedFile.getPath() );
}
}
}
else
{
if ( !wanted )
if ( !expectedFile.exists() )
{
throw new VerificationException( "Unwanted file was found: " + expectedFile.getPath() );
if ( wanted )
{
throw new VerificationException( "Expected file was not found: " + expectedFile.getPath() );
}
}
else
{
if ( !wanted )
{
throw new VerificationException( "Unwanted file was found: " + expectedFile.getPath() );
}
}
}
}
@ -540,7 +584,7 @@ public class Verifier
//
// ----------------------------------------------------------------------
public void executeGoals( Properties properties, String filename )
public void executeGoals( Properties properties, Properties controlProperties, String filename )
throws VerificationException
{
String mavenHome = System.getProperty( "maven.home" );
@ -583,7 +627,10 @@ public class Verifier
for ( Iterator it = cliOptions.iterator(); it.hasNext(); )
{
String key = (String) it.next();
cli.createArgument().setLine( key );
String resolvedArg = resolveCommandLineArg( key );
cli.createArgument().setLine( resolvedArg );
}
cli.createArgument().setValue( "-e" );
@ -598,9 +645,13 @@ public class Verifier
cli.createArgument().setLine( "-D" + key + "=" + properties.getProperty( key ) );
}
// Note: Make sure that the repo is surrounded by quotes as it can possibly have
// spaces in its path.
cli.createArgument().setLine( "-Dmaven.repo.local=" + "\"" + localRepo + "\"" );
boolean useMavenRepoLocal = Boolean.valueOf( controlProperties.getProperty( "use.mavenRepoLocal", "true" ) ).booleanValue();
if ( useMavenRepoLocal )
{
// Note: Make sure that the repo is surrounded by quotes as it can possibly have
// spaces in its path.
cli.createArgument().setLine( "-Dmaven.repo.local=" + "\"" + localRepo + "\"" );
}
for ( Iterator i = allGoals.iterator(); i.hasNext(); )
{
@ -636,6 +687,15 @@ public class Verifier
}
}
private String resolveCommandLineArg( String key )
{
String result = key.replaceAll( "\\$\\{basedir\\}", basedir );
result = result.replaceAll( "\\\\", "\\" );
result = result.replaceAll( "\\/\\/", "\\/" );
return result;
}
private void displayLogFile()
{
System.out.println( "Log file contents:" );
@ -746,7 +806,7 @@ public class Verifier
boolean chokeOnErrorOutput = Boolean.valueOf(
controlProperties.getProperty( "failOnErrorOutput", "true" ) ).booleanValue();
verifier.executeGoals( properties, "goals.txt" );
verifier.executeGoals( properties, controlProperties, "goals.txt" );
verifier.executeHook( "postbuild-hook.txt" );

View File

@ -291,5 +291,14 @@ it2001: Test that repositories are accumulated as the artifact resolution
that transitive dependencies can be resolved from repositories defined
in the top-level pom.xml. See MNG-757.
it2002: Test the release plugin.
it2003: Test that source artifacts share the same build number as the main
project artifact. This is only defined in the 2000 series because of
the exorbitant time it takes to execute (it uses a uniquely defined
local repository, to avoid pollution from existing artifacts in
pattern matching of the results).
-------------------------------------------------------------------------------

View File

@ -0,0 +1,3 @@
This should be defined as a 00-series IT, but it takes WAY too long to run, so
I'm putting it in the 20-series. You should use the same method for running this
test as you would any single test in the 00 series.

View File

@ -0,0 +1 @@
--settings ${basedir}/settings.xml

View File

@ -0,0 +1,2 @@
target/test-repo/org/apache/maven/it/maven-core-it2003/1.0-SNAPSHOT/maven-core-it2003-1.0-*-1.jar
target/test-repo/org/apache/maven/it/maven-core-it2003/1.0-SNAPSHOT/maven-core-it2003-1.0-*-1-sources.jar

View File

@ -0,0 +1 @@
deploy

View File

@ -0,0 +1,31 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it2003</artifactId>
<version>1.0-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>
<id>test-repo</id>
<url>file:target/test-repo</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,3 @@
<settings>
<localRepository>file:target/local-repo</localRepository>
</settings>

View File

@ -0,0 +1,6 @@
package org.apache.maven.it2003;
public class Person
{
private String name;
}

View File

@ -0,0 +1 @@
use.mavenRepoLocal=false