You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by an...@apache.org on 2014/04/07 05:06:15 UTC
svn commit: r1585377 - in /ant/core/trunk/src:
etc/testcases/taskdefs/optional/ etc/testcases/taskdefs/optional/antlr/
tests/junit/org/apache/tools/ant/taskdefs/optional/
Author: antoine
Date: Mon Apr 7 03:06:14 2014
New Revision: 1585377
URL: http://svn.apache.org/r1585377
Log:
changing tests to adopt unique temporary directories
Modified:
ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml
ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml
ant/core/trunk/src/etc/testcases/taskdefs/optional/xslt.xml
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml?rev=1585377&r1=1585376&r2=1585377&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml Mon Apr 7 03:06:14 2014
@@ -18,11 +18,10 @@
<project name="antlr-test" basedir="." default="test1">
- <property name="tmp.dir" location="antlr.tmp"/>
+ <import file="../../../buildfiletest-base.xml"/>
-
- <target name="setup">
- <mkdir dir="${tmp.dir}"/>
+ <target name="setUp">
+ <mkdir dir="${output}" />
</target>
<target name="test1">
@@ -30,17 +29,17 @@
</target>
<target name="test2">
- <antlr target="antlr.g" outputdirectory="${tmp.dir}"/>
+ <antlr target="antlr.g" outputdirectory="${output}"/>
</target>
- <target name="test3" depends="setup">
- <antlr target="antlr.g" outputdirectory="${tmp.dir}"/>
+ <target name="test3" depends="setUp">
+ <antlr target="antlr.g" outputdirectory="${output}"/>
<fail>
<condition>
<!-- to prove each of these files exists;
ANTLR >= 2.7.6 leaves behind new (.smap) files as well. -->
<resourcecount when="ne" count="5">
- <fileset dir="${tmp.dir}">
+ <fileset dir="${output}">
<include name="CalcParserTokenTypes.txt" />
<include name="CalcParserTokenTypes.java" />
<include name="CalcLexer.java" />
@@ -52,20 +51,20 @@
</fail>
</target>
- <target name="test4" depends="setup">
- <antlr target="java.g" outputdirectory="${tmp.dir}"/>
- <antlr dir="${tmp.dir}" target="java.tree.g" outputdirectory="${tmp.dir}"/>
+ <target name="test4" depends="setUp">
+ <antlr target="java.g" outputdirectory="${output}"/>
+ <antlr dir="${output}" target="java.tree.g" outputdirectory="${output}"/>
</target>
- <target name="test5" depends="setup">
- <antlr target="java.tree.g" outputdirectory="${tmp.dir}" fork="yes"/>
+ <target name="test5" depends="setUp">
+ <antlr target="java.tree.g" outputdirectory="${output}" fork="yes"/>
</target>
- <target name="test6" depends="setup">
- <antlr target="java.g" outputdirectory="${tmp.dir}" />
- <antlr dir="${tmp.dir}"
+ <target name="test6" depends="setUp">
+ <antlr target="java.g" outputdirectory="${output}" />
+ <antlr dir="${output}"
target="java.tree.g"
- outputdirectory="${tmp.dir}"
+ outputdirectory="${output}"
fork="yes"/>
</target>
@@ -73,58 +72,58 @@
<antlr target="antlr.xml"/>
</target>
- <target name="test8" depends="setup">
- <antlr target="extended.calc.g" outputdirectory="${tmp.dir}" glib="non-existent-file.g"/>
+ <target name="test8" depends="setUp">
+ <antlr target="extended.calc.g" outputdirectory="${output}" glib="non-existent-file.g"/>
</target>
- <target name="test9" depends="setup">
+ <target name="test9" depends="setUp">
<!-- Note that I had to copy the grammars over to the temporary directory. -->
<!-- This is because ANTLR expects the super grammar and its generated java -->
<!-- files to be in the same directory, which won't be the case if I use -->
<!-- the output directory option. -->
- <copy file="antlr.g" todir="${tmp.dir}"/>
- <copy file="extended.calc.g" todir="${tmp.dir}"/>
- <antlr target="${tmp.dir}/antlr.g"/>
- <antlr target="${tmp.dir}/extended.calc.g" glib="${tmp.dir}/antlr.g"/>
+ <copy file="antlr.g" todir="${output}"/>
+ <copy file="extended.calc.g" todir="${output}"/>
+ <antlr target="${output}/antlr.g"/>
+ <antlr target="${output}/extended.calc.g" glib="${output}/antlr.g"/>
</target>
- <target name="test10" depends="setup">
- <antlr target="antlr.g" outputdirectory="${tmp.dir}" html="yes"/>
+ <target name="test10" depends="setUp">
+ <antlr target="antlr.g" outputdirectory="${output}" html="yes"/>
</target>
- <target name="test11" depends="setup">
- <antlr target="antlr.g" outputdirectory="${tmp.dir}" diagnostic="yes"/>
+ <target name="test11" depends="setUp">
+ <antlr target="antlr.g" outputdirectory="${output}" diagnostic="yes"/>
</target>
- <target name="test12" depends="setup">
- <antlr target="antlr.g" outputdirectory="${tmp.dir}" trace="yes"/>
+ <target name="test12" depends="setUp">
+ <antlr target="antlr.g" outputdirectory="${output}" trace="yes"/>
</target>
- <target name="test13" depends="setup">
- <antlr target="antlr.g" outputdirectory="${tmp.dir}" traceLexer="yes" traceParser="yes" traceTreeWalker="yes"/>
+ <target name="test13" depends="setUp">
+ <antlr target="antlr.g" outputdirectory="${output}" traceLexer="yes" traceParser="yes" traceTreeWalker="yes"/>
</target>
<!-- test9 will have been run before that -->
<target name="noRecompile">
- <antlr target="${tmp.dir}/extended.calc.g" glib="${tmp.dir}/antlr.g"/>
+ <antlr target="${output}/extended.calc.g" glib="${output}/antlr.g"/>
</target>
<!-- test9 will have been run before that -->
<target name="normalRecompile">
<sleep seconds="2"/>
- <touch file="${tmp.dir}/extended.calc.g"/>
- <antlr target="${tmp.dir}/extended.calc.g" glib="${tmp.dir}/antlr.g"/>
+ <touch file="${output}/extended.calc.g"/>
+ <antlr target="${output}/extended.calc.g" glib="${output}/antlr.g"/>
</target>
<!-- test9 will have been run before that -->
<target name="supergrammarChangeRecompile">
<sleep seconds="2"/>
- <touch file="${tmp.dir}/antlr.g"/>
- <antlr target="${tmp.dir}/extended.calc.g" glib="${tmp.dir}/antlr.g"/>
+ <touch file="${output}/antlr.g"/>
+ <antlr target="${output}/extended.calc.g" glib="${output}/antlr.g"/>
</target>
- <target name="cleanup">
- <delete dir="${tmp.dir}" />
+ <target name="tearDown">
+ <delete dir="${output}" />
<delete file="../../../../../../CalcParserTokenTypes.txt"/>
</target>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml?rev=1585377&r1=1585376&r2=1585377&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml Mon Apr 7 03:06:14 2014
@@ -16,68 +16,68 @@
limitations under the License.
-->
<project name="test" default="def" basedir=".">
- <property name="tmpregexp" location="tmpregexp"/>
- <target name="def">
- <fail>This build file should only be run from within the testcase</fail>
+ <import file="../../buildfiletest-base.xml"/>
+
+ <property name="root" location="../../../../.."/>
+
+ <target name="setUp">
+ <mkdir dir="${output}" />
+ <copy file="replaceregexp.properties" tofile="${output}/test.properties" />
</target>
- <target name="setup">
- <copy file="replaceregexp.properties" tofile="test.properties" />
+ <target name="def">
+ <fail>This build file should only be run from within the testcase</fail>
</target>
- <target name="setup-nl">
- <copy file="replaceregexp2.properties" tofile="test.properties" />
+ <target name="setUp-nl">
+ <mkdir dir="${output}" />
+ <copy file="replaceregexp2.properties" tofile="${output}/test.properties" />
</target>
- <target name="testReplace" depends="setup">
- <replaceregexp file="test.properties" byline="true">
+ <target name="testReplace" depends="setUp">
+ <replaceregexp file="${output}/test.properties" byline="true">
<regexp pattern="Old(.*)=(.*)" />
<substitution expression="NewProp=\1\2" />
</replaceregexp>
</target>
<!-- use in conjunction with testDirectoryDateDoesNotChange to make sure something will happen -->
<target name="touchDirectory">
- <mkdir dir="${tmpregexp}"/>
- <copy file="replaceregexp.properties" tofile="${tmpregexp}/test.properties" />
+ <copy file="replaceregexp.properties" tofile="${output}/test.properties" />
<sleep seconds="2"/>
</target>
<target name="testDirectoryDateDoesNotChange">
- <replaceregexp file="${tmpregexp}/test.properties" byline="true">
+ <replaceregexp file="${output}/test.properties" byline="true">
<regexp pattern="foo" />
<substitution expression="bar"/>
</replaceregexp>
</target>
- <target name="testDontAddNewline1" depends="setup-nl">
- <replaceregexp file="test.properties" byline="false">
+ <target name="testDontAddNewline1" depends="setUp-nl">
+ <replaceregexp file="${output}/test.properties" byline="false">
<regexp pattern="Old(.*)=(.*)" />
<substitution expression="NewProp=\1\2" />
</replaceregexp>
</target>
- <target name="testDontAddNewline2" depends="setup-nl">
- <replaceregexp file="test.properties" byline="true">
+ <target name="testDontAddNewline2" depends="setUp-nl">
+ <replaceregexp file="${output}/test.properties" byline="true">
<regexp pattern="Old(.*)=(.*)" />
<substitution expression="NewProp=\1\2" />
</replaceregexp>
</target>
<target name="lastModifiedSetup">
- <mkdir dir="${tmpregexp}"/>
- <echo file="${tmpregexp}/test.txt">Hello, world!</echo>
+ <echo file="${output}/test.txt">Hello, world!</echo>
</target>
+
<target name="testNoPreserve">
- <replaceregexp match="world" replace="Ant" file="${tmpregexp}/test.txt"/>
+ <replaceregexp match="world" replace="Ant" file="${output}/test.txt"/>
</target>
+
<target name="testPreserve">
- <replaceregexp match="world" replace="Ant" file="${tmpregexp}/test.txt"
+ <replaceregexp match="world" replace="Ant" file="${output}/test.txt"
preserveLastModified="true"/>
</target>
- <target name="cleanup">
- <delete file="test.properties" />
- <delete dir="${tmpregexp}" quiet="true"/>
- </target>
-
</project>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/xslt.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/xslt.xml?rev=1585377&r1=1585376&r2=1585377&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/xslt.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/xslt.xml Mon Apr 7 03:06:14 2014
@@ -16,14 +16,17 @@
limitations under the License.
-->
-<project name="xslt" default="xslt" basedir=".">
- <property name="nonasciidir" value="xml/ãnt"/>
- <target name="init">
- <mkdir dir="xml/out"/>
+<project name="xslt" default="tearDown" basedir=".">
+
+ <import file="../../buildfiletest-base.xml"/>
+
+ <target name="setUp">
+ <mkdir dir="${output}" />
</target>
- <target name="initNonAscii">
- <mkdir dir="${nonasciidir}"/>
+ <target name="initNonAscii" depends="setUp">
+ <property name="nonasciidir" value="${output}/ãnt"/>
+ <mkdir dir="${nonasciidir}"/>
<copy todir="${nonasciidir}">
<fileset dir="xml">
<include name="docwithentity.xml"/>
@@ -32,13 +35,8 @@
</copy>
</target>
- <target name="teardown">
- <delete dir="xml/out"/>
- <delete dir="${nonasciidir}" quiet="true"/>
- </target>
-
- <target name="testCatchNoDtd" depends="init">
- <xslt basedir="xml" destdir="xml/out"
+ <target name="testCatchNoDtd" depends="setUp">
+ <xslt basedir="xml" destdir="${output}"
includes="about.xml"
extension=".txt"
style="xml/doc.xsl">
@@ -50,8 +48,8 @@
location="xml/doc.dtd"/>
</xmlcatalog>
- <target name="testCatalog" depends="init">
- <xslt destdir="xml/out"
+ <target name="testCatalog" depends="setUp">
+ <xslt destdir="${output}"
includes="about.xml"
extension=".txt"
style="xml/doc.xsl">
@@ -59,9 +57,9 @@
</xslt>
</target>
- <target name="testOutputProperty" depends="init">
+ <target name="testOutputProperty" depends="setUp">
<xslt in="xml/test.xml"
- out="xml/out/test-out.xml"
+ out="${output}/test-out.xml"
style="xml/test.xsl">
<outputproperty name="method" value="xml"/>
<outputproperty name="standalone" value="yes"/>
@@ -71,17 +69,17 @@
</target>
- <target name="testFactory" depends="init">
+ <target name="testFactory" depends="setUp">
<xslt in="xml/test.xml"
- out="xml/out/test-out.xml"
+ out="${output}/test-out.xml"
style="xml/test.xsl">
<factory name="org.apache.xalan.processor.TransformerFactoryImpl"/>
</xslt>
</target>
- <target name="testAttribute" depends="init">
+ <target name="testAttribute" depends="setUp">
<xslt in="xml/test.xml"
- out="xml/out/test-out.xml"
+ out="${output}/test-out.xml"
style="xml/test.xsl">
<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
<attribute name="http://xml.apache.org/xalan/features/optimize" value="true"/>
@@ -91,13 +89,13 @@
<!-- inspired by bug report 37348 -->
<target name="testXMLWithEntitiesInNonAsciiPath" depends="initNonAscii">
<xslt in="${nonasciidir}/docwithentity.xml"
- out="xml/out/test-out.xml"
+ out="${output}/test-out.xml"
style="xml/apache.xsl">
</xslt>
</target>
- <target name="testStyleSheetWithInclude" depends="init">
+ <target name="testStyleSheetWithInclude" depends="setUp">
<xslt in="xml/books.xml"
- out="xml/out/test-out.xml"
+ out="${output}/test-out.xml"
style="xml/stylesheet_with_include.xsl">
</xslt>
</target>
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java?rev=1585377&r1=1585376&r2=1585377&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java Mon Apr 7 03:06:14 2014
@@ -44,10 +44,6 @@ public class ANTLRTest extends BuildFile
configureProject(TASKDEFS_DIR + "antlr.xml");
}
- public void tearDown() {
- executeTarget("cleanup");
- }
-
public void test1() {
expectBuildException("test1", "required argument, target, missing");
}
@@ -99,8 +95,7 @@ public class ANTLRTest extends BuildFile
*/
public void test10() {
executeTarget("test10");
- File outputDirectory = new File(System.getProperty("root"), TASKDEFS_DIR + "antlr.tmp");
- String[] calcFiles = outputDirectory.list(new HTMLFilter());
+ String[] calcFiles = getOutputDir().list(new HTMLFilter());
assertTrue(calcFiles.length > 0);
}
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java?rev=1585377&r1=1585376&r2=1585377&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java Mon Apr 7 03:06:14 2014
@@ -41,15 +41,11 @@ public class ReplaceRegExpTest extends B
configureProject(PROJECT_PATH + "/replaceregexp.xml");
}
- public void tearDown() {
- executeTarget("cleanup");
- }
-
public void testReplace() throws IOException {
Properties original = new Properties();
FileInputStream propsFile = null;
try {
- propsFile = new FileInputStream(new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp.properties"));
+ propsFile = new FileInputStream(new File(project.getBaseDir() + "/replaceregexp.properties"));
original.load(propsFile);
} finally {
if (propsFile != null) {
@@ -64,7 +60,7 @@ public class ReplaceRegExpTest extends B
Properties after = new Properties();
try {
- propsFile = new FileInputStream(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"));
+ propsFile = new FileInputStream(new File(getOutputDir(), "test.properties"));
after.load(propsFile);
} finally {
if (propsFile != null) {
@@ -79,7 +75,7 @@ public class ReplaceRegExpTest extends B
// inspired by bug 22541
public void testDirectoryDateDoesNotChange() {
executeTarget("touchDirectory");
- File myFile = new File(System.getProperty("root"), PROJECT_PATH + "/" + getProject().getProperty("tmpregexp"));
+ File myFile = getOutputDir();
long timeStampBefore = myFile.lastModified();
executeTarget("testDirectoryDateDoesNotChange");
long timeStampAfter = myFile.lastModified();
@@ -90,34 +86,32 @@ public class ReplaceRegExpTest extends B
executeTarget("testDontAddNewline1");
assertTrue("Files match",
FILE_UTILS
- .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"),
- new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties")));
+ .contentEquals(new File(getOutputDir(), "test.properties"),
+ new File(getProjectDir(), "replaceregexp2.result.properties")));
}
public void testDontAddNewline2() throws IOException {
executeTarget("testDontAddNewline2");
assertTrue("Files match",
FILE_UTILS
- .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"),
- new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties")));
+ .contentEquals(new File(getOutputDir(), "test.properties"),
+ new File(getProjectDir(), "replaceregexp2.result.properties")));
}
public void testNoPreserveLastModified() throws Exception {
executeTarget("lastModifiedSetup");
- String tmpdir = project.getProperty("tmpregexp");
- long ts1 = new File(tmpdir, "test.txt").lastModified();
+ long ts1 = new File(getOutputDir(), "test.txt").lastModified();
Thread.sleep(3000);
executeTarget("testNoPreserve");
- assertTrue(ts1 < new File(tmpdir, "test.txt").lastModified());
+ assertTrue(ts1 < new File(getOutputDir(), "test.txt").lastModified());
}
public void testPreserveLastModified() throws Exception {
executeTarget("lastModifiedSetup");
- String tmpdir = project.getProperty("tmpregexp");
- long ts1 = new File(tmpdir, "test.txt").lastModified();
+ long ts1 = new File(getOutputDir(), "test.txt").lastModified();
Thread.sleep(3000);
executeTarget("testPreserve");
- assertTrue(ts1 == new File(tmpdir, "test.txt").lastModified());
+ assertTrue(ts1 == new File(getOutputDir(), "test.txt").lastModified());
}
}// ReplaceRegExpTest
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java?rev=1585377&r1=1585376&r2=1585377&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java Mon Apr 7 03:06:14 2014
@@ -50,14 +50,6 @@ public class XsltTest extends BuildFileT
}
- /**
- * The teardown method for JUnit
- */
- public void tearDown() {
- executeTarget("teardown");
- }
-
-
/**
* A unit test for JUnit
@@ -79,16 +71,6 @@ public class XsltTest extends BuildFileT
executeTarget("testOutputProperty");
}
- /* Only runs if xalan.jar is in CP (not incl. Sun's JRE repackaging):
- public void testFactory() throws Exception {
- executeTarget("testFactory");
- }
-
- public void testAttribute() throws Exception {
- executeTarget("testAttribute");
- }
- */
-
public void testXMLWithEntitiesInNonAsciiPath() throws Exception {
executeTarget("testXMLWithEntitiesInNonAsciiPath");
}