Revert Jason commit

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2004-01-20 08:53:39 +00:00
parent 8b47999877
commit feeeacc13d
4 changed files with 183 additions and 13 deletions

View File

@ -20,7 +20,7 @@ if $cygwin = true; then
repoLocal=`cygpath -pu "$repoLocal"`
fi
compile .:$repoLocal/junit/jars/junit-3.8.1.jar:$repoLocal/maven/jars/surefire-runner-1.0.jar:$repoLocal/plexus/jars/plexus-utils-1.0-beta-1.jar target/classes src/main
compile ".:$repoLocal/junit/jars/junit-3.8.1.jar:$repoLocal/maven/jars/surefire-runner-1.0.jar:$repoLocal/plexus/jars/plexus-utils-1.0-beta-1.jar" target/classes src/main
isCommandSuccessful $? "Failed compiling Maven bootstrapper classes!"

View File

@ -20,7 +20,7 @@ runJava()
{
# $1 == classpath
# $2 == Main class
# $3 == Mail args
# $3 == Main args
if $cygwin; then
CP=`cygpath -pw "$1"`
@ -33,7 +33,20 @@ runJava()
runTests()
{
# TO DO
# $1 == classpath
# $2 == home args
# $3 == repo local
# $4 == dependencies file
# $5 == includes file
# $6 == excludes file
if $cygwin; then
CP=`cygpath -pw "$1"`
else
CP=$1
fi
"${JAVACMD}" -classpath "$CP" TestRunnerBooter "$2" "$3" $4 $5 $6
}
compile()
@ -140,6 +153,8 @@ buildMavenProject()
fi
echo "Building tests in `pwd`"
repoLocal=`cat bootstrap.repo`
if $cygwin = true; then
@ -156,7 +171,9 @@ buildMavenProject()
copyResources
runTests
echo "Running tests in `pwd`"
runTests ".:${MBOOT_HOME}/classes:$repoLocal/junit/jars/junit-3.8.1.jar:$repoLocal/maven/jars/surefire-runner-1.0.jar:$repoLocal/plexus/jars/plexus-utils-1.0-beta-1.jar" "$home" "$repoLocal" bootstrap.libs bootstrap.tests.includes bootstrap.tests.excludes
if [ "$2" = "default" ]
then
@ -165,6 +182,8 @@ buildMavenProject()
jarName=$2
fi
echo "Building jars (${jarName}) in `pwd`/target"
buildJar $buildDest target/${jarName}
if [ -z $3 ]
@ -173,7 +192,8 @@ buildMavenProject()
rm -f bootstrap.libs > /dev/null 2>&1
rm -f bootstrap.resources > /dev/null 2>&1
rm -f bootstrap.repo > /dev/null 2>&1
rm -f bootstrap.test > /dev/null 2>&1
rm -f bootstrap.tests.includes > /dev/null 2>&1
rm -f bootstrap.tests.excludes > /dev/null 2>&1
fi
)
}

View File

