source: main/trunk/ant-tasks/build.xml@ 21422

Last change on this file since 21422 was 20204, checked in by oranfry, 15 years ago

added more tests to dcff task

File size: 4.8 KB
Line 
1<project name="compile-ant-tasks" default="compile">
2
3 <condition property="libs.set">
4 <and>
5 <isset property="crypt.jar"/>
6 </and>
7 </condition>
8
9 <target name="compile" depends="check-libs">
10
11 <mkdir dir="classes"/>
12 <javac
13 srcdir="src/org/greenstone/anttasks"
14 destdir="classes"
15 classpath="${crypt.jar}"/>
16
17 <jar
18 destfile="anttasks.jar"
19 basedir="classes"/>
20
21 </target>
22
23 <target name="clean">
24 <delete dir="classes"/>
25 <delete file="anttasks.jar"/>
26 </target>
27
28 <target name="check-libs" unless="libs.set">
29 <echo>Please set crypt.jar property to the path of the crypt.jar file</echo>
30 <echo>E.g., ant -Dcrypt.jar=/path/to/crypt.jar</echo>
31 <fail>paths to libs not set</fail>
32 </target>
33
34 <target name="test-setup">
35 <path id="test.classpath">
36 <pathelement path="anttasks.jar"/>
37 <pathelement path="${crypt.jar}"/>
38 </path>
39 <typedef name="dcff" classname="org.greenstone.anttasks.DeleteChunkFromFile" classpathref="test.classpath"/>
40 <typedef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="test.classpath"/>
41 <typedef name="gpv" classname="org.greenstone.anttasks.GetPropertyValue" classpathref="test.classpath"/>
42 <mkdir dir="test"/>
43 </target>
44
45 <target name="test" depends="test-setup">
46 <antcall target="test-rsr"/>
47 <antcall target="test-dcff"/>
48 <antcall target="test-gpv"/>
49 </target>
50
51 <target name="test-rsr" depends="test-setup">
52
53 <!-- test 1 -->
54 <copy file="src/test/rsr.txt" tofile="test/rsr1.txt"/>
55 <rsr file="test/rsr1.txt" pattern="things" replacement="strings"/>
56
57 <!-- test 2 -->
58 <copy file="src/test/rsr.txt" tofile="test/rsr2.txt"/>
59 <rsr file="test/rsr2.txt">
60 <job pattern="things" replacement="objects"/>
61 <job pattern="Or" replacement="And"/>
62 </rsr>
63
64 <!-- test 3 -->
65 <copy file="src/test/rsr.txt" tofile="test/rsr3.txt"/>
66 <rsr file="test/rsr3.txt" pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
67 <rsr file="test/rsr3.txt" pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
68
69 <!-- test 4 -->
70 <copy file="src/test/rsr.txt" tofile="test/rsr4.txt"/>
71 <rsr file="test/rsr4.txt">
72 <job pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
73 <job pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
74 </rsr>
75
76 <!-- test 5 -->
77 <copy file="src/test/rsr.txt" tofile="test/rsr5-1.txt"/>
78 <copy file="src/test/rsr.txt" tofile="test/rsr5-2.txt"/>
79 <rsr>
80 <fileset dir="test" includes="rsr5-*"/>
81 <job pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
82 <job pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
83 </rsr>
84
85 <!-- test 6 -->
86 <copy file="src/test/rsr.txt" tofile="test/rsr6-1.txt"/>
87 <copy file="src/test/rsr.txt" tofile="test/rsr6-2.txt"/>
88 <copy file="src/test/rsr.txt" tofile="test/rsr6-3.txt"/>
89 <copy file="src/test/rsr.txt" tofile="test/rsr6-4.txt"/>
90 <rsr file="test/rsr6-1.txt" pattern="e" replacement="*" lines="8"/>
91 <rsr file="test/rsr6-2.txt" pattern="e" replacement="*" lines="4-9"/>
92 <rsr file="test/rsr6-3.txt" pattern="e" replacement="*" lines="-8"/>
93 <rsr file="test/rsr6-4.txt" pattern="e" replacement="*" lines="4-"/>
94
95 </target>
96
97 <target name="test-dcff" depends="test-setup">
98
99 <!-- test 1 -->
100 <copy file="src/test/dcff.txt" tofile="test/dcff1.txt"/>
101 <dcff file="test/dcff1.txt" startTag="The" endTag="brown" leaveTags="true"/>
102
103 <!-- test 2 -->
104 <copy file="src/test/dcff.txt" tofile="test/dcff2.txt"/>
105 <dcff file="test/dcff2.txt" startTag="quick" endTag="brown"/>
106
107 <!-- test 3 -->
108 <copy file="src/test/dcff.txt" tofile="test/dcff3.txt"/>
109 <dcff file="test/dcff3.txt" startTag="fox" leaveTags="true"/>
110
111 <!-- test 4 -->
112 <copy file="src/test/dcff.txt" tofile="test/dcff4.txt"/>
113 <dcff file="test/dcff4.txt" startTag="&lt;!--start--&gt;" endTag="&lt;!--end--&gt;"/>
114
115 <!-- test 5 -->
116 <copy file="src/test/dcff.txt" tofile="test/dcff5.txt"/>
117 <dcff file="test/dcff5.txt" startTag="&lt;!--\s*if\s*(?!.*linux)[^ ]+\s*--&gt;" endTag="&lt;!--\s*/if\s*--&gt;" />
118
119
120 </target>
121
122 <target name="test-gpv" depends="test-setup">
123
124 <!-- test 1 -->
125 <gpv propertiesFile="src/test/gpv.txt" propertyName="startmenu.path" outputProperty="gpv.startmenu.path"/>
126 <echo>startmenu.path = '${gpv.startmenu.path}'</echo>
127
128 <gpv propertiesFile="src/test/gpv.txt" propertyName="my.second.property" outputProperty="gpv.my.second.property"/>
129 <echo>my.second.property = '${gpv.my.second.property}'</echo>
130
131
132 </target>
133
134 <target name="test-win-sevenzip" depends="test-setup">
135
136 <!-- test 1 -->
137 <copy file="src/test/sevenzip.lzma" tofile="test/sevenzip1.lzma"/>
138 <sevenzip task="decode" input="test/sevenzip1.lzma" output="test/sevenzip1.comp"/>
139
140 </target>
141
142 <target name="test-clean">
143 <delete dir="test"/>
144 </target>
145
146</project>
Note: See TracBrowser for help on using the repository browser.