Browse Source

Bug 150131 "org.aspectj.ajde.core testcases create "out" directory in project root" (use sandbox for compiling and running tests)

tags/pre_pr_153572
mwebster 18 years ago
parent
commit
ea82f25eb6

+ 5
- 5
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java View File

List args = new ArrayList(); List args = new ArrayList();


args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-classpath"); args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator + "../lib/junit/junit.jar;../testing-client/bin"); args.add(getRuntimeClasspath() + File.pathSeparator + "../lib/junit/junit.jar;../testing-client/bin");
List args = new ArrayList(); List args = new ArrayList();


args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-classpath"); args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator + "../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar"); args.add(getRuntimeClasspath() + File.pathSeparator + "../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar");
List args = new ArrayList(); List args = new ArrayList();


args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-classpath"); args.add("-classpath");
args.add("../lib/junit/junit.jar;../testing-client/bin"); args.add("../lib/junit/junit.jar;../testing-client/bin");
} }
public void testSizeChanges() { public void testSizeChanges() {
File f1 = new File("out/SizeIssues.class");
File f1 = new File(getSandboxName(),"SizeIssues.class");
List args = new ArrayList(); List args = new ArrayList();


args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-classpath"); args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator + args.add(getRuntimeClasspath() + File.pathSeparator +

+ 17
- 15
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java View File



public void testJar1() throws IOException { public void testJar1() throws IOException {
String library = getSandboxName() + "/lib.jar";
List args = new ArrayList(); List args = new ArrayList();
args.add("-outjar"); args.add("-outjar");
args.add("out/lib.jar");
args.add(library);


args.add("-classpath"); args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath()); args.add(AjcTests.aspectjrtClasspath());
args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-XnotReweavable"); args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/lib/ConcreteA.aj"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/lib/ConcreteA.aj");
args = new ArrayList(); args = new ArrayList();
args.add("-aspectpath"); args.add("-aspectpath");
args.add("out/lib.jar");
args.add(library);


args.add("-classpath"); args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath()); args.add(AjcTests.aspectjrtClasspath());
args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-XnotReweavable"); args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client.java"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
TestUtil.runMain("out" + File.pathSeparator + "out/lib.jar", "client.Client");
TestUtil.runMain("out" + File.pathSeparator + "out/lib.jar", "client.Client1");
TestUtil.runMain(getSandboxName() + File.pathSeparator + library, "client.Client");
TestUtil.runMain(getSandboxName() + File.pathSeparator + library, "client.Client1");
args = new ArrayList(); args = new ArrayList();
args.add("-aspectpath"); args.add("-aspectpath");
args.add("out/lib.jar");
args.add(library);


args.add("-classpath"); args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath()); args.add(AjcTests.aspectjrtClasspath());
args.add("-XnotReweavable"); args.add("-XnotReweavable");
args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
TestUtil.runMain("out" + File.pathSeparator + "out/lib.jar", "client.Client1");
TestUtil.runMain(getSandboxName() + File.pathSeparator + library, "client.Client1");


args = new ArrayList(); args = new ArrayList();
args.add("-aspectpath"); args.add("-aspectpath");
args.add("out/lib.jar");
args.add(library);


args.add("-classpath"); args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath()); args.add(AjcTests.aspectjrtClasspath());
args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-XnotReweavable"); args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect1.aj"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect1.aj");


args = new ArrayList(); args = new ArrayList();
args.add("-classpath"); args.add("-classpath");
args.add("out/lib.jar" + File.pathSeparator + AjcTests.aspectjrtClasspath());
args.add(library + File.pathSeparator + AjcTests.aspectjrtClasspath());
args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-XnotReweavable"); args.add("-XnotReweavable");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
args = new ArrayList(); args = new ArrayList();
args.add("-classpath"); args.add("-classpath");
args.add(AjcTests.aspectjrtClasspath() + File.pathSeparator + "out/lib.jar");
args.add(AjcTests.aspectjrtClasspath() + File.pathSeparator + library);
args.add("-Xlint:error"); args.add("-Xlint:error");
args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj");
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");