@ -8,17 +8,13 @@ import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
public class Bootstrapper
{
@ -26,6 +22,8 @@ public class Bootstrapper
private BootstrapPomParser bootstrapPomParser;
private List dependencies;
private UnitTests unitTests;
private List resources;
@ -77,6 +75,62 @@ public class Bootstrapper
writeFile( "bootstrap.classpath", classPath.toString() );
writeFile( "bootstrap.libs", libs.toString() );
unitTests = bootstrapPomParser.getUnitTests();
StringBuffer tests = new StringBuffer();
tests.append(unitTests.getDirectory());
tests.append("@");
int size = unitTests.getIncludes().size();
// If there are no includes specified then we want it all.
if ( size == 0 )
{
tests.append( "'*'" );
}
for ( int j = 0; j < size; j++ )
{
String include = (String) unitTests.getIncludes().get( j );
tests.append( include );
if ( j != size - 1 )
{
tests.append( "," );
}
}
tests.append( "\n" );
writeFile( "bootstrap.tests.includes", tests.toString() );
tests = new StringBuffer();
tests.append(unitTests.getDirectory());
tests.append("@");
size = unitTests.getExcludes().size();
for ( int j = 0; j < size; j++ )
{
String exclude = (String) unitTests.getExcludes().get( j );
tests.append( exclude );
if ( j != size - 1 )
{
tests.append( "," );
}
}
tests.append( "\n" );
writeFile( "bootstrap.tests.excludes", tests.toString() );
resources = bootstrapPomParser.getResources();
@ -101,7 +155,7 @@ public class Bootstrapper
res.append( "@" );
int size = r.getIncludes().size();
size = r.getIncludes().size();
// If there are no includes specified then we want it all.
if ( size == 0 )
@ -153,6 +207,8 @@ public class Bootstrapper
extends DefaultHandler
{
private List dependencies = new ArrayList();
private UnitTests unitTests;
private List resources = new ArrayList();
@ -176,6 +232,11 @@ public class Bootstrapper
{
return dependencies;
}
public UnitTests getUnitTests()
{
return unitTests;
}
public List getResources()
{
@ -208,8 +269,13 @@ public class Bootstrapper
{
return;
}
else if ( rawName.equals( "unitTestSourceDirectory" ) )
{
unitTests = new UnitTests();
}
else if ( rawName.equals( "unitTest" ) )
{
unitTests = new UnitTests();
insideUnitTest = true;
}
else if ( rawName.equals( "dependency" ) )
@ -252,6 +318,10 @@ public class Bootstrapper
resources.addAll( p.getResources() );
}
else if ( rawName.equals( "unitTestSourceDirectory" ) )
{
unitTests.setDirectory(getBodyText());
}
else if ( rawName.equals( "unitTest" ) )
{
insideUnitTest = false;
@ -296,6 +366,17 @@ public class Bootstrapper
}
}
else if ( insideUnitTest )
{
if ( rawName.equals( "include" ) )
{
unitTests.addInclude( getBodyText() );
}
else if ( rawName.equals( "exclude" ) )
{
unitTests.addExclude( getBodyText() );
}
}
else if ( insideResource )
{
if ( rawName.equals( "directory" ) )
@ -494,6 +575,46 @@ public class Bootstrapper
return false;
}
}
public static class UnitTests
implements Serializable
{
private String directory;
private List includes = new ArrayList();
private List excludes = new ArrayList();
public void addInclude( String pattern )
{
this.includes.add( pattern );
}
public void addExclude( String pattern )
{
this.excludes.add( pattern );
}
public List getIncludes()
{
return this.includes;
}
public List getExcludes()
{
return this.excludes;
}
public void setDirectory( String directory )
{
this.directory = directory;
}
public String getDirectory()
{
return this.directory;
}
}
public static class Resource
implements Serializable

View File

@ -2,11 +2,14 @@ import org.apache.maven.test.TestRunner;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
public class TestRunnerBooter
{
@ -34,15 +37,40 @@ public class TestRunnerBooter
File dependenciesFile = new File(args[2]);
List dependencies = new ArrayList();
BufferedReader buf = new BufferedReader(new FileReader(dependenciesFile));
String line;
while ((line = buf.readLine()) != null)
{
dependencies.add(line);
}
buf.close();
processDependencies( dependencies, classLoader );
File includesFile = new File(args[3]);
List includes = new ArrayList();
buf = new BufferedReader(new FileReader(includesFile));
line = buf.readLine();
String includesStr = line.substring(line.indexOf("@")+1);
StringTokenizer st = new StringTokenizer( includesStr, "," );
while ( st.hasMoreTokens() )
{
includes.add( st.nextToken().trim() );
}
buf.close();
File excludesFile = new File(args[4]);
List includes = new ArrayList();
List excludes = new ArrayList();
buf = new BufferedReader(new FileReader(excludesFile));
line = buf.readLine();
String excludesStr = line.substring(line.indexOf("@")+1);
st = new StringTokenizer( excludesStr, "," );
while ( st.hasMoreTokens() )
{
excludes.add( st.nextToken().trim() );
}
buf.close();
String[] tests = collectTests( basedir,
includes,
@ -64,6 +92,7 @@ public class TestRunnerBooter
}
private void processDependencies(List dependencies, IsolatedClassLoader classLoader)
throws Exception
{
for (Iterator i=dependencies.iterator(); i.hasNext(); )
{