From 90d3f9f305bc825480c4f9504b3eb635ce5e903c Mon Sep 17 00:00:00 2001 From: wisberg Date: Tue, 5 Oct 2004 20:51:24 +0000 Subject: [PATCH] support vm args during forking (simple update: forking still requires system properties) --- .../org/aspectj/testing/drivers/package.html | 88 +++++++++++-------- .../testing/harness/bridge/JavaRun.java | 9 ++ 2 files changed, 62 insertions(+), 35 deletions(-) diff --git a/testing-drivers/src/org/aspectj/testing/drivers/package.html b/testing-drivers/src/org/aspectj/testing/drivers/package.html index ed0e466b9..a24466579 100644 --- a/testing-drivers/src/org/aspectj/testing/drivers/package.html +++ b/testing-drivers/src/org/aspectj/testing/drivers/package.html @@ -1,13 +1,24 @@ + Harness Package Documentation -This document you how to run the harness, -specifying options on the command-line for the -various components that form the harness. +

+The AspectJ compiler test harness can compile and run AspectJ programs +as specified by the test definitions. +This document tells you how to run the harness. +It describes the options you can specify on the command-line to +control various components that form the harness, either to +specify options that augment the test definitions or to +change how the harness works, e.g., selecting particular tests +or logging more information. +For information on how to write a test definition, see +readme-writing-compiler-tests.html in the testing module. +

The harness drives compiler tests, using a chain of responsibility to map elements -in the schema of a test definition to implementing classes: -

+in the schema of a test definition to implementing classes. + +

@@ -21,23 +32,23 @@ in the schema of a test definition to implementing classes: - + - + - + - + - + @@ -51,12 +62,12 @@ in the schema of a test definition to implementing classes: <run> {sub-} run component (JavaRun) ... --> -

+

