]> source.dussan.org Git - aspectj.git/commitdiff
Bug 150131 "org.aspectj.ajde.core testcases create "out" directory in project root...
authormwebster <mwebster>
Thu, 3 Aug 2006 08:32:31 +0000 (08:32 +0000)
committermwebster <mwebster>
Thu, 3 Aug 2006 08:32:31 +0000 (08:32 +0000)
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompileAndRunTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/ProceedOnErrorTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java

index 3f9cb379a3ed3d0a14105a28551c01394a5cf9cf..7a8bfa48f4ce412332341c033fdcc9ca16741543 100644 (file)
@@ -95,7 +95,7 @@ public class BasicCommandTestCase extends CommandTestCase {
                List args = new ArrayList();
 
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                
                args.add("-classpath");
                args.add(getRuntimeClasspath() + File.pathSeparator +\r                  "../lib/junit/junit.jar;../testing-client/bin");
@@ -108,7 +108,7 @@ public class BasicCommandTestCase extends CommandTestCase {
                List args = new ArrayList();
 
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                
                args.add("-classpath");
                args.add(getRuntimeClasspath() + File.pathSeparator +\r                  "../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar");
@@ -128,7 +128,7 @@ public class BasicCommandTestCase extends CommandTestCase {
                List args = new ArrayList();
 
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                
                args.add("-classpath");
                args.add("../lib/junit/junit.jar;../testing-client/bin");
@@ -174,12 +174,12 @@ public class BasicCommandTestCase extends CommandTestCase {
        }
        
        public void testSizeChanges() {
-               File f1 = new File("out/SizeIssues.class");
+               File f1 = new File(getSandboxName(),"SizeIssues.class");
                
                List args = new ArrayList();
 
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                
                args.add("-classpath");
                args.add(getRuntimeClasspath() + File.pathSeparator +
index ef7eda767627192d257584e1482f650f5b368449..d69906cdfdc1f33170ba20d8892aeeecf2b71473 100644 (file)
@@ -30,15 +30,17 @@ public class BinaryFormsTestCase extends CommandTestCase {
        
 
        public void testJar1() throws IOException {
+               String library = getSandboxName() + "/lib.jar";
+               
                List args = new ArrayList();
                args.add("-outjar");
-               args.add("out/lib.jar");
+               args.add(library);
 
                args.add("-classpath");
         args.add(AjcTests.aspectjrtClasspath());
                
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                args.add("-XnotReweavable");
                
                args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/lib/ConcreteA.aj");
@@ -48,13 +50,13 @@ public class BinaryFormsTestCase extends CommandTestCase {
                
                args = new ArrayList();
                args.add("-aspectpath");
-               args.add("out/lib.jar");
+               args.add(library);
 
                args.add("-classpath");
         args.add(AjcTests.aspectjrtClasspath());
                
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                args.add("-XnotReweavable");
                
                args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client.java");
@@ -62,36 +64,36 @@ public class BinaryFormsTestCase extends CommandTestCase {
                
                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.add("-aspectpath");
-               args.add("out/lib.jar");
+               args.add(library);
 
                args.add("-classpath");
         args.add(AjcTests.aspectjrtClasspath());
                args.add("-XnotReweavable");
                
                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/Client1.java");
                
                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.add("-aspectpath");
-               args.add("out/lib.jar");
+               args.add(library);
 
                args.add("-classpath");
         args.add(AjcTests.aspectjrtClasspath());
                
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                args.add("-XnotReweavable");
                
                args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect1.aj");
@@ -101,10 +103,10 @@ public class BinaryFormsTestCase extends CommandTestCase {
 
                args = new ArrayList();
                args.add("-classpath");
-        args.add("out/lib.jar" + File.pathSeparator + AjcTests.aspectjrtClasspath());
+        args.add(library + File.pathSeparator + AjcTests.aspectjrtClasspath());
                
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                args.add("-XnotReweavable");
                
                args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
@@ -113,11 +115,11 @@ public class BinaryFormsTestCase extends CommandTestCase {
                
                args = new ArrayList();
                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("-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/Client1.java");
index 12dc26c1dfeb86d2e704ee343ba696968a20dcf7..58c93b921dc78d6bf5c2db44cbc59334d5aed2bc 100644 (file)
 
 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.IOException;
 import java.util.ArrayList;
@@ -31,6 +21,18 @@ import java.util.List;
 
 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 {
 
        /**
@@ -44,17 +46,22 @@ public abstract class CommandTestCase extends TestCase {
        public static final int[] NO_ERRORS = 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();
                args.add("-verbose");
                
                args.add("-d");
-               args.add("out");
+               args.add(sandboxName);
                
                args.add("-classpath");         
 
@@ -77,7 +84,7 @@ public abstract class CommandTestCase extends TestCase {
                args.add("-verbose");
                
                args.add("-d");
-               args.add("out");
+               args.add(getSandboxName());
                
                args.add("-classpath");
                args.add(getRuntimeClasspath());
@@ -170,6 +177,16 @@ public abstract class CommandTestCase extends TestCase {
         return AjcTests.aspectjrtClasspath();          
        }
 
+       protected String getSandboxName () {
+               return sandbox.getAbsolutePath();
+       }
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+
+               sandbox = Ajc.createEmptySandbox();
+       }
+
 }
 
 
index 4c72a37188f329a4a3c6284e035cf1c380dd27ac..2838763bf8cbf4316820ce56855d100124e0bccb 100644 (file)
@@ -14,8 +14,6 @@ package org.aspectj.ajdt.internal.compiler.batch;
 
 import java.io.IOException;
 
-import org.aspectj.testing.util.TestUtil;
-
 
 public class CompileAndRunTestCase extends CommandTestCase {
 
@@ -25,66 +23,66 @@ public class CompileAndRunTestCase extends CommandTestCase {
 
        public void testAround() throws IOException {
                checkCompile("src1/AroundA.java", NO_ERRORS);
-               TestUtil.runMain("out", "AroundAMain");
+               runMain("AroundAMain");
        }
        
        public void testInterType() throws IOException {
                checkCompile("src1/InterType.java", NO_ERRORS);
-               TestUtil.runMain("out", "InterType");
+               runMain("InterType");
        }
        
        public void testInterTypeMethods() throws IOException {
                checkCompile("src1/InterTypeMethods.java", NO_ERRORS);
-               TestUtil.runMain("out", "InterTypeMethods");
+               runMain("InterTypeMethods");
        }
        
        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 {
-               CommandTestCase.checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19});
+               checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19});
        }
        
        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 {
-               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 {
-               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 {
-               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 {
-               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 {
-               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 {
-               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 {
-               CommandTestCase.checkCompile("src1/AroundA1.java", CommandTestCase.NO_ERRORS);
-               TestUtil.runMain("out", "AroundA1");
+               checkCompile("src1/AroundA1.java", CommandTestCase.NO_ERRORS);
+               runMain("AroundA1");
        }
                
 }
index 98f69707e84f36e14e179bcea2745050343a4c35..1563a57bb8cf42c746ffad55673ff75ca1cfbca2 100644 (file)
@@ -14,8 +14,6 @@ package org.aspectj.ajdt.internal.compiler.batch;
 
 import java.io.IOException;
 
-import org.aspectj.testing.util.TestUtil;
-
 
 public class PerformanceTestCase extends CommandTestCase {
 
@@ -28,7 +26,7 @@ public class PerformanceTestCase extends CommandTestCase {
        public void xxx_testLazyTjpOff() throws IOException {
                checkCompile("src1/LazyTjp.aj", NO_ERRORS);
                try {
-                       TestUtil.runMain("out", "LazyTjp");
+                       runMain("LazyTjp");
                        fail("expected an exception when running without -XlazyTjp");
                } catch (IllegalStateException e) {
                        // expected exception thrown when no -XlazyTjp
@@ -40,8 +38,9 @@ public class PerformanceTestCase extends CommandTestCase {
                //   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.
                // 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");
        }
        
 }
index 3378130ea86a023a5ba82e84a0de677a9d866ab7..570adf7aa20fbde06c3976e13a43feb4a2f66a21 100644 (file)
@@ -30,11 +30,11 @@ public class ProceedOnErrorTestCase extends CommandTestCase {
         */
        public void testNoProceedOnError() throws IOException {
                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();
            pause(2);
                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();
         // 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="+
@@ -44,11 +44,12 @@ public class ProceedOnErrorTestCase extends CommandTestCase {
 
        public void testProceedOnError() throws IOException {
                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();
            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();
         // 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="+
index 10eb2d2226ec38d016eb3dffe1af103d580a242d..8de9bb93bad512a11b064a5fbcd237c920299257 100644 (file)
@@ -20,11 +20,11 @@ import java.io.PrintWriter;
 import junit.framework.TestCase;
 
 import org.aspectj.ajdt.ajc.*;
-import org.aspectj.ajdt.ajc.BuildArgParser;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageHandler;
 import org.aspectj.bridge.MessageWriter;
+import org.aspectj.tools.ajc.Ajc;
 import org.aspectj.util.StreamPrintWriter;
 //import org.eclipse.core.runtime.CoreException;
 
@@ -64,9 +64,10 @@ public class AjBuildManagerTest extends TestCase {
                AjBuildManager manager = new AjBuildManager(messageWriter);
                BuildArgParser parser = new BuildArgParser(messageWriter);
                String javaClassPath = System.getProperty("java.class.path");
+               String sandboxName = Ajc.createEmptySandbox().getAbsolutePath();
         AjBuildConfig buildConfig = 
                        parser.genBuildConfig(new String[] { 
-                               "-d", "out"
+                               "-d", sandboxName
                                "-classpath",
                                javaClassPath,
                                AjdtAjcTests.TESTDATA_PATH