bodewig 02/04/12 08:08:18
Modified: docs/manual/CoreTypes filelist.html
src/main/org/apache/tools/ant/taskdefs Ant.java
src/main/org/apache/tools/ant/taskdefs/compilers
CompilerAdapterFactory.java
src/main/org/apache/tools/ant/taskdefs/optional/junit
JUnitTask.java JUnitTest.java
Log:
finally, 7552 audit of <junit> - leave information in tests untouched
by cloning the instances.
Revision Changes Path
1.7 +1 -1 jakarta-ant/docs/manual/CoreTypes/filelist.html
Index: filelist.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTypes/filelist.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- filelist.html 12 Apr 2002 14:47:15 -0000 1.6
+++ filelist.html 12 Apr 2002 15:08:17 -0000 1.7
@@ -68,7 +68,7 @@
<p>Same files as the example above.</p>
<hr>
-<p align="center">Copyright © 2001 Apache Software Foundation. All
rights
+<p align="center">Copyright © 2001-2002 Apache Software Foundation. All
rights
Reserved.</p>
</body>
1.51 +2 -2
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
Index: Ant.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- Ant.java 12 Apr 2002 14:46:44 -0000 1.50
+++ Ant.java 12 Apr 2002 15:08:17 -0000 1.51
@@ -135,7 +135,7 @@
* inside the ant call itself
*/
public void setInheritAll(boolean value) {
- inheritAll = value;
+ inheritAll = value;
}
/**
@@ -144,7 +144,7 @@
* inside the ant call itself
*/
public void setInheritRefs(boolean value) {
- inheritRefs = value;
+ inheritRefs = value;
}
/**
1.7 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
Index: CompilerAdapterFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CompilerAdapterFactory.java 12 Apr 2002 14:46:45 -0000 1.6
+++ CompilerAdapterFactory.java 12 Apr 2002 15:08:17 -0000 1.7
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
1.39 +229 -106
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Index: JUnitTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- JUnitTask.java 8 Mar 2002 11:16:14 -0000 1.38
+++ JUnitTask.java 12 Apr 2002 15:08:17 -0000 1.39
@@ -67,6 +67,7 @@
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.util.FileUtils;
import java.io.File;
import java.io.FileOutputStream;
@@ -76,7 +77,6 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
-import java.util.Random;
import java.util.Vector;
import java.net.URL;
@@ -88,7 +88,8 @@
* created by Erich Gamma and Kent Beck. JUnit can be found at <a
* href="http://www.junit.org">http://www.junit.org</a>.
*
- * <p> <code>JUnitTask</code> can run a single specific
<code>JUnitTest</code> using the <code>test</code> element.
+ * <p> <code>JUnitTask</code> can run a single specific
+ * <code>JUnitTest</code> using the <code>test</code> element.</p>
* For example, the following target <code><pre>
* <target name="test-int-chars" depends="jar-test">
* <echo message="testing international characters"/>
@@ -98,14 +99,19 @@
* <test name="org.apache.ecs.InternationalCharTest" />
* </junit>
* </target>
- * </pre></code> runs a single junit test
(<code>org.apache.ecs.InternationalCharTest</code>)
- * in the current VM using the path with id <code>classpath</code> as
classpath
- * and presents the results formatted using the standard <code>plain</code>
formatter on the command line.
+ * </pre></code>
+ * <p>runs a single junit test
+ * (<code>org.apache.ecs.InternationalCharTest</code>) in the current
+ * VM using the path with id <code>classpath</code> as classpath and
+ * presents the results formatted using the standard
+ * <code>plain</code> formatter on the command line.</p>
*
- * <p> This task can also run batches of tests.
- * The <code>batchtest</code> element creates a <code>BatchTest</code> based
on a fileset.
- * This allows, for example, all classes found in directory to be run as
testcases.
- * For example, <code><pre>
+ * <p> This task can also run batches of tests. The
+ * <code>batchtest</code> element creates a <code>BatchTest</code>
+ * based on a fileset. This allows, for example, all classes found in
+ * directory to be run as testcases.</p>
+ *
+ * <p>For example,</p><code><pre>
* <target name="run-tests" depends="dump-info,compile-tests"
if="junit.present">
* <junit printsummary="no" haltonfailure="yes" fork="${junit.fork}">
* <jvmarg value="-classic"/>
@@ -119,29 +125,30 @@
* </batchtest>
* </junit>
* </target>
- * </pre></code> this target finds any classes with a <code>test</code>
directory anywhere in their path
- * (under the top <code>${tests.dir}</code>, of course) and creates
<code>JUnitTest</code>'s for each one.
+ * </pre></code>
+ * <p>this target finds any classes with a <code>test</code> directory
+ * anywhere in their path (under the top <code>${tests.dir}</code>, of
+ * course) and creates <code>JUnitTest</code>'s for each one.</p>
*
- * <p> Of course, <code><junit></code> and <code><batch></code>
elements can be combined
- * for more complex tests. For an example, see the ant
<code>build.xml</code> target <code>run-tests</code>
- * (the second example is an edited version).
+ * <p> Of course, <code><junit></code> and
+ * <code><batch></code> elements can be combined for more
+ * complex tests. For an example, see the ant <code>build.xml</code>
+ * target <code>run-tests</code> (the second example is an edited
+ * version).</p>
*
* <p> To spawn a new Java VM to prevent interferences between
- * different testcases, you need to enable <code>fork</code>.
- * A number of attributes and elements allow you to set up how this JVM runs.
- * <ul>
- * <li>[EMAIL PROTECTED] #setTimeout} property sets the maximum time allowed
before a test is 'timed out'
- * <li>[EMAIL PROTECTED] #setMaxmemory} property sets memory assignment for
the forked jvm
- * <li>[EMAIL PROTECTED] #setJvm} property allows the jvm to be specified
- * <li>The <code><jvmarg></code> element sets arguements to be passed
to the forked jvm
- * </ul>
+ * different testcases, you need to enable <code>fork</code>. A
+ * number of attributes and elements allow you to set up how this JVM
+ * runs.
* @author Thomas Haas
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Bailliez</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Gerrit Riessen</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Erik Hatcher</a>
*
- * @version $Revision: 1.38 $
+ * @version $Revision: 1.39 $
+ *
+ * @since Ant 1.2
*
* @see JUnitTest
* @see BatchTest
@@ -166,11 +173,16 @@
private Path antRuntimeClasses = null;
/**
- * Tells this task whether to smartly filter the stack frames of JUnit
testcase
- * errors and failures before reporting them. This property is applied
on all
- * BatchTest (batchtest) and JUnitTest (test) however it can possibly be
- * overridden by their own properties.
- * @param value <tt>false</tt> if it should not filter, otherwise
<tt>true<tt>
+ * Tells this task whether to smartly filter the stack frames of
+ * JUnit testcase errors and failures before reporting them.
+ *
+ * <p>This property is applied on all BatchTest (batchtest) and
+ * JUnitTest (test) however it can possibly be overridden by their
+ * own properties.</p>
+ * @param value <tt>false</tt> if it should not filter, otherwise
+ * <tt>true<tt>
+ *
+ * @since Ant 1.5
*/
public void setFiltertrace(boolean value) {
Enumeration enum = allTests();
@@ -181,10 +193,14 @@
}
/**
- * Tells this task to halt when there is an error in a test.
- * this property is applied on all BatchTest (batchtest) and JUnitTest
(test)
- * however it can possibly be overridden by their own properties.
- * @param value <tt>true</tt> if it should halt, otherwise
<tt>false</tt>
+ * Tells this task to halt when there is an error in a test. this
+ * property is applied on all BatchTest (batchtest) and JUnitTest
+ * (test) however it can possibly be overridden by their own
+ * properties.
+ * @param value <tt>true</tt> if it should halt, otherwise
+ * <tt>false</tt>
+ *
+ * @since Ant 1.2
*/
public void setHaltonerror(boolean value) {
Enumeration enum = allTests();
@@ -195,10 +211,16 @@
}
/**
- * Tells this task to set the named property to "true" when there is a
error in a test.
- * This property is applied on all BatchTest (batchtest) and JUnitTest
(test),
- * however, it can possibly be overriden by their own properties.
- * @param propertyName the name of the property to set in the event of
an error.
+ * Tells this task to set the named property to "true" when there
+ * is a error in a test.
+ *
+ * <p>This property is applied on all BatchTest (batchtest) and
+ * JUnitTest (test), however, it can possibly be overriden by
+ * their own properties.</p>
+ * @param propertyName the name of the property to set in the
+ * event of an error.
+ *
+ * @since Ant 1.4
*/
public void setErrorProperty(String propertyName) {
Enumeration enum = allTests();
@@ -210,9 +232,13 @@
/**
* Tells this task to halt when there is a failure in a test.
- * this property is applied on all BatchTest (batchtest) and JUnitTest
(test)
- * however it can possibly be overridden by their own properties.
- * @param value <tt>true</tt> if it should halt, otherwise
<tt>false</tt>
+ * this property is applied on all BatchTest (batchtest) and
+ * JUnitTest (test) however it can possibly be overridden by their
+ * own properties.
+ * @param value <tt>true</tt> if it should halt, otherwise
+ * <tt>false</tt>
+ *
+ * @since Ant 1.2
*/
public void setHaltonfailure(boolean value) {
Enumeration enum = allTests();
@@ -223,10 +249,16 @@
}
/**
- * Tells this task to set the named property to "true" when there is a
failure in a test.
- * This property is applied on all BatchTest (batchtest) and JUnitTest
(test),
- * however, it can possibly be overriden by their own properties.
- * @param propertyName the name of the property to set in the event of
an failure.
+ * Tells this task to set the named property to "true" when there
+ * is a failure in a test.
+ *
+ * <p>This property is applied on all BatchTest (batchtest) and
+ * JUnitTest (test), however, it can possibly be overriden by
+ * their own properties.</p>
+ * @param propertyName the name of the property to set in the
+ * event of an failure.
+ *
+ * @since Ant 1.4
*/
public void setFailureProperty(String propertyName) {
Enumeration enum = allTests();
@@ -237,12 +269,17 @@
}
/**
- * Tells whether a JVM should be forked for each testcase. It avoids
interference
- * between testcases and possibly avoids hanging the build.
- * this property is applied on all BatchTest (batchtest) and JUnitTest
(test)
- * however it can possibly be overridden by their own properties.
- * @param value <tt>true</tt> if a JVM should be forked, otherwise
<tt>false</tt>
+ * Tells whether a JVM should be forked for each testcase.
+ *
+ * <p>It avoids interference between testcases and possibly avoids
+ * hanging the build. this property is applied on all BatchTest
+ * (batchtest) and JUnitTest (test) however it can possibly be
+ * overridden by their own properties.</p>
+ * @param value <tt>true</tt> if a JVM should be forked, otherwise
+ * <tt>false</tt>
* @see #setTimeout
+ *
+ * @since Ant 1.2
*/
public void setFork(boolean value) {
Enumeration enum = allTests();
@@ -253,11 +290,14 @@
}
/**
- * Tells whether the task should print a short summary of the task.
+ * Tells whether the task should print a short summary of the
+ * task.
* @param value <tt>true</tt> to print a summary,
- * <tt>withOutAndErr</tt> to include the test's output as
- * well, <tt>false</tt> otherwise.
+ * <tt>withOutAndErr</tt> to include the test's output as
+ * well, <tt>false</tt> otherwise.
* @see SummaryJUnitResultFormatter
+ *
+ * @since Ant 1.2
*/
public void setPrintsummary(SummaryAttribute value) {
summaryValue = value.getValue();
@@ -283,11 +323,15 @@
}
/**
- * Set the timeout value (in milliseconds). If the test is running for
more than this
- * value, the test will be canceled. (works only when in 'fork' mode).
- * @param value the maximum time (in milliseconds) allowed before
declaring the test
- * as 'timed-out'
+ * Set the timeout value (in milliseconds).
+ *
+ * <p>If the test is running for more than this value, the test
+ * will be canceled. (works only when in 'fork' mode).</p>
+ * @param value the maximum time (in milliseconds) allowed before
+ * declaring the test as 'timed-out'
* @see #setFork(boolean)
+ *
+ * @since 1.2
*/
public void setTimeout(Integer value) {
timeout = value;
@@ -297,19 +341,20 @@
* Set the maximum memory to be used by all forked JVMs.
* @param max the value as defined by <tt>-mx</tt> or <tt>-Xmx</tt>
* in the java command line options.
+ *
+ * @since 1.2
*/
public void setMaxmemory(String max) {
- if (Project.getJavaVersion().startsWith("1.1")) {
- createJvmarg().setValue("-mx"+max);
- } else {
- createJvmarg().setValue("-Xmx"+max);
- }
+ commandline.setMaxmemory(max);
}
/**
- * Set a new VM to execute the testcase. Default is <tt>java</tt>.
Ignored if no JVM is forked.
+ * Set a new VM to execute the testcase. Default is
+ * <tt>java</tt>. Ignored if no JVM is forked.
* @param value the new VM to use instead of <tt>java</tt>
* @see #setFork(boolean)
+ *
+ * @since 1.2
*/
public void setJvm(String value) {
commandline.setVm(value);
@@ -317,8 +362,11 @@
/**
* Create a new JVM argument. Ignored if no JVM is forked.
- * @return create a new JVM argument so that any argument can be passed
to the JVM.
+ * @return create a new JVM argument so that any argument can be
+ * passed to the JVM.
* @see #setFork(boolean)
+ *
+ * @since 1.2
*/
public Commandline.Argument createJvmarg() {
return commandline.createVmArgument();
@@ -328,6 +376,8 @@
* The directory to invoke the VM in. Ignored if no JVM is forked.
* @param dir the directory to invoke the JVM from.
* @see #setFork(boolean)
+ *
+ * @since 1.2
*/
public void setDir(File dir) {
this.dir = dir;
@@ -336,6 +386,8 @@
/**
* Add a nested sysproperty element. This might be useful to tranfer
* Ant properties to the testcases when JVM forking is not enabled.
+ *
+ * @since 1.3
*/
public void addSysproperty(Environment.Variable sysp) {
commandline.addSysproperty(sysp);
@@ -343,6 +395,8 @@
/**
* <code><classpath></code> allows classpath to be set for tests.
+ *
+ * @since 1.2
*/
public Path createClasspath() {
return commandline.createClasspath(project).createPath();
@@ -351,9 +405,9 @@
/**
* Add a nested env element - an environment variable.
*
- * <p>Will be ignored if we are not forking a new VM.
+ * <p>Will be ignored if we are not forking a new VM.</p>
*
- * @since 1.33, Ant 1.5
+ * @since Ant 1.5
*/
public void addEnv(Environment.Variable var) {
env.addVariable(var);
@@ -362,9 +416,9 @@
/**
* Use a completely new environment.
*
- * <p>Will be ignored if we are not forking a new VM.
+ * <p>Will be ignored if we are not forking a new VM.</p>
*
- * @since 1.33, Ant 1.5
+ * @since Ant 1.5
*/
public void setNewenvironment(boolean newenv) {
newEnvironment = newenv;
@@ -374,15 +428,20 @@
* Add a new single testcase.
* @param test a new single testcase
* @see JUnitTest
+ *
+ * @since 1.2
*/
public void addTest(JUnitTest test) {
tests.addElement(test);
}
/**
- * Create a new set of testcases (also called ..batchtest) and add it to
the list.
+ * Create a new set of testcases (also called ..batchtest) and add
+ * it to the list.
* @return a new instance of a batch test.
* @see BatchTest
+ *
+ * @since 1.2
*/
public BatchTest createBatchTest() {
BatchTest test = new BatchTest(project);
@@ -392,6 +451,8 @@
/**
* Add a new formatter to all tests of this task.
+ *
+ * @since 1.2
*/
public void addFormatter(FormatterElement fe) {
formatters.addElement(fe);
@@ -400,7 +461,7 @@
/**
* Whether to include ant.jar, optional.jar and junit.jar in the forked
VM.
*
- * @since 1.37, Ant 1.5
+ * @since Ant 1.5
*/
public void setIncludeantruntime(boolean b) {
includeAntRuntime = b;
@@ -408,15 +469,20 @@
/**
* Creates a new JUnitRunner and enables fork of a new Java VM.
+ *
+ * @since 1.2
*/
public JUnitTask() throws Exception {
-
commandline.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner");
+ commandline
+
.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner");
}
/**
* Adds the jars or directories containing Ant, this task and
* JUnit to the classpath - this should make the forked JVM work
* without having to specify them directly.
+ *
+ * @since 1.4
*/
public void init() {
antRuntimeClasses = new Path(getProject());
@@ -427,6 +493,8 @@
/**
* Runs the testcase.
+ *
+ * @since 1.2
*/
public void execute() throws BuildException {
Enumeration list = getIndividualTests();
@@ -441,7 +509,8 @@
/**
* Run the tests.
*/
- protected void execute(JUnitTest test) throws BuildException {
+ protected void execute(JUnitTest arg) throws BuildException {
+ JUnitTest test = (JUnitTest) arg.clone();
// set the default values if not specified
//@todo should be moved to the test class instead.
if (test.getTodir() == null) {
@@ -466,8 +535,8 @@
}
}
- // if there is an error/failure and that it should halt, stop
everything otherwise
- // just log a statement
+ // if there is an error/failure and that it should halt, stop
+ // everything otherwise just log a statement
boolean errorOccurredHere = exitValue == JUnitTestRunner.ERRORS;
boolean failureOccurredHere = exitValue != JUnitTestRunner.SUCCESS;
if (errorOccurredHere || failureOccurredHere) {
@@ -480,10 +549,10 @@
log("TEST "+test.getName()+" FAILED"
+ (wasKilled ? " (timeout)" : ""), Project.MSG_ERR);
if (errorOccurredHere && test.getErrorProperty() != null) {
- project.setProperty(test.getErrorProperty(), "true");
+ project.setNewProperty(test.getErrorProperty(), "true");
}
if (failureOccurredHere && test.getFailureProperty() !=
null) {
- project.setProperty(test.getFailureProperty(), "true");
+ project.setNewProperty(test.getFailureProperty(),
"true");
}
}
}
@@ -498,14 +567,17 @@
* exceeds a certain amount of time. Can be <tt>null</tt>, in this case
* the test could probably hang forever.
*/
- private int executeAsForked(JUnitTest test, ExecuteWatchdog watchdog)
throws BuildException {
+ private int executeAsForked(JUnitTest test, ExecuteWatchdog watchdog)
+ throws BuildException {
+
CommandlineJava cmd = (CommandlineJava) commandline.clone();
cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner");
cmd.createArgument().setValue(test.getName());
cmd.createArgument().setValue("filtertrace=" +
test.getFiltertrace());
cmd.createArgument().setValue("haltOnError=" +
test.getHaltonerror());
- cmd.createArgument().setValue("haltOnFailure=" +
test.getHaltonfailure());
+ cmd.createArgument().setValue("haltOnFailure="
+ + test.getHaltonfailure());
if (includeAntRuntime) {
log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH",
Project.MSG_VERBOSE);
@@ -515,7 +587,8 @@
if (summary) {
log("Running " + test.getName(), Project.MSG_INFO);
-
cmd.createArgument().setValue("formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter");
+ cmd.createArgument()
+
.setValue("formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter");
}
StringBuffer formatterArg = new StringBuffer(128);
@@ -533,9 +606,13 @@
formatterArg.setLength(0);
}
- // Create a temporary file to pass the Ant properties to the forked
test
- File propsFile = new File("junit" + (new
Random(System.currentTimeMillis())).nextLong() + ".properties");
- cmd.createArgument().setValue("propsfile=" +
propsFile.getAbsolutePath());
+ // Create a temporary file to pass the Ant properties to the
+ // forked test
+ File propsFile =
+ FileUtils.newFileUtils().createTempFile("junit", ".properties",
+ project.getBaseDir());
+ cmd.createArgument().setValue("propsfile="
+ + propsFile.getAbsolutePath());
Hashtable p = project.getProperties();
Properties props = new Properties();
for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) {
@@ -547,10 +624,15 @@
props.save(outstream,"Ant JUnitTask generated properties file");
outstream.close();
} catch (java.io.IOException e) {
- throw new BuildException("Error creating temporary properties
file.", e, location);
+ propsFile.delete();
+ throw new BuildException("Error creating temporary properties "
+ + "file.", e, location);
}
- Execute execute = new Execute(new LogStreamHandler(this,
Project.MSG_INFO, Project.MSG_WARN), watchdog);
+ Execute execute = new Execute(new LogStreamHandler(this,
+ Project.MSG_INFO,
+ Project.MSG_WARN),
+ watchdog);
execute.setCommandline(cmd.getCommandline());
execute.setAntRun(project);
if (dir != null) {
@@ -574,58 +656,73 @@
} catch (IOException e) {
throw new BuildException("Process fork failed.", e, location);
} finally {
- if (! propsFile.delete()) {
- throw new BuildException("Could not delete temporary properties
file.");
- }
+ if (!propsFile.delete()) {
+ throw new BuildException("Could not delete temporary "
+ + "properties file.");
+ }
}
return retVal;
}
- // in VM is not very nice since it could probably hang the
- // whole build. IMHO this method should be avoided and it would be best
- // to remove it in future versions. TBD. (SBa)
-
+ /**
+ * Pass output sent to System.out to the TestRunner so it can
+ * collect ot for the formatters.
+ *
+ * @since Ant 1.5
+ */
protected void handleOutput(String line) {
if (runner != null) {
runner.handleOutput(line);
- }
- else {
+ } else {
super.handleOutput(line);
}
}
+ /**
+ * Pass output sent to System.err to the TestRunner so it can
+ * collect ot for the formatters.
+ *
+ * @since Ant 1.5
+ */
protected void handleErrorOutput(String line) {
if (runner != null) {
runner.handleErrorOutput(line);
- }
- else {
+ } else {
super.handleErrorOutput(line);
}
}
+ // in VM is not very nice since it could probably hang the
+ // whole build. IMHO this method should be avoided and it would be best
+ // to remove it in future versions. TBD. (SBa)
+
/**
* Execute inside VM.
*/
- private int executeInVM(JUnitTest test) throws BuildException {
+ private int executeInVM(JUnitTest arg) throws BuildException {
+ JUnitTest test = (JUnitTest) arg.clone();
test.setProperties(project.getProperties());
if (dir != null) {
- log("dir attribute ignored if running in the same VM",
Project.MSG_WARN);
+ log("dir attribute ignored if running in the same VM",
+ Project.MSG_WARN);
}
if (newEnvironment || null != env.getVariables()) {
- log("Changes to environment variables are ignored if running in
the same VM.",
- Project.MSG_WARN);
+ log("Changes to environment variables are ignored if running in "
+ + "the same VM.", Project.MSG_WARN);
}
- CommandlineJava.SysProperties sysProperties =
commandline.getSystemProperties();
+ CommandlineJava.SysProperties sysProperties =
+ commandline.getSystemProperties();
if (sysProperties != null) {
sysProperties.setSystem();
}
AntClassLoader cl = null;
try {
- log("Using System properties " + System.getProperties(),
Project.MSG_VERBOSE);
+ log("Using System properties " + System.getProperties(),
+ Project.MSG_VERBOSE);
Path classpath = (Path) commandline.getClasspath().clone();
if (includeAntRuntime) {
log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH",
@@ -644,13 +741,16 @@
cl.addSystemPackageRoot("org.apache.tools.ant");
cl.setThreadContextLoader();
}
- runner = new JUnitTestRunner(test, test.getHaltonerror(),
test.getFiltertrace(), test.getHaltonfailure(), cl);
+ runner = new JUnitTestRunner(test, test.getHaltonerror(),
+ test.getFiltertrace(),
+ test.getHaltonfailure(), cl);
if (summary) {
log("Running " + test.getName(), Project.MSG_INFO);
- SummaryJUnitResultFormatter f =
- new SummaryJUnitResultFormatter();
- f.setWithOutAndErr( "withoutanderr".equalsIgnoreCase(
summaryValue ));
+ SummaryJUnitResultFormatter f =
+ new SummaryJUnitResultFormatter();
+ f.setWithOutAndErr("withoutanderr"
+ .equalsIgnoreCase( summaryValue ));
f.setOutput( getDefaultOutput() );
runner.addFormatter(f);
}
@@ -680,6 +780,8 @@
/**
* @return <tt>null</tt> if there is a timeout value, otherwise the
* watchdog instance.
+ *
+ * @since 1.2
*/
protected ExecuteWatchdog createWatchdog() throws BuildException {
if (timeout == null){
@@ -690,6 +792,8 @@
/**
* Get the default output for a formatter.
+ *
+ * @since 1.3
*/
protected OutputStream getDefaultOutput(){
return new LogOutputStream(this, Project.MSG_INFO);
@@ -698,6 +802,8 @@
/**
* Merge all individual tests from the batchtest with all individual
tests
* and return an enumeration over all <tt>JUnitTest</tt>.
+ *
+ * @since 1.3
*/
protected Enumeration getIndividualTests(){
final int count = batchTests.size();
@@ -710,11 +816,17 @@
return Enumerations.fromCompound(enums);
}
+ /**
+ * @since 1.3
+ */
protected Enumeration allTests() {
Enumeration[] enums = { tests.elements(), batchTests.elements() };
return Enumerations.fromCompound(enums);
}
+ /**
+ * @since 1.3
+ */
private FormatterElement[] mergeFormatters(JUnitTest test){
Vector feVector = (Vector)formatters.clone();
test.addFormattersTo(feVector);
@@ -723,7 +835,12 @@
return feArray;
}
- /** return the file or null if does not use a file */
+ /**
+ * If the formatter sends output to a file, return that file.
+ * null otherwise.
+ *
+ * @since 1.3
+ */
protected File getOutput(FormatterElement fe, JUnitTest test){
if (fe.getUseFile()) {
String filename = test.getOutfile() + fe.getExtension();
@@ -740,6 +857,8 @@
*
* <p>Doesn't work for archives in JDK 1.1 as the URL returned by
* getResource doesn't contain the name of the archive.</p>
+ *
+ * @since 1.4
*/
protected void addClasspathEntry(String resource) {
URL url = getClass().getResource(resource);
@@ -749,12 +868,16 @@
int pling = u.indexOf("!");
String jarName = u.substring(9, pling);
log("Found "+jarName, Project.MSG_DEBUG);
- antRuntimeClasses.createPath().setLocation(new File((new
File(jarName)).getAbsolutePath()));
+ antRuntimeClasses.createPath()
+ .setLocation(new File((new File(jarName))
+ .getAbsolutePath()));
} else if (u.startsWith("file:")) {
int tail = u.indexOf(resource);
String dirName = u.substring(5, tail);
log("Found "+dirName, Project.MSG_DEBUG);
- antRuntimeClasses.createPath().setLocation(new File((new
File(dirName)).getAbsolutePath()));
+ antRuntimeClasses.createPath()
+ .setLocation(new File((new File(dirName))
+ .getAbsolutePath()));
} else {
log("Don\'t know how to handle resource URL "+u,
Project.MSG_DEBUG);
1.11 +21 -5
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java
Index: JUnitTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JUnitTest.java 10 Jan 2002 13:59:37 -0000 1.10
+++ JUnitTest.java 12 Apr 2002 15:08:17 -0000 1.11
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,8 +56,6 @@
import org.apache.tools.ant.Project;
-
-
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
@@ -73,10 +71,12 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>,
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Bailliez</a>
*
+ * @since Ant 1.2
+ *
* @see JUnitTask
* @see JUnitTestRunner
*/
-public class JUnitTest extends BaseTest {
+public class JUnitTest extends BaseTest implements Cloneable {
/** the name of the test case */
private String name = null;
@@ -100,7 +100,8 @@
this.name = name;
}
- public JUnitTest(String name, boolean haltOnError, boolean
haltOnFailure, boolean filtertrace) {
+ public JUnitTest(String name, boolean haltOnError, boolean
haltOnFailure,
+ boolean filtertrace) {
this.name = name;
this.haltOnError = haltOnError;
this.haltOnFail = haltOnFailure;
@@ -185,6 +186,21 @@
final int count = formatters.size();
for (int i = 0; i < count; i++){
v.addElement( formatters.elementAt(i) );
+ }
+ }
+
+ /**
+ * @since Ant 1.5
+ */
+ public Object clone() {
+ try {
+ JUnitTest t = (JUnitTest) super.clone();
+ t.props = props == null ? null : (Properties) props.clone();
+ t.formatters = (Vector) formatters.clone();
+ return t;
+ } catch (CloneNotSupportedException e) {
+ // plain impossible
+ return this;
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>