The compiler used is the AspectJ compiler ajc (optionally as wrapped by the Ant task or AJDE API's), but in principle any compiler accepting similar options can be used. -

+

To run from the command-line, use Harness.main(String[]). To run programmatically, use Harness.getHarness(). @@ -64,13 +75,13 @@ To run programmatically, use Harness.getHarness(). each component in the chain may accept and interpret, so you can modify how the tests run by specifying the following arguments on the harness command line: -

+

Test feature Descriptionsubclass feature harness FeatureHarness
<suite>
<suite> Test suite AjcTest.Suite
  <ajc-test>
  <ajc-test> Test case AjcTest
    <compile>
    <compile> Initial (batch) compile run CompilerRun
    <inc-compile>
    <inc-compile> Incremental re-compile IncCompilerRun
    <run>
    <run> Run class JavaRun
+

@@ -103,7 +114,7 @@ arguments on the harness command line: +

+

+

+

Options and forking

ComponentOptions
Harness

suite files, harness verbosity, temp files, option variants -

suite files: ajcTest-compliant .txt or .xml files are accepted.
FeatureHarness

output and logging options -

tracing: -progressDots will print "." for every passed test completed and "!" for every test completed but not passed. @@ -148,7 +159,7 @@ arguments on the harness command line:
AjcTest

selection options for keywords, bugID (PR), or title (description) -

keywords: -ajctest[Require|Skip]Keywords=one{,two} will either require or skip a test that has one of the specified keywords. @@ -161,13 +172,13 @@ arguments on the harness command line: will require that the title (description) of a test contain one of the specified substrings, here either "one" or "two". Use this to select a few tests you know generally. -
+
"-ajctestTitleList=first title\, in theory, second title" will require that the title (description) of a test be exactly "first title, in theory" or "second title". The entire option must be one argument on the command line. Use this when working with just a few specific tests. -
+
"-ajctestTitleList=../tests/ajcTestResults.txt" will require that the title (description) of a test be equal to one listed in ../tests/ajcTestResults.txt @@ -176,7 +187,7 @@ arguments on the harness command line: This option only differs from the prior in that the parameter is a valid file to read. Use this to re-run a large set of tests. -
+
"-ajctestTitleFailList=../tests/ajcTestResults.txt" is the same as the -ajctestTitleList={file} variant, except that only results prefixed "FAIL" are included. @@ -203,7 +214,7 @@ arguments on the harness command line:
CompilerRun

compiler options and side-effects -

supported options: The command line passed to the compiler by CompilerRun is composed of entries derived from the <compile> @@ -259,8 +270,9 @@ arguments on the harness command line: if they are in the same family. For example, -ajc and eclipse are both compiler, and -source 1.4 and -source 1.3 are both source. +
-

    +

auto-skip: After combining global and local options, there may be conflicting or impossible options, which cause the test to be skipped: @@ -269,8 +281,9 @@ arguments on the harness command line: - e.g., -lenient and -strict
  • impossible option: It may not be possible in the current configuration to implement an option - e.g., -usejavac or -eclipse - when javac or the eclipse implementation is not on the classpath
  • -

      + when javac or the eclipse implementation is not on the classpath +
      +

    source searching: Given -seek:{literal}, @@ -284,7 +297,7 @@ arguments on the harness command line:
    JavaRun -

    Options and forking

    options: options specified in the test are passed to the main method as they would be on the command-line. No options passed to the harness are passed through to @@ -295,7 +308,7 @@ arguments on the harness command line: than can be supported by the harness (i.e., some 1.1 flavor); it's very time-consuming otherwise. Currently forking is only controllable through system properties - of the invoking vm (defined in JavaRun): + of the invoking vm (defined in JavaRun.java):
    • javarun.fork: anything to run in a new vm.
    • @@ -310,50 +323,55 @@ arguments on the harness command line: run classpath. Multiple entries must be separated by the system-dependent path separator. +
    • javarun.vmargs: this is added to the fork command-line + right after java. Multiple entries must be separated by a comma + (and the whole thing should be one parameter), e.g., + -Djavarun.vmargs=-Dname=value,-Dname2="value 2" +
    -

    +
    Following are some sample configurations:

    @@ -361,7 +379,7 @@ Following are some sample configurations: If you have a set of options you use often, you can define a single-word option alias for it; see Harness.optionAliases. -

    Configuration: Most tests use the library jars in +
    Configuration: Most tests use the library jars in modules/lib/test, defined in org.aspectj.testing.harness.bridge.Globals. Normally the harness finds these by relative path @@ -373,7 +391,7 @@ define the environment variable harness.libdir - e.g., $ java -Dharness.libdir=../modules/lib/test ... -

    Forking:: +
    Forking:: The harness must be run in a compiler-compatible VM, and the compiler steps run in-process. However, the java steps can be run in forked mode, which is useful diff --git a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java index 21a67986c..e0ce0a799 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java @@ -42,17 +42,20 @@ import java.util.*; public class JavaRun implements IAjcRun { public static String FORK_KEY = "javarun.fork"; public static String JAVA_KEY = "javarun.java"; + public static String VM_ARGS_KEY = "javarun.vmargs"; public static String JAVA_HOME_KEY = "javarun.java.home"; public static String BOOTCLASSPATH_KEY = "javarun.bootclasspath"; private static final boolean FORK; private static final String JAVA; private static final String JAVA_HOME; + private static final String VM_ARGS; static final String BOOTCLASSPATH; static { FORK = (null != getProperty(FORK_KEY)); JAVA = getProperty(JAVA_KEY); JAVA_HOME = getProperty(JAVA_HOME_KEY); BOOTCLASSPATH = getProperty(BOOTCLASSPATH_KEY); + VM_ARGS = getProperty(VM_ARGS_KEY); try { System.setSecurityManager(RunSecurityManager.ME); } catch (Throwable t) { @@ -228,6 +231,12 @@ public class JavaRun implements IAjcRun { java = jfile.getAbsolutePath(); } cmd.add(java); + if (null != VM_ARGS) { + String[] args = XMLWriter.unflattenList(VM_ARGS); + for (int i = 0; i < args.length; i++) { + cmd.add(args[i]); + } + } cmd.add("-classpath"); cmd.add(classpath); cmd.add(spec.className); -- 2.39.5