Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /antelope/src/test/

antelope
Discussion topic

Back to topic list

CVS update: /antelope/src/test/

Author danson
Full name Dale Anson
Date 2005-10-21 12:00:43 PDT
Message User: danson
Date: 2005/10/21 12:00:43

Modified:
   antelope/src/test/sp​lit_test.xml

Log:
 updated tests for SplitTask.
 
 Issue number:
 Obtained from:
 Submitted by:
 Reviewed by:

File Changes:

Directory: /antelope/src/test/
==============================

File [changed]: split_test.xml
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/test/s​plit_test.xml?r1=1.1​&r2=1.2
Delta lines: +122 -26
----------------------
--- split_test.xml 21 Oct 2005 03:47:45 -0000 1.1
+++ split_test.xml 21 Oct 2005 19:00:41 -0000 1.2
@@ -13,11 +13,11 @@
       <property name="prop1" value="ABCDE"/>
       <a:split property="prop1" bytes="1" outputdir="${out_dir}"/>
       <a:fileutil file="${out_dir}" property="file_count">
- <a:filecount/>
+ <filecount/>
       </a:fileutil>
       <a:assert message="Expected 5 files, got ${file_count}">
          <bool>
- <a:mathequals arg1="5" arg2="${file_count}"/>
+ <mathequals arg1="5" arg2="${file_count}"/>
          </bool>
       </a:assert>
    </target>
@@ -38,7 +38,7 @@
          
          <!-- count the parts -->
          <a:fileutil file="${out_dir}" property="file_count">
- <a:filecount/>
+ <filecount/>
          </a:fileutil>
          
          <!-- calculate how many parts there should be -->
@@ -46,28 +46,28 @@
             <a:filelength/>
          </a:fileutil>
          <a:math result="split_size">
- <a:op op="ceil">
- <a:op op="/">
- <a:num value="${ant_size}"/>
- <a:num value="${piece_size}"/>
- </a:op>
- </a:op>
+ <op op="ceil">
+ <op op="/">
+ <num value="${ant_size}"/>
+ <num value="${piece_size}"/>
+ </op>
+ </op>
          </a:math>
          
          <!-- make sure there are the right number of parts -->
          <a:assert message="Expected ${split_size} files, got ${file_count}">
             <bool>
- <a:mathequals arg1="${split_size}" arg2="${file_count}"/>
+ <mathequals arg1="${split_size}" arg2="${file_count}"/>
             </bool>
          </a:assert>
 
          <!-- sort the filenames of the parts so concat puts them together in
          the right order-->
          <a:fileutil file="${out_dir}" property="file_list">
- <a:listfiles includepath="no"/>
+ <listfiles includepath="no"/>
          </a:fileutil>
          <a:stringutil string="${file_list}" property="file_list">
- <a:sort/>
+ <sort/>
          </a:stringutil>
          
          <!-- put them back together -->
@@ -100,39 +100,39 @@
          
          <!-- count the parts -->
          <a:fileutil file="${out_dir}" property="file_count">
- <a:filecount/>
+ <filecount/>
          </a:fileutil>
          
          <!-- calculate how many parts there should be -->
          <a:fileutil file="${ant.jar}" property="ant_size">
- <a:filelength/>
+ <filelength/>
          </a:fileutil>
          <a:math result="split_size">
- <a:op op="ceil">
- <a:op op="/">
- <a:num value="${ant_size}"/>
- <a:op op="*">
- <a:num value="100"/>
- <a:num value="1024"/>
- </a:op>
- </a:op>
- </a:op>
+ <op op="ceil">
+ <op op="/">
+ <num value="${ant_size}"/>
+ <op op="*">
+ <num value="100"/>
+ <num value="1024"/>
+ </op>
+ </op>
+ </op>
          </a:math>
          
          <!-- make sure there are the right number of parts -->
          <a:assert message="Expected ${split_size} files, got ${file_count}">
             <bool>
- <a:mathequals arg1="${split_size}" arg2="${file_count}"/>
+ <mathequals arg1="${split_size}" arg2="${file_count}"/>
             </bool>
          </a:assert>
 
          <!-- sort the filenames of the parts so concat puts them together in
          the right order-->
          <a:fileutil file="${out_dir}" property="file_list">
