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;
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);
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)) {
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
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;
}
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)) {
* {@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>
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;
}
/** 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 + " ")
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;
}
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