diff options
author | wisberg <wisberg> | 2003-10-23 20:01:19 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2003-10-23 20:01:19 +0000 |
commit | 1e28c4ed1f76c67d26a51092ec02bf75d97132e3 (patch) | |
tree | 7c9118aabe9211d469abda64de814c95a3f94ab8 /testing/src | |
parent | df309ad58ae97560a94b01f798845d9517cd5c86 (diff) | |
download | aspectj-1e28c4ed1f76c67d26a51092ec02bf75d97132e3.tar.gz aspectj-1e28c4ed1f76c67d26a51092ec02bf75d97132e3.zip |
head-compatible version of earlier fix. sigh.
Note that the fix is incomplete and being reworked.
Diffstat (limited to 'testing/src')
3 files changed, 154 insertions, 16 deletions
diff --git a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java index c14f53aa7..8339a25ad 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java +++ b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java @@ -13,6 +13,7 @@ package org.aspectj.testing.harness.bridge; +import java.io.File; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; @@ -20,6 +21,7 @@ import java.util.BitSet; import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.StringTokenizer; import org.aspectj.bridge.*; import org.aspectj.bridge.IMessage; @@ -78,6 +80,16 @@ import org.aspectj.util.LangUtil; */ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHandler? + + private static final Fork FORK; + + static { + String value = + Globals.getSystemProperty(Globals.FORK_NAME, null); + FORK = (LangUtil.isEmpty(value) + ? Fork.NOFORK + : new Fork(value)); + } /** true if we expect to use a staging directory */ boolean isStaging; @@ -158,7 +170,6 @@ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHa public String getDescription() { return description; } - // ------- source location of the spec public void setSourceLocation(ISourceLocation sourceLocation) { @@ -779,6 +790,11 @@ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHa spec.xmlNames = ((AbstractRunSpec.XMLNames) xmlNames.clone()); } + protected final Fork getFork() { + // spec ignored now, but perhaps not later... + return FORK; + } + private static void addListCount(String name, List list, StringBuffer sink) { int size = list.size(); if ((null != list) && (0 < size)) { @@ -986,4 +1002,125 @@ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHa } } } // class RT + + protected static class Fork { + public static final Fork NOFORK = new Fork(); + private static final String DELIMITER = ","; + private final boolean fork; + private final String version; + private final String java; + private final File javaHome; + private final String bootclasspath; + private final String errs; + + private Fork() { + this(null); + } + + /** + * @param spec a String null (no) or of the form + * <code>1.[12345],{javaHome},{java},{bootclasspath}</code> + * where {javaHome} is a readable directory and + * a prefix of {java}. + */ + private Fork(String spec) { + if (null == spec) { + fork = false; + version = null; + java = null; + javaHome = null; + bootclasspath = null; + errs = null; + return; + } + String inputVersion = null; + File inputJavaHome = null; + String inputJava = null; + String inputBootclasspath = null; + // + // paths should be in system-specific form + final String EXPECT = + "{version=1.[12345],{java.home},{java.command},{bootclasspath}"; + final String EXAMPLE = + "1.1,d:/jdk11,d:/jdk11/bin/java,d:/jdk11/lib/classes.zip"; + if (LangUtil.isEmpty(spec)) { + spec = ""; + } + StringBuffer inputErrs = new StringBuffer(); + StringTokenizer st = new StringTokenizer(spec, DELIMITER); + if (4 != st.countTokens()) { + inputErrs.append(" expecting 4 tokens."); + } else { + inputVersion = st.nextToken().trim(); + String inputJavaHomePath = st.nextToken().trim(); + inputJava = st.nextToken().trim(); + inputBootclasspath = st.nextToken().trim(); + if (!inputVersion.startsWith("1.") + || (3 != inputVersion.length()) + || ('1' > inputVersion.charAt(2)) + || ('6' < inputVersion.charAt(2)) ) { + inputErrs.append(" expecting version 1.[12345]"); + } + inputJavaHome = new File(inputJavaHomePath); + if (!inputJavaHome.canRead() + || !inputJavaHome.isDirectory()) { + inputErrs.append(" expecting java.home dir: " + + inputJavaHomePath); + } + if (!inputJava.startsWith(inputJavaHomePath)) { + inputErrs.append(" expecting java in java.home.dir: " + + inputJava); + } + if (LangUtil.isEmpty(inputBootclasspath)) { + inputBootclasspath = null; + } + } + String inputErrString = inputErrs.toString(); + fork = (0 == inputErrString.length()); + if (fork) { + errs = null; + } else { + errs = "bad fork specification. Expecting " + + EXPECT + + " - for example, " + + EXAMPLE + + ". Problems: " + + inputErrString; + } + version = inputVersion; + java = inputJava; + javaHome = inputJavaHome; + bootclasspath = inputBootclasspath; + } + public boolean fork() { + return fork; + } + public String getJavaExecutablePath() { + return java; + } + public File getJavaHome() { + return javaHome; + } + public String getJavaBootclasspath() { + return bootclasspath; + } + public String getErrors() { + return errs; + } + public String toSpecString() { + if (!fork) { + return null; + } + return version + + DELIMITER + + javaHome + + DELIMITER + + java + + DELIMITER + + bootclasspath; + } + public String toString() { + return (fork ? "Fork [true]" : "Fork [false]"); // XXX upgrade + } + } // class Fork } diff --git a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java index 91be27a0b..172f0de74 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java +++ b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java @@ -67,8 +67,8 @@ public class CompilerRun implements IAjcRun { static final String AJDE_COMPILER = CompileCommand.class.getName(); static final String AJCTASK_COMPILER = AjcTaskCompileCommand.class.getName(); - static final String JAVAC_COMPILER - = JavacCompileCommand.class.getName(); +// static final String JAVAC_COMPILER +// = JavacCompileCommand.class.getName(); static final String[] RA_String = new String[0]; @@ -987,15 +987,15 @@ public class CompilerRun implements IAjcRun { } else { result.result = true; } - } else if (JAVAC_COMPILER.equals(result.compilerName)) { - // XXX vet - badOptions = LangUtil.selectOptions(argList, Spec.INVALID_JAVAC_OPTIONS); - if (!LangUtil.isEmpty(badOptions)) { - result.failureReason = "no support in javac" - + " for (normally-valid) options " + Arrays.asList(badOptions); - } else { - result.result = true; - } +// } else if (JAVAC_COMPILER.equals(result.compilerName)) { +// // XXX vet +// badOptions = LangUtil.selectOptions(argList, Spec.INVALID_JAVAC_OPTIONS); +// if (!LangUtil.isEmpty(badOptions)) { +// result.failureReason = "no support in javac" +// + " for (normally-valid) options " + Arrays.asList(badOptions); +// } else { +// result.result = true; +// } } else { result.failureReason = "unrecognized compiler: " + result.compilerName; } @@ -1036,9 +1036,9 @@ public class CompilerRun implements IAjcRun { } else if ("-ajctaskCompiler".equals(arg)) { result.compilerName = AJCTASK_COMPILER; return true; - } else if ("-javac".equals(arg)) { - result.compilerName = JAVAC_COMPILER; - return true; +// } else if ("-javac".equals(arg)) { +// result.compilerName = JAVAC_COMPILER; +// return true; } else if ("-eclipse".equals(arg) || "!eclipse".equals(arg) || "^ajc".equals(arg)) { result.compilerName = ReflectionFactory.ECLIPSE; return true; diff --git a/testing/src/org/aspectj/testing/harness/bridge/Globals.java b/testing/src/org/aspectj/testing/harness/bridge/Globals.java index f838a5637..9b0b7736c 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/Globals.java +++ b/testing/src/org/aspectj/testing/harness/bridge/Globals.java @@ -23,6 +23,7 @@ import org.aspectj.util.LangUtil; /** */ public class Globals { + public static final String FORK_NAME = "harness.fork"; // XXX in testing-drivers/../package.htm /** name/key of the System property to set to define library dir */ public static final String LIBDIR_NAME = "harness.libdir"; @@ -76,7 +77,7 @@ public class Globals { * @param defaultValue the String default value to return value is null or empty * @return String value or defaultValue if not available. */ - private static String getSystemProperty( + static String getSystemProperty( String propertyName, String defaultValue) { String result = defaultValue; |