Index: testsrc/org/aspectj/ajdt/internal/compiler/batch/DeclareParents.java =================================================================== RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/DeclareParents.java,v --- testsrc/org/aspectj/ajdt/internal/compiler/batch/DeclareParents.java 29 Apr 2005 20:22:00 -0000 1.3 +++ testsrc/org/aspectj/ajdt/internal/compiler/batch/DeclareParents.java 20 Oct 2005 05:07:04 -0000 @@ -332,7 +332,7 @@ if (result.getErrorMessages().size()!=0) System.err.println("Expecting no errors from jar building but got\n"+result.getErrorMessages()); assertTrue("Should get no errors for this compile, but got: "+result.getErrorMessages().size(),result.getErrorMessages().size()==0); // Execute: "ajc -inpath classes -showWeaveInfo -d classes2 -aspectpath aspects.jar" - result = ajc(testBase,new String[]{"-inpath","classes","-showWeaveInfo","-d","classes2","-aspectpath","aspects.jar"}); + result = weave(testBase,new String[]{"-inpath","classes","-showWeaveInfo","-d","classes2","-aspectpath","aspects.jar"}); if (!expectErrors) assertTrue("unexpected errors? \n"+result.getErrorMessages(),!result.hasErrorMessages()); @@ -415,7 +415,13 @@ // } } - public String[] mergeOptions(String[] input,String[] extras) { + // default to testing with ajc + protected CompilationResult weave(File testBase, String[] strings) { + return ajc(testBase, strings); + } + + + public String[] mergeOptions(String[] input,String[] extras) { String[] ret = new String[input.length+extras.length]; System.arraycopy(input,0,ret,0,input.length); System.arraycopy(extras,0,ret,input.length,extras.length); @@ -425,7 +431,7 @@ - private List getWeaveMessages(CompilationResult result) { + protected List getWeaveMessages(CompilationResult result) { List infoMessages = result.getInfoMessages(); List weaveMessages = new ArrayList(); for (Iterator iter = infoMessages.iterator(); iter.hasNext();) { Index: testsrc/org/aspectj/tools/ajc/Ajc.java =================================================================== RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java,v --- testsrc/org/aspectj/tools/ajc/Ajc.java 29 Sep 2005 15:40:48 -0000 1.21 +++ testsrc/org/aspectj/tools/ajc/Ajc.java 20 Oct 2005 05:07:04 -0000 @@ -30,6 +30,7 @@ import org.aspectj.bridge.IMessage.Kind; import org.aspectj.bridge.context.CompilationAndWeavingContext; import org.aspectj.util.FileUtil; +import org.aspectj.weaver.tools.CmdLineWeaver; /** * The Ajc class is intended for use as part of a unit-test suite, it drives @@ -76,6 +77,7 @@ private File sandbox; private File baseDir; private Main main; + private CmdLineWeaver weaver; private String[] ajcArgs; private int incrementalStage = 10; private boolean shouldEmptySandbox = true; @@ -194,6 +196,11 @@ // important to sleep after preparing the sandbox on first incremental stage (see notes in pr90806) try { Thread.sleep(1000); } catch (Exception e) {} } + if (weaver != null) { + weaver.setMessageHander(holder); + weaver.run(args); + weaver = null; + } else if (isIncremental) { controller.doIncremental(holder); } else { @@ -269,6 +276,13 @@ if ((dir != null) && !dir.isDirectory()) throw new IllegalArgumentException(dir.getPath() + " is not a directory"); baseDir = dir; } + + /** + * Set a jar weaver to be used for the next compile only + */ + public void setJarWeaverNext(CmdLineWeaver weaver) { + this.weaver = weaver; + } private void addMessagesTo(List aList, IMessage[] messages) { for (int i = 0; i < messages.length; i++) { @@ -314,7 +328,7 @@ * Make every relative file name and dir be absolute under sandbox * Add TESTER_PATH to classpath */ - private String[] adjustToSandbox(String[] args,boolean doCopy) throws IOException { + String[] adjustToSandbox(String[] args,boolean doCopy) throws IOException { String[] newArgs = new String[args.length]; boolean hasClasspath = false; boolean hasOutdir = false; Index: testsrc/org/aspectj/tools/ajc/AjcTestCase.java =================================================================== RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java,v --- testsrc/org/aspectj/tools/ajc/AjcTestCase.java 14 Oct 2005 07:23:54 -0000 1.23 +++ testsrc/org/aspectj/tools/ajc/AjcTestCase.java 20 Oct 2005 05:07:05 -0000 @@ -30,6 +30,8 @@ import org.aspectj.testing.util.TestUtil; import org.aspectj.weaver.loadtime.WeavingURLClassLoader; +import org.aspectj.weaver.tools.CmdLineWeaver; + import junit.framework.TestCase; /** @@ -519,7 +521,7 @@ return lastRunResult; } public void testNothingForAntJUnit() {} - + /** * Run the given class (main method), and return the result in a RunResult. The program runs with * a classpath containing the sandbox directory, runtime, testing-client, bridge, and @@ -725,6 +727,13 @@ } } + /** + * Set a jar weaver to be used for the next compile only + */ + public void setJarWeaverNext(CmdLineWeaver weaver) { + ajc.setJarWeaverNext(weaver); + } + /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ Index: aspects.jar =================================================================== RCS file: aspects.jar --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ aspects.jar 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1 @@ +PKb~I3META-INF/MANIFEST.MFþÊ Index: testsrc/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsJarWeaver.java =================================================================== RCS file: testsrc/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsJarWeaver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsrc/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsJarWeaver.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +package org.aspectj.ajdt.internal.compiler.batch; + +import java.io.File; + +import org.aspectj.tools.ajc.CompilationResult; +import org.aspectj.weaver.tools.CmdLineWeaver; + +/** run declare parents tests using the jar weaver command line weaver */ +public class DeclareParentsJarWeaver extends DeclareParents { + + public CompilationResult weave(File baseDir, String[] args) { + ajc.setJarWeaverNext(new CmdLineWeaver()); + return super.weave(baseDir, args); + } + + +}