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;
private boolean includeClassesDir;
private String aspectpath;
private String classpath;
+ private String modulepath;
private String inpath;
private String sourceroots;
private String outjar;
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.
*/
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());
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>();
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;
}
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
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;
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) {
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;
}
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;
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");
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 {
}
public int discoverChangesSince(File dir, long buildtime) {
- // TODO Auto-generated method stub
return 0;
}
/** 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;
this.className = className;
}
+ public void setModule(String module) {
+ this.module = module;
+ }
+
public void setLTW(String ltw) {
useLTW = TestUtil.parseBoolean(ltw);
}
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");