+ 32
- 15
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java View File



package org.aspectj.ajdt.internal.compiler.batch; package org.aspectj.ajdt.internal.compiler.batch;


import org.aspectj.ajdt.ajc.*;
import org.aspectj.ajdt.ajc.AjdtCommand;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.IMessageHolder;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.tools.ajc.AjcTests;
import org.aspectj.weaver.bcel.LazyClassGen;

import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;


import junit.framework.TestCase; import junit.framework.TestCase;


import org.aspectj.ajdt.ajc.AjdtAjcTests;
import org.aspectj.ajdt.ajc.AjdtCommand;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.IMessageHolder;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.testing.util.TestUtil;
import org.aspectj.tools.ajc.Ajc;
import org.aspectj.tools.ajc.AjcTests;
import org.aspectj.weaver.bcel.LazyClassGen;

public abstract class CommandTestCase extends TestCase { public abstract class CommandTestCase extends TestCase {


/** /**
public static final int[] NO_ERRORS = new int[0]; public static final int[] NO_ERRORS = new int[0];
public static final int[] TOP_ERROR = new int[0]; public static final int[] TOP_ERROR = new int[0];


private File sandbox;


public static void checkCompile(String source, int[] expectedErrors) {
checkCompile(source, new String[0], expectedErrors);
public void checkCompile(String source, int[] expectedErrors) {
checkCompile(source, new String[0], expectedErrors, getSandboxName());
} }
public static void checkCompile(String source, String[] extraArgs, int[] expectedErrors) {
protected void runMain(String className) {
TestUtil.runMain(getSandboxName(), className);
}
public static void checkCompile(String source, String[] extraArgs, int[] expectedErrors, String sandboxName) {
List args = new ArrayList(); List args = new ArrayList();
args.add("-verbose"); args.add("-verbose");
args.add("-d"); args.add("-d");
args.add("out");
args.add(sandboxName);
args.add("-classpath"); args.add("-classpath");


args.add("-verbose"); args.add("-verbose");
args.add("-d"); args.add("-d");
args.add("out");
args.add(getSandboxName());
args.add("-classpath"); args.add("-classpath");
args.add(getRuntimeClasspath()); args.add(getRuntimeClasspath());
return AjcTests.aspectjrtClasspath(); return AjcTests.aspectjrtClasspath();
} }


protected String getSandboxName () {
return sandbox.getAbsolutePath();
}
protected void setUp() throws Exception {
super.setUp();

sandbox = Ajc.createEmptySandbox();
}

} }





+ 22
- 24
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompileAndRunTestCase.java View File



import java.io.IOException; import java.io.IOException;


import org.aspectj.testing.util.TestUtil;



public class CompileAndRunTestCase extends CommandTestCase { public class CompileAndRunTestCase extends CommandTestCase {




public void testAround() throws IOException { public void testAround() throws IOException {
checkCompile("src1/AroundA.java", NO_ERRORS); checkCompile("src1/AroundA.java", NO_ERRORS);
TestUtil.runMain("out", "AroundAMain");
runMain("AroundAMain");
} }
public void testInterType() throws IOException { public void testInterType() throws IOException {
checkCompile("src1/InterType.java", NO_ERRORS); checkCompile("src1/InterType.java", NO_ERRORS);
TestUtil.runMain("out", "InterType");
runMain("InterType");
} }
public void testInterTypeMethods() throws IOException { public void testInterTypeMethods() throws IOException {
checkCompile("src1/InterTypeMethods.java", NO_ERRORS); checkCompile("src1/InterTypeMethods.java", NO_ERRORS);
TestUtil.runMain("out", "InterTypeMethods");
runMain("InterTypeMethods");
} }
public void testIf() throws IOException { public void testIf() throws IOException {
CommandTestCase.checkCompile("src1/IfPcd.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "IfPcd");
checkCompile("src1/IfPcd.java", CommandTestCase.NO_ERRORS);
runMain("IfPcd");
} }
public void testDeclareParentsFail() throws IOException { public void testDeclareParentsFail() throws IOException {
CommandTestCase.checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19});
checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19});
} }
public void testDeclareParents() throws IOException { public void testDeclareParents() throws IOException {
CommandTestCase.checkCompile("src1/Parents.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "Parents");
checkCompile("src1/Parents.java", CommandTestCase.NO_ERRORS);
runMain("Parents");
} }
public void testPerCflow() throws IOException { public void testPerCflow() throws IOException {
CommandTestCase.checkCompile("src1/PerCflow.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "PerCflow");
checkCompile("src1/PerCflow.java", CommandTestCase.NO_ERRORS);
runMain("PerCflow");
} }
public void testPerObject() throws IOException { public void testPerObject() throws IOException {
CommandTestCase.checkCompile("src1/PerObject.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "PerObject");
checkCompile("src1/PerObject.java", CommandTestCase.NO_ERRORS);
runMain("PerObject");
} }
public void testDeclareSoft() throws IOException { public void testDeclareSoft() throws IOException {
CommandTestCase.checkCompile("src1/DeclareSoft.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "DeclareSoft");
checkCompile("src1/DeclareSoft.java", CommandTestCase.NO_ERRORS);
runMain("DeclareSoft");
} }
public void testPrivileged() throws IOException { public void testPrivileged() throws IOException {
CommandTestCase.checkCompile("src1/Privileged.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "Privileged");
checkCompile("src1/Privileged.java", CommandTestCase.NO_ERRORS);
runMain("Privileged");
} }
public void testHandler() throws IOException { public void testHandler() throws IOException {
CommandTestCase.checkCompile("src1/Handler.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "Handler");
checkCompile("src1/Handler.java", CommandTestCase.NO_ERRORS);
runMain("Handler");
} }
public void testInterConstructors() throws IOException { public void testInterConstructors() throws IOException {
CommandTestCase.checkCompile("src1/InterTypeConstructors.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "InterTypeConstructors");
checkCompile("src1/InterTypeConstructors.java", CommandTestCase.NO_ERRORS);
runMain("InterTypeConstructors");
} }
public void testAroundA1() throws IOException { public void testAroundA1() throws IOException {
CommandTestCase.checkCompile("src1/AroundA1.java", CommandTestCase.NO_ERRORS);
TestUtil.runMain("out", "AroundA1");
checkCompile("src1/AroundA1.java", CommandTestCase.NO_ERRORS);
runMain("AroundA1");
} }
} }

+ 4
- 5
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java View File



import java.io.IOException; import java.io.IOException;


import org.aspectj.testing.util.TestUtil;



public class PerformanceTestCase extends CommandTestCase { public class PerformanceTestCase extends CommandTestCase {


public void xxx_testLazyTjpOff() throws IOException { public void xxx_testLazyTjpOff() throws IOException {
checkCompile("src1/LazyTjp.aj", NO_ERRORS); checkCompile("src1/LazyTjp.aj", NO_ERRORS);
try { try {
TestUtil.runMain("out", "LazyTjp");
runMain("LazyTjp");
fail("expected an exception when running without -XlazyTjp"); fail("expected an exception when running without -XlazyTjp");
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// expected exception thrown when no -XlazyTjp // expected exception thrown when no -XlazyTjp
// joinpoint method-execution(int LazyTjp.doit3(int)) because around advice is used [Xlint:canNotImplementLazyTjp]' // joinpoint method-execution(int LazyTjp.doit3(int)) because around advice is used [Xlint:canNotImplementLazyTjp]'
// into an error so that we can use checkCompiles() ability to check errors occur. // into an error so that we can use checkCompiles() ability to check errors occur.
// Pass -proceedOnError to ensure even though we get that message, we still get the class file on disk // Pass -proceedOnError to ensure even though we get that message, we still get the class file on disk
checkCompile("src1/LazyTjp.aj", new String[] {"-Xlint:error","-proceedOnError"}, new int[] {96});
TestUtil.runMain("out", "LazyTjp");
String sandboxName = getSandboxName();
checkCompile("src1/LazyTjp.aj", new String[] {"-Xlint:error","-proceedOnError"}, new int[] {96}, sandboxName);
runMain("LazyTjp");
} }
} }

+ 6
- 5
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/ProceedOnErrorTestCase.java View File

*/ */
public void testNoProceedOnError() throws IOException { public void testNoProceedOnError() throws IOException {
checkCompile("src1/C1.java", NO_ERRORS); checkCompile("src1/C1.java", NO_ERRORS);
File f =new File("out"+File.separator+"C.class");
File f =new File(getSandboxName(),"C.class");
long oldmodtime = f.lastModified(); long oldmodtime = f.lastModified();
pause(2); pause(2);
checkCompile("src1/C2.java", new int[]{1}); checkCompile("src1/C2.java", new int[]{1});
f =new File("out"+File.separator+"C.class");
f =new File(getSandboxName(),"C.class");
long newmodtime = f.lastModified(); long newmodtime = f.lastModified();
// Without -proceedOnError supplied, we should *not* change the time stamp on the .class file // Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
assertTrue("The .class file should not have been modified as '-proceedOnError' was not supplied (old="+ assertTrue("The .class file should not have been modified as '-proceedOnError' was not supplied (old="+


public void testProceedOnError() throws IOException { public void testProceedOnError() throws IOException {
checkCompile("src1/C1.java", NO_ERRORS); checkCompile("src1/C1.java", NO_ERRORS);
File f =new File("out"+File.separator+"C.class");
File f =new File(getSandboxName(),"C.class");
long oldmodtime = f.lastModified(); long oldmodtime = f.lastModified();
pause(2); pause(2);
checkCompile("src1/C2.java",new String[]{"-proceedOnError"}, new int[]{1});
f =new File("out"+File.separator+"C.class");
String sandboxName = getSandboxName();
checkCompile("src1/C2.java",new String[]{"-proceedOnError"}, new int[]{1}, sandboxName);
f =new File(sandboxName,"C.class");
long newmodtime = f.lastModified(); long newmodtime = f.lastModified();
// Without -proceedOnError supplied, we should *not* change the time stamp on the .class file // Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
assertTrue("The .class file should have been modified as '-proceedOnError' *was* supplied (old="+ assertTrue("The .class file should have been modified as '-proceedOnError' *was* supplied (old="+

+ 3
- 2
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java View File

import junit.framework.TestCase; import junit.framework.TestCase;


import org.aspectj.ajdt.ajc.*; import org.aspectj.ajdt.ajc.*;
import org.aspectj.ajdt.ajc.BuildArgParser;
import org.aspectj.asm.AsmManager; import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageHandler; import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.MessageWriter; import org.aspectj.bridge.MessageWriter;
import org.aspectj.tools.ajc.Ajc;
import org.aspectj.util.StreamPrintWriter; import org.aspectj.util.StreamPrintWriter;
//import org.eclipse.core.runtime.CoreException; //import org.eclipse.core.runtime.CoreException;


AjBuildManager manager = new AjBuildManager(messageWriter); AjBuildManager manager = new AjBuildManager(messageWriter);
BuildArgParser parser = new BuildArgParser(messageWriter); BuildArgParser parser = new BuildArgParser(messageWriter);
String javaClassPath = System.getProperty("java.class.path"); String javaClassPath = System.getProperty("java.class.path");
String sandboxName = Ajc.createEmptySandbox().getAbsolutePath();
AjBuildConfig buildConfig = AjBuildConfig buildConfig =
parser.genBuildConfig(new String[] { parser.genBuildConfig(new String[] {
"-d", "out",
"-d", sandboxName,
"-classpath", "-classpath",
javaClassPath, javaClassPath,
AjdtAjcTests.TESTDATA_PATH AjdtAjcTests.TESTDATA_PATH

Loading…
Cancel
Save