Skip to content

Commit

Permalink
improved test harnesses for working with runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
aclement committed Feb 19, 2019
1 parent 35c4a7d commit b858c78
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ public RunResult run(String className, String moduleName, String[] args, String
vmargs ="";
}
try {
if (mp.indexOf("$runtimemodule") != -1) {
mp = mp.replace(mp.indexOf("$runtimemodule"),"$runtimemodule".length(),TestUtil.aspectjrtPath(true).toString());
}
if (mp.indexOf("$runtime") != -1) {
mp = mp.replace(mp.indexOf("$runtime"),"$runtime".length(),TestUtil.aspectjrtPath().toString());
}
Expand Down Expand Up @@ -930,7 +933,7 @@ protected String[] fixupArgs(String[] args) {
if (-1 == cpIndex) {
String[] newargs = new String[args.length + 2];
newargs[0] = "-classpath";
newargs[1] = TestUtil.aspectjrtPath().getPath();
newargs[1] = TestUtil.aspectjrtPath(false).getPath();
System.arraycopy(args, 0, newargs, 2, args.length);
args = newargs;
cpIndex = 1;
Expand Down
20 changes: 16 additions & 4 deletions testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ public final class TestUtil {
private static final Properties LIB_RPATHS;
private static final Map LIB_ENTRIES;
private static File ASPECTJRT_PATH;
private static File ASPECTJRTJAR_PATH;
static {
{
String[] paths = { "sp:aspectjrt.path", "sp:aspectjrt.jar"
,"../lib/test/aspectjrt.jar", "../runtime/target/classes"
// ,"../aj-build/jars/aspectj5rt-all.jar", "../aj-build/jars/runtime.jar", "../runtime/bin"
};
String[] paths = {
"sp:aspectjrt.path",
"sp:aspectjrt.jar",
"../runtime/target/classes",
"../lib/test/aspectjrt.jar"};
ASPECTJRT_PATH = FileUtil.getBestFile(paths);
ASPECTJRTJAR_PATH = FileUtil.getBestFile(paths, true);
}
{
boolean j5 = false;
Expand Down Expand Up @@ -159,6 +162,15 @@ public static File aspectjrtPath() {
return ASPECTJRT_PATH;
}

// needsJar for module packaged runtime
public static File aspectjrtPath(boolean needsJar) {
if (needsJar) {
return ASPECTJRTJAR_PATH;
} else {
return ASPECTJRT_PATH;
}
}

public static URL fileToURL(File file) {
try {
return file.toURL();
Expand Down
1 change: 1 addition & 0 deletions testing/src/test/java/org/aspectj/testing/CompileSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ protected String[] buildArgs() {
}

private String rewrite(String path) {
path = path.replace("$runtimemodule", TestUtil.aspectjrtPath(true).toString());
path = path.replace("$runtime", TestUtil.aspectjrtPath().toString());
return path;
}
Expand Down

0 comments on commit b858c78

Please sign in to comment.