Browse Source

Enable previously disabled head-tail tests.

Make StripJavaComments recognize and retain Mac line endings.

PR: 18476

Submitted by: peter.reilly@corvil.com (peter reilly)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274506 13f79535-47bb-0310-9956-ffa450edef68
master
Magesh Umasankar 22 years ago
parent
commit
9eb6d592ed
4 changed files with 29 additions and 16 deletions
  1. +0
    -1
      build.xml
  2. +24
    -0
      src/etc/testcases/filters/head-tail.xml
  3. +1
    -7
      src/main/org/apache/tools/ant/filters/StripJavaComments.java
  4. +4
    -8
      src/testcases/org/apache/tools/ant/filters/HeadTailTest.java

+ 0
- 1
build.xml View File

@@ -277,7 +277,6 @@
<patternset id="teststhatfail"> <patternset id="teststhatfail">
<exclude name="${optional.package}/BeanShellScriptTest.java"/> <exclude name="${optional.package}/BeanShellScriptTest.java"/>
<exclude name="${ant.package}/taskdefs/ImportTest.java"/> <exclude name="${ant.package}/taskdefs/ImportTest.java"/>
<!-- <exclude name="${ant.package}/filters/HeadTailTest.java"/> -->
</patternset> </patternset>


<!-- <!--


+ 24
- 0
src/etc/testcases/filters/head-tail.xml View File

@@ -43,6 +43,18 @@
</copy> </copy>
</target> </target>


<target name="testFilterReaderHeadLinesSkip" depends="init">
<copy file="input/head-tail.test"
tofile="result/head-tail.filterReaderHeadLinesSkip.test">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.HeadFilter">
<param name="lines" value="2"/>
<param name="skip" value="2"/>
</filterreader>
</filterchain>
</copy>
</target>

<target name="testHeadAllSkip" depends="init"> <target name="testHeadAllSkip" depends="init">
<copy file="input/head-tail.test" tofile="result/head-tail.headAllSkip.test"> <copy file="input/head-tail.test" tofile="result/head-tail.headAllSkip.test">
<filterchain> <filterchain>
@@ -85,6 +97,18 @@
</copy> </copy>
</target> </target>


<target name="testFilterReaderTailLinesSkip" depends="init">
<copy file="input/head-tail.test"
tofile="result/head-tail.filterReaderTailLinesSkip.test">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.TailFilter">
<param name="lines" value="2"/>
<param name="skip" value="2"/>
</filterreader>
</filterchain>
</copy>
</target>

<target name="testTailAllSkip" depends="init"> <target name="testTailAllSkip" depends="init">
<copy file="input/head-tail.test" tofile="result/head-tail.tailAllSkip.test"> <copy file="input/head-tail.test" tofile="result/head-tail.tailAllSkip.test">
<filterchain> <filterchain>


+ 1
- 7
src/main/org/apache/tools/ant/filters/StripJavaComments.java View File

@@ -132,15 +132,9 @@ public final class StripJavaComments
if (ch == '/') { if (ch == '/') {
ch = in.read(); ch = in.read();
if (ch == '/') { if (ch == '/') {
int prevCh = -1;
while (ch != '\n' && ch != -1) {
prevCh = ch;
while (ch != '\n' && ch != -1 && ch != '\r') {
ch = in.read(); ch = in.read();
} }
if ( ch == '\n' && prevCh == '\r' ) {
readAheadCh = ch;
ch = prevCh;
}
} else if (ch == '*') { } else if (ch == '*') {
while (ch != -1) { while (ch != -1) {
ch = in.read(); ch = in.read();


+ 4
- 8
src/testcases/org/apache/tools/ant/filters/HeadTailTest.java View File

@@ -112,19 +112,17 @@ public class HeadTailTest extends BuildFileTest {
assertTrue("testHeadLinesSkip: Result not like expected", fu.contentEquals(expected, result)); assertTrue("testHeadLinesSkip: Result not like expected", fu.contentEquals(expected, result));
} }


/*
public void testFilterReaderHeadLinesSkip() throws IOException { public void testFilterReaderHeadLinesSkip() throws IOException {
executeTarget("testFilterReaderHeadLinesSkip"); executeTarget("testFilterReaderHeadLinesSkip");
File expected = getProject().resolveFile( File expected = getProject().resolveFile(
"expected/head-tail.filterReaderHeadLinesSkip.test");
"expected/head-tail.headLinesSkip.test");
File result = getProject().resolveFile( File result = getProject().resolveFile(
"result/head-tail.headLinesSkip.test");
"result/head-tail.filterReaderHeadLinesSkip.test");
FileUtils fu = FileUtils.newFileUtils(); FileUtils fu = FileUtils.newFileUtils();
assertTrue("testFilterReaderHeadLinesSkip: Result not like expected", assertTrue("testFilterReaderHeadLinesSkip: Result not like expected",
fu.contentEquals(expected, result)); fu.contentEquals(expected, result));
} }


*/
public void testTail() throws IOException { public void testTail() throws IOException {
executeTarget("testTail"); executeTarget("testTail");
File expected = getProject().resolveFile("expected/head-tail.tail.test"); File expected = getProject().resolveFile("expected/head-tail.tail.test");
@@ -157,18 +155,16 @@ public class HeadTailTest extends BuildFileTest {
assertTrue("testTailLinesSkip: Result not like expected", fu.contentEquals(expected, result)); assertTrue("testTailLinesSkip: Result not like expected", fu.contentEquals(expected, result));
} }


/*
public void testFilterReaderTailLinesSkip() throws IOException { public void testFilterReaderTailLinesSkip() throws IOException {
executeTarget("testFilterReaderTailLinesSkip"); executeTarget("testFilterReaderTailLinesSkip");
File expected = getProject().resolveFile( File expected = getProject().resolveFile(
"expected/head-tail.filterReaderTailLinesSkip.test");
"expected/head-tail.tailLinesSkip.test");
File result = getProject().resolveFile( File result = getProject().resolveFile(
"result/head-tail.tailLinesSkip.test");
"result/head-tail.filterReaderTailLinesSkip.test");
FileUtils fu = FileUtils.newFileUtils(); FileUtils fu = FileUtils.newFileUtils();
assertTrue("testFilterReaderTailLinesSkip: Result not like expected", assertTrue("testFilterReaderTailLinesSkip: Result not like expected",
fu.contentEquals(expected, result)); fu.contentEquals(expected, result));
} }
*/


public void testHeadTail() throws IOException { public void testHeadTail() throws IOException {
executeTarget("testHeadTail"); executeTarget("testHeadTail");


Loading…
Cancel
Save