- <a:listfiles includepath="no"/>
+ <listfiles includepath="no"/>
          </a:fileutil>
          <a:stringutil string="${file_list}" property="file_list">
- <a:sort/>
+ <sort/>
          </a:stringutil>
          
          <!-- put them back together -->
@@ -146,6 +146,102 @@
                <filesmatch file1="${ant.jar}" file2="${out_dir}/ant.jar"/>
             </bool>
          </a:assert>
+ </a:if>
+ </target>
+
+ <!--
+ Similar to test 2, but using lines.
+ -->
+ <target name="test4" depends="clean">
+ <!-- make sure Ant's build.xml is available -->
+ <property name="ant.build.xml" value="${ant.home}/​build.xml"/>
+ <available property="ant.build.​xml.available" file="${ant.build.xml}"/>
+
+ <a:if name="ant.build.xml.available" value="true">
+ <!-- Ant's build.xml generally runs around 1700 lines, use 100 lines
+ per file -->
+ <a:unset name="piece_size"/>
+ <property name="piece_size" value="100"/>
+ <a:split file="${ant.build.xml}" lines="${piece_size}" outputdir="${out_dir}" prefix="ant.build.xml"/>
+
+ <!-- count the parts -->
+ <a:fileutil file="${out_dir}" property="file_count">
+ <filecount/>
+ </a:fileutil>
+
+ <!-- calculate how many parts there should be -->
+ <a:fileutil file="${ant.build.xml}" property="line_count">
+ <linecount/>
+ </a:fileutil>
+ <a:math result="split_size">
+ <op op="ceil">
+ <op op="/">
+ <num value="${line_count}"/>
+ <num value="${piece_size}"/>
+ </op>
+ </op>
+ </a:math>
+
+ <!-- make sure there are the right number of parts -->
+ <a:assert message="Expected ${split_size} files, got ${file_count}">
+ <bool>
+ <mathequals arg1="${split_size}" arg2="${file_count}"/>
+ </bool>
+ </a:assert>
+
+ <!-- sort the filenames of the parts so concat puts them together in
+ the right order-->
+ <a:fileutil file="${out_dir}" property="file_list">
+ <listfiles includepath="no"/>
+ </a:fileutil>
+ <a:stringutil string="${file_list}" property="file_list">
+ <sort/>
+ </a:stringutil>
+
+ <!-- put them back together -->
+ <concat destfile="${out_dir​}/ant.build.xml">​
+ <filelist dir="${out_dir}" files="${file_list}"/>
+ </concat>
+
+ <!-- make sure the new file is similar to the original. It may be
+ different since the line separator used in the original may not be
+ the same as the new one. Line count should be the same. -->
+ <a:fileutil file="${out_dir}/ant.build.xml" property="new_line_count">
+ <linecount/>
+ </a:fileutil>
+ <a:assert message="concat did not produce similar file">
+ <bool>
+ <mathequals arg1="${line_count}" arg2="${new_line_count}"/>
+ </bool>
+ </a:assert>
+
+ <!-- the original and the new should have the same number of bytes,
+ plus or minus the line count (that is, there could be an extra byte
+ per line in either the original or the new if DOS line enders were
+ used in one and Unix/Mac line enders in the other) -->
+ <a:fileutil file="${ant.build.xml}" property="original_length">
+ <filelength/>
+ </a:fileutil>
+ <a:fileutil file="${out_dir}/ant.build.xml" property="new_length">
+ <filelength/>
+ </a:fileutil>
+ <a:math result="difference">
+ <op op="abs">
+ <op op="-">
+ <num value="${original_length}"/>
+ <num value="${new_length}"/>
+ </op>
+ </op>
+ </a:math>
+ <a:assert message="File size difference is outside of tolerance.">
+ <bool>
+ <or>
+ <islessthan arg1="${difference}" arg2="${line_count}"/>
+ <mathequals arg1="${difference}" arg2="${line_count}"/>
+ </or>
+ </bool>
+ </a:assert>
+
       </a:if>
    </target>

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /antelope/src/test/ danson Dale Anson 2005-10-21 12:00:43 PDT
Messages per page: