]> source.dussan.org Git - aspectj.git/commitdiff
Upgraded test infra to support building/running modules
authorAndy Clement <aclement@pivotal.io>
Fri, 20 Oct 2017 19:36:27 +0000 (12:36 -0700)
committerAndy Clement <aclement@pivotal.io>
Fri, 20 Oct 2017 19:36:27 +0000 (12:36 -0700)
testing/newsrc/org/aspectj/testing/CompileSpec.java
testing/newsrc/org/aspectj/testing/FileSpec.java
testing/newsrc/org/aspectj/testing/RunSpec.java
testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java
testing/src/org/aspectj/testing/ajde/CompileCommand.java
testing/src/org/aspectj/testing/harness/bridge/JavaRun.java
testing/src/org/aspectj/testing/xml/AjcSpecXmlReader.java

index 714158a11b183b8987bb44a32533ea1a6cba9b69..22570e3d168610b71cda37fc7b7d11ea59676402 100644 (file)
@@ -16,6 +16,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import org.aspectj.testing.util.TestUtil;
 import org.aspectj.tools.ajc.AjcTestCase;
 import org.aspectj.tools.ajc.CompilationResult;
 
@@ -31,6 +32,7 @@ public class CompileSpec implements ITestStep {
        private boolean includeClassesDir;
        private String aspectpath;
        private String classpath;
+       private String modulepath;
        private String inpath;
        private String sourceroots;
        private String outjar;
@@ -97,6 +99,14 @@ public class CompileSpec implements ITestStep {
        public void setClasspath(String classpath) {
                this.classpath = classpath.replace(',',File.pathSeparatorChar);
        }
+
+       public String getModulepath() {
+               return this.modulepath;
+       }
+       
+       public void setModulepath(String modulepath) {
+               this.modulepath = modulepath.replace(',', File.pathSeparatorChar);
+       }
        /**
         * @return Returns the files.
         */
@@ -241,6 +251,11 @@ public class CompileSpec implements ITestStep {
                        args.append(getClasspath());
                        args.append(" ");
                }
+               if (getModulepath() != null) {
+                       args.append("-p ");
+                       args.append(rewrite(getModulepath()));
+                       args.append(" ");
+               }
                if (getXlintfile() != null) {
                        args.append("-Xlintfile ");
                        args.append(getXlintfile());
@@ -287,6 +302,11 @@ public class CompileSpec implements ITestStep {
                return ret;
        }
        
+       private String rewrite(String path) {
+               path = path.replace("$runtime", TestUtil.aspectjrtPath().toString());
+               return path;
+       }
+
        protected AjcTestCase.MessageSpec buildMessageSpec() {
                List<AjcTestCase.Message> infos = null;
                List<AjcTestCase.Message> warnings = new ArrayList<AjcTestCase.Message>();
index 448e5e34e4a80c078ebd6484bbd5ad8c8f0c9e95..f9876928b5abf28d0bd597a09a7c247c9c7b4fef 100644 (file)
@@ -40,10 +40,25 @@ public class FileSpec implements ITestStep {
        public void execute(AjcTestCase inTestCase) {
                File sandbox = inTestCase.getSandboxDirectory();
                if (toDelete != null) {
-                       new File(sandbox, toDelete).delete();
+                       File targetForDeletion = new File(sandbox, toDelete);
+                       if (targetForDeletion.isFile()) {
+                               targetForDeletion.delete();
+                       } else {
+                               recursiveDelete(targetForDeletion);
+                       }
                }
        }
 
+       private void recursiveDelete(File toDelete) {
+               if (toDelete.isDirectory()) {
+                       File[] files = toDelete.listFiles();
+                       for (File f: files) {
+                               recursiveDelete(f);
+                       }
+               }
+               toDelete.delete();
+       }
+
        public void setBaseDir(String dir) {
                // this.dir = dir;
        }
index 2309788bc94d5c48747695a32b90ff3371079ee0..9d21b599c65fbbf9e0dd4f9e652213fa484ad950 100644 (file)
@@ -21,6 +21,9 @@ import java.util.StringTokenizer;
 
 import org.aspectj.tools.ajc.AjcTestCase;
 import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
+import org.aspectj.weaver.Utils;
+import org.aspectj.weaver.bcel.Utility;
 
 /**
  * @author Adrian Colyer
@@ -29,9 +32,11 @@ public class RunSpec implements ITestStep {
 
        private List<ExpectedMessageSpec> expected = new ArrayList<ExpectedMessageSpec>();
        private String classToRun;
+       private String moduleToRun;  // alternative to classToRun on JDK9+
        private String baseDir;
        private String options;
        private String cpath;
+       private String mpath;
        private String orderedStderr;
        private AjcTest myTest;
        private OutputSpec stdErrSpec;
@@ -59,9 +64,9 @@ public class RunSpec implements ITestStep {
                try {
                        setSystemProperty("test.base.dir", inTestCase.getSandboxDirectory().getAbsolutePath());
 
-                       AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(), args, vmargs, getClasspath(), useLtw, "true".equalsIgnoreCase(usefullltw));
+                       AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(), getModuleToRun(), args, vmargs, getClasspath(), getModulepath(), useLtw, "true".equalsIgnoreCase(usefullltw));
 
-                       if (stdErrSpec != null) {
+                       if (stdErrSpec != null) { 
                                stdErrSpec.matchAgainst(rr.getStdErr(), orderedStderr);
                        }
                        if (stdOutSpec != null) {
@@ -129,6 +134,16 @@ public class RunSpec implements ITestStep {
                return this.cpath.replace('/', File.separatorChar).replace(',', File.pathSeparatorChar);
        }
 
+       public String getModulepath() {
+               if (mpath == null)
+                       return null;
+               return this.mpath.replace('/', File.separatorChar).replace(',', File.pathSeparatorChar);
+       }
+
+       public void setModulepath(String mpath) {
+               this.mpath = mpath;
+       }
+       
        public void setClasspath(String cpath) {
                this.cpath = cpath;
        }
@@ -144,20 +159,22 @@ public class RunSpec implements ITestStep {
        public void setOrderedStderr(String orderedStderr) {
                this.orderedStderr = orderedStderr;
        }
-
-       /**
-        * @return Returns the classToRun.
-        */
+       
        public String getClassToRun() {
                return classToRun;
        }
-
-       /**
-        * @param classToRun The classToRun to set.
-        */
+       
        public void setClassToRun(String classToRun) {
                this.classToRun = classToRun;
        }
+       
+       public void setModuleToRun(String moduleToRun) {
+               this.moduleToRun = moduleToRun;
+       }
+       
+       public String getModuleToRun() {
+               return this.moduleToRun;
+       }
 
        public String getLtwFile() {
                return ltwFile;
index 18b9233dc1cd46a4502844d9d531f7074dbd38ed..fa47c98c445129748f822c4d00255cb4c45b0cdc 100644 (file)
@@ -202,6 +202,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
                digester.addSetNext("suite/ajc-test/file", "addTestStep", "org.aspectj.testing.ITestStep");
                digester.addObjectCreate("suite/ajc-test/run", RunSpec.class);
                digester.addSetProperties("suite/ajc-test/run", "class", "classToRun");
+               digester.addSetProperties("suite/ajc-test/run", "module", "moduleToRun");
                digester.addSetProperties("suite/ajc-test/run", "ltw", "ltwFile");
                digester.addSetProperties("suite/ajc-test/run", "xlintfile", "xlintFile");
                digester.addSetProperties("suite/ajc-test/run/stderr", "ordered", "orderedStderr");
index 2fd748ff2798da9a85b495117aaaaa3fcdc30b62..86c5fbaf72d67249e9d5cf424948a3d31e357f46 100644 (file)
@@ -378,6 +378,18 @@ class MyCompilerConfig implements ICompilerConfiguration {
                return null;
        }
 
+       @Override
+       public String getModulepath() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public String getModuleSourcepath() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
 }
 
 class MyOutputLocationManager implements IOutputLocationManager {
@@ -417,7 +429,6 @@ class MyOutputLocationManager implements IOutputLocationManager {
        }
 
        public int discoverChangesSince(File dir, long buildtime) {
-               // TODO Auto-generated method stub
                return 0;
        }
 
index 8efad22de64e36a90b44735f6ffe94598963440e..aade35f48928d50a45d0a0dc588fe3b65468f040 100644 (file)
@@ -610,6 +610,9 @@ public class JavaRun implements IAjcRun {
         /** fully-qualified name of the class to run */
         protected String className;
         
+        /** Alternative to classname for specifying what to run modulename/type */
+        protected String module;
+        
         /** minimum required version of Java, if any */
         protected String javaVersion;
         
@@ -669,6 +672,10 @@ public class JavaRun implements IAjcRun {
             this.className = className;
         }
         
+        public void setModule(String module) {
+            this.module = module;
+        }
+
         public void setLTW(String ltw) {
             useLTW = TestUtil.parseBoolean(ltw);
         }
index 1c295d795067ccd6f65dc90bd57d7cc5035ea016..370a9ac913861f589545fa922a6ca46a6bba39fd 100644 (file)
@@ -251,8 +251,8 @@ public class AjcSpecXmlReader {
         digester.addSetProperties(compileX + "/file");
         digester.addSetProperties(inccompileX, "classes", "paths");
         digester.addSetProperties(runX, 
-            new String[] { "class", "vm", "skipTester", "fork", "vmargs", "aspectpath"},
-            new String[] { "className", "javaVersion", "skipTester", "fork", "vmArgs", "aspectpath"});
+            new String[] { "class", "vm", "skipTester", "fork", "vmargs", "aspectpath", "module"},
+            new String[] { "className", "javaVersion", "skipTester", "fork", "vmArgs", "aspectpath", "module"});
         digester.addSetProperties(dirchangesX);
         digester.addSetProperties(messageX);
         digester.addSetProperties(messageSrcLocX, "line", "lineAsString");