aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwisberg <wisberg>2003-08-28 18:28:43 +0000
committerwisberg <wisberg>2003-08-28 18:28:43 +0000
commit0f8a362edf5e81909bf782b667b213a6da3df0b2 (patch)
tree44f9e703821e7aa255784063aba4595054e2a928
parent31c52df57dbc34ebea91712d236a096f67153201 (diff)
downloadaspectj-0f8a362edf5e81909bf782b667b213a6da3df0b2.tar.gz
aspectj-0f8a362edf5e81909bf782b667b213a6da3df0b2.zip
implementing clone() for test specifications
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java64
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/AjcTest.java21
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java48
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java20
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/JavaRun.java16
5 files changed, 166 insertions, 3 deletions
diff --git a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java
index 3eef0679e..c14f53aa7 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java
@@ -92,7 +92,7 @@ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHa
private BitSet skipSet;
private boolean skipAll;
- protected final String xmlElementName;
+ protected String xmlElementName; // nonfinal only for clone()
protected final ArrayList /*String*/ keywords;
protected final IMessageHolder /*IMessage*/ messages;
protected final ArrayList /*String*/ options;
@@ -107,7 +107,7 @@ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHa
public final RT runtime;
/** if true, then any child skip causes this to skip */
- protected final boolean skipIfAnyChildSkipped;
+ protected boolean skipIfAnyChildSkipped; // nonfinal only for cloning
public AbstractRunSpec(String xmlElementName) {
this(xmlElementName, true);
@@ -735,6 +735,50 @@ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHa
return result.toString();
}
+ protected void initClone(AbstractRunSpec spec)
+ throws CloneNotSupportedException {
+ /*
+ * clone associated objects only if not (used as?) read-only.
+ */
+ spec.badInput = badInput;
+ spec.children.clear();
+ for (Iterator iter = children.iterator(); iter.hasNext();) {
+ // clone these...
+ IRunSpec child = (IRunSpec) iter.next();
+ // require all child classes to support clone?
+ if (child instanceof AbstractRunSpec) {
+ spec.addChild((AbstractRunSpec) ((AbstractRunSpec) child).clone());
+ } else {
+ throw new Error("unable to clone " + child);
+ }
+ }
+ spec.comment = comment;
+ spec.description = description;
+ spec.dirChanges.clear();
+ spec.dirChanges.addAll(dirChanges);
+ spec.isStaging = spec.isStaging;
+ spec.keywords.clear();
+ spec.keywords.addAll(keywords);
+ spec.messages.clearMessages();
+ MessageUtil.handleAll(spec.messages, messages, false);
+ spec.options.clear();
+ spec.options.addAll(options);
+ spec.paths.clear();
+ spec.paths.addAll(paths);
+ spec.runtime.copy(runtime);
+ spec.skipAll = skipAll;
+ spec.skipIfAnyChildSkipped = skipIfAnyChildSkipped;
+ if (null != skipSet) {
+ spec.skipSet = new BitSet();
+ spec.skipSet.or(skipSet);
+ }
+ spec.sourceLocation = sourceLocation;
+ spec.sourceLocations.clear();
+ spec.sourceLocations.addAll(sourceLocations);
+ spec.xmlElementName = xmlElementName;
+ spec.xmlNames = ((AbstractRunSpec.XMLNames) xmlNames.clone());
+ }
+
private static void addListCount(String name, List list, StringBuffer sink) {
int size = list.size();
if ((null != list) && (0 < size)) {
@@ -780,6 +824,22 @@ abstract public class AbstractRunSpec implements IRunSpec { // XXX use MessageHa
final boolean skipDirChanges;
final boolean skipMessages;
final boolean skipChildren;
+ protected Object clone() {
+ return new XMLNames(
+ null,
+ descriptionName,
+ sourceLocationName,
+ keywordsName,
+ optionsName,
+ pathsName,
+ commentName,
+ stagingName,
+ badInputName,
+ skipDirChanges,
+ skipMessages,
+ skipChildren);
+ }
+
// not runtime, skipAll, skipIfAnyChildSkipped, skipSet
// sourceLocations
/** reset all names/behavior or pass defaultNames
diff --git a/testing/src/org/aspectj/testing/harness/bridge/AjcTest.java b/testing/src/org/aspectj/testing/harness/bridge/AjcTest.java
index 4a521d890..e359389bf 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/AjcTest.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/AjcTest.java
@@ -247,6 +247,20 @@ public class AjcTest extends RunSpecIterator {
setXMLNames(NAMES);
}
+ protected void initClone(Spec spec)
+ throws CloneNotSupportedException {
+ super.initClone(spec);
+ spec.bugId = bugId;
+ spec.suiteDir = suiteDir;
+ spec.testDirOffset = testDirOffset;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ Spec result = new Spec();
+ initClone(result);
+ return result;
+ }
+
public void setSuiteDir(File suiteDir) {
this.suiteDir = suiteDir;
}
@@ -518,6 +532,13 @@ public class AjcTest extends RunSpecIterator {
super(XMLNAME, false); // do not skip this even if children skip
}
+ public Object clone() throws CloneNotSupportedException {
+ Spec spec = new Spec();
+ super.initClone(spec);
+ spec.suiteDir = suiteDir;
+ return spec;
+ }
+
/** @param suiteDirPath the String path to the base suite dir */
public void setSuiteDir(String suiteDirPath) {
if (!LangUtil.isEmpty(suiteDirPath)) {
diff --git a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java
index 680ecbea9..37d5ba9b5 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java
@@ -312,7 +312,7 @@ public class CompilerRun implements IAjcRun {
* {@link setupArgs(ArrayList, IMessageHandler}.</li>
* <li>construct a command line, using as classpath
* {@link Sandbox.classpathToString()}<li>
- * <li>construct a compiler using {@link Spec#compilerName}
+ * <li>construct a compiler using {@link Spec#compiler}
* or any overriding value set in TestSetup.<li>
* <li>Just before running, set the compiler in the sandbox using
* {@link Sandbox.setCompiler(ICommand)}.<li>
@@ -528,6 +528,38 @@ public class CompilerRun implements IAjcRun {
compiler = DEFAULT_COMPILER;
}
+ private static String[] copy(String[] input) {
+ if (null == input) {
+ return null;
+ }
+ String[] result = new String[input.length];
+ System.arraycopy(input, 0, result, 0, input.length);
+ return result;
+ }
+
+ protected void initClone(Spec spec)
+ throws CloneNotSupportedException {
+ super.initClone(spec);
+ spec.argfiles = copy(argfiles);
+ spec.aspectpath = copy(aspectpath);
+ spec.classpath = copy(classpath);
+ spec.compiler = compiler;
+ spec.includeClassesDir = includeClassesDir;
+ spec.reuseCompiler = reuseCompiler;
+ spec.sourceroots = copy(sourceroots);
+ spec.testSetup = null;
+ if (null != testSetup) {
+ spec.testSetup = (TestSetup) testSetup.clone();
+ }
+ spec.testSrcDirOffset = testSrcDirOffset;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ Spec result = new Spec();
+ initClone(result);
+ return result;
+ }
+
public void setIncludeClassesDir(boolean include) {
this.includeClassesDir = include;
}
@@ -1065,6 +1097,20 @@ public class CompilerRun implements IAjcRun {
/** if setup completed, this has the combined global/local options */
ArrayList commandOptions;
+ public Object clone() {
+ TestSetup testSetup = new TestSetup();
+ testSetup.compilerName = compilerName;
+ testSetup.ignoreWarnings = ignoreWarnings;
+ testSetup.ignoreWarningsSet = ignoreWarningsSet;
+ testSetup.result = result;
+ testSetup.failureReason = failureReason;
+ testSetup.seek = seek;
+ if (null != commandOptions) {
+ testSetup.commandOptions = new ArrayList();
+ testSetup.commandOptions.addAll(commandOptions);
+ }
+ return testSetup;
+ }
public String toString() {
return "TestSetup("
+ (null == compilerName ? "" : compilerName + " ")
diff --git a/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java b/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java
index b4302ac63..b06430e61 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java
@@ -299,6 +299,26 @@ public class IncCompilerRun implements IAjcRun {
classesUpdated = new ArrayList();
}
+ protected void initClone(Spec spec)
+ throws CloneNotSupportedException {
+ super.initClone(spec);
+ spec.fresh = fresh;
+ spec.tag = tag;
+ spec.classesAdded.clear();
+ spec.classesAdded.addAll(classesAdded);
+ spec.classesRemoved.clear();
+ spec.classesRemoved.addAll(classesRemoved);
+ spec.classesUpdated.clear();
+ spec.classesUpdated.addAll(classesUpdated);
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ Spec result = new Spec();
+ initClone(result);
+ return result;
+ }
+
+
public void setFresh(boolean fresh) {
this.fresh = fresh;
}
diff --git a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java
index 76785b464..21a67986c 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java
@@ -444,6 +444,22 @@ public class JavaRun implements IAjcRun {
setXMLNames(NAMES);
}
+ protected void initClone(Spec spec)
+ throws CloneNotSupportedException {
+ super.initClone(spec);
+ spec.className = className;
+ spec.errStreamIsError = errStreamIsError;
+ spec.javaVersion = javaVersion;
+ spec.outStreamIsError = outStreamIsError;
+ spec.skipTester = skipTester;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ Spec result = new Spec();
+ initClone(result);
+ return result;
+ }
+
/**
* @param version "1.1", "1.2", "1.3", "1.4"
* @throws IllegalArgumentException if version is not recognized