From b858c788515524c2224165fc615638b75266954f Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Tue, 19 Feb 2019 12:07:48 -0800 Subject: [PATCH] improved test harnesses for working with runtime --- .../org/aspectj/tools/ajc/AjcTestCase.java | 5 ++++- .../org/aspectj/testing/util/TestUtil.java | 20 +++++++++++++++---- .../java/org/aspectj/testing/CompileSpec.java | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index e102bd3514..eca7511823 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -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()); } @@ -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; diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java index d35f998961..654efd8c4d 100644 --- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java +++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java @@ -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; @@ -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(); diff --git a/testing/src/test/java/org/aspectj/testing/CompileSpec.java b/testing/src/test/java/org/aspectj/testing/CompileSpec.java index 22570e3d16..97cba2bc5f 100644 --- a/testing/src/test/java/org/aspectj/testing/CompileSpec.java +++ b/testing/src/test/java/org/aspectj/testing/CompileSpec.java @@ -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; }