18 |
18 |
19 Description: |
19 Description: |
20 |
20 |
21 ============================================================================ |
21 ============================================================================ |
22 --> |
22 --> |
|
23 <!--* @package framework --> |
23 <project name="internal.testing" xmlns:au="org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium"> |
24 <project name="internal.testing" xmlns:au="org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium"> |
24 <description> |
25 <description> |
25 Targets to test Helium itself. |
26 Targets to test Helium itself. |
26 </description> |
27 </description> |
27 <import file="${helium.dir}/build-jar.ant.xml"/> |
28 |
28 |
|
29 <fileset id="python.files" dir="${helium.dir}"> |
|
30 <include name="tools/**/*.py"/> |
|
31 <include name="extensions/nokia/tools/**/*.py"/> |
|
32 <exclude name="tools/startup/bootstrap/site.py"/> |
|
33 </fileset> |
|
34 |
|
35 <!-- Runs all the unit testing targets. --> |
29 <!-- Runs all the unit testing targets. --> |
36 <target name="unittest" depends="ju-unittest,check,ant-unittest,py-unittest"/> |
30 <target name="unittest" depends="ju-unittest,ant-unittest,py-unittest"/> |
37 |
31 |
38 <!-- Unit testing --> |
32 <!-- Unit testing --> |
39 |
33 |
40 <!-- Setup environment for Python unit tests --> |
34 <!-- Setup environment for Python unit tests. --> |
41 <target name="setup-py-unittest"> |
35 <target name="setup-py-unittest"> |
42 <!-- Autogenerate test data for ArchivePreBuilderTest based on ANT properties --> |
36 <!-- Autogenerate test data for ArchivePreBuilderTest based on ANT properties --> |
43 <if> |
37 <if> |
44 <available file="${helium.dir}/tests/data/archive_test.cfg.xml"/> |
38 <available file="${helium.dir}/tests/data/archive_test.cfg.xml"/> |
45 <then> |
39 <then> |
53 </copy> |
47 </copy> |
54 </target> |
48 </target> |
55 |
49 |
56 <!-- Do Python tests. --> |
50 <!-- Do Python tests. --> |
57 <target name="do-py-unittest" depends="setup-py-unittest"> |
51 <target name="do-py-unittest" depends="setup-py-unittest"> |
58 <property name="nose.args" value="nokiatest test"/> |
52 <property name="nose.args" value="nokiacpythontest scripttests"/> |
59 <exec executable="python" failonerror="true"> |
53 <exec executable="python" failonerror="true"> |
|
54 <env key="TEST_DATA" value="${helium.dir}/tests"/> |
60 <arg line="${python.tools}/coverage.py -x ${python.tools}/nosetests-script.py -v ${nose.args}"/> |
55 <arg line="${python.tools}/coverage.py -x ${python.tools}/nosetests-script.py -v ${nose.args}"/> |
61 </exec> |
56 </exec> |
|
57 <script language="jython" setbeans="false"> |
|
58 import sys |
|
59 import os |
|
60 os.putenv('TEST_DATA', os.path.join(os.environ['HELIUM_HOME'], 'tests')) |
|
61 sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'external/python/lib/common/nose-0.11.1-py2.6.egg')) |
|
62 sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'external/python/lib/common/mocker-0.10.1-py2.5.egg')) |
|
63 import nose |
|
64 args = project.getProperty('nose.args') |
|
65 if ' ' in args: |
|
66 nose.run(argv=['-v', 'scripttests']) |
|
67 elif 'cpython' not in args: |
|
68 nose.run(argv=['-v', args]) |
|
69 print >> sys.stderr |
|
70 </script> |
62 </target> |
71 </target> |
63 |
72 |
64 <!-- Shortcut for Python unit tests. --> |
73 <!-- Shortcut for Python unit tests. --> |
65 <target name="pt" depends="do-py-unittest"/> |
74 <target name="pt" depends="do-py-unittest"/> |
66 |
75 |
67 |
76 |
68 <!-- Create Python code coverage statistics. --> |
77 <!-- Create Python code coverage statistics. --> |
69 <target name="py-unittest-coverage"> |
78 <target name="py-unittest-coverage"> |
70 <mkdir dir="${helium.dir}/build/coverage"/> |
79 <mkdir dir="${helium.build.dir}/coverage"/> |
71 <pathconvert pathsep=" " property="python.modules.coverage"> |
80 <pathconvert pathsep=" " property="python.modules.coverage"> |
72 <fileset refid="python.files"/> |
81 <fileset dir="${helium.dir}"> |
|
82 <include name="tools/**/*.py"/> |
|
83 <include name="extensions/nokia/tools/**/*.py"/> |
|
84 <exclude name="tools/startup/bootstrap/site.py"/> |
|
85 </fileset> |
73 </pathconvert> |
86 </pathconvert> |
74 <exec executable="python" failonerror="true"> |
87 <exec executable="python" failonerror="true"> |
75 <arg line="${python.tools}/coverage.py -a -d ${helium.dir}/build/coverage ${python.modules.coverage}"/> |
88 <arg line="${python.tools}/coverage.py -a -d ${helium.build.dir}/coverage ${python.modules.coverage}"/> |
76 </exec> |
89 </exec> |
77 |
90 |
78 <!-- backup the old line coverage report and create the new one --> |
91 <!-- backup the old line coverage report and create the new one --> |
79 <mkdir dir="${helium.dir}/build/coverage/report"/> |
92 <mkdir dir="${helium.build.dir}/coverage/report"/> |
80 <if> |
93 <if> |
81 <available file="${helium.dir}/build/coverage/report/line_coverage.txt"/> |
94 <available file="${helium.build.dir}/coverage/report/line_coverage.txt"/> |
82 <then> |
95 <then> |
83 <copy file="${helium.dir}/build/coverage/report/line_coverage.txt" tofile="${helium.dir}/build/coverage/report/line_coverage_old.txt" overwrite="true"/> |
96 <copy file="${helium.build.dir}/coverage/report/line_coverage.txt" tofile="${helium.build.dir}/coverage/report/line_coverage_old.txt" overwrite="true"/> |
84 </then> |
97 </then> |
85 </if> |
98 </if> |
86 <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="start"/> |
99 <hlm:record name="${helium.build.dir}/coverage/report/line_coverage.txt" action="start"/> |
87 <exec executable="python" failonerror="true"> |
100 <exec executable="python" failonerror="true"> |
88 <arg line="${python.tools}/coverage.py -r ${python.modules.coverage}"/> |
101 <arg line="${python.tools}/coverage.py -r ${python.modules.coverage}"/> |
89 </exec> |
102 </exec> |
90 <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="stop"/> |
103 <hlm:record name="${helium.build.dir}/coverage/report/line_coverage.txt" action="stop"/> |
91 <replace file="${helium.dir}/build/coverage/report/line_coverage.txt"> |
104 <replace file="${helium.build.dir}/coverage/report/line_coverage.txt"> |
92 <replacetoken><![CDATA[[exec]]]></replacetoken> |
105 <replacetoken><![CDATA[[exec]]]></replacetoken> |
93 <replacevalue><![CDATA[]]></replacevalue> |
106 <replacevalue><![CDATA[]]></replacevalue> |
94 </replace> |
107 </replace> |
95 <hlm:python> |
108 <hlm:python> |
96 for line in open(r'${helium.dir}/build/coverage/report/line_coverage.txt'): |
109 for line in open(r'${helium.build.dir}/coverage/report/line_coverage.txt'): |
97 if 'TOTAL' in line and '0%' in line: |
110 if 'TOTAL' in line and ' 0%' in line: |
98 raise Exception('Coverage at 0%') |
111 raise Exception('Coverage at 0%') |
99 </hlm:python> |
112 </hlm:python> |
100 <delete file="${helium.dir}/.coverage"/> |
113 <delete file="${helium.dir}/.coverage"/> |
101 </target> |
114 </target> |
102 |
115 |
106 |
119 |
107 |
120 |
108 <!-- Run Ant unit tests. --> |
121 <!-- Run Ant unit tests. --> |
109 <target name="ant-unittest"> |
122 <target name="ant-unittest"> |
110 <mkdir dir="${helium.build.dir}/temp"/> |
123 <mkdir dir="${helium.build.dir}/temp"/> |
|
124 <mkdir dir="${helium.build.dir}/report/antunit"/> |
111 <au:antunit> |
125 <au:antunit> |
|
126 <propertyset> |
|
127 <propertyref name="cache.dir"/> |
|
128 </propertyset> |
112 <fileset dir="${helium.dir}" includes="tools/**/test_*.ant.xml"/> |
129 <fileset dir="${helium.dir}" includes="tools/**/test_*.ant.xml"/> |
113 <fileset dir="${helium.dir}" includes="extensions/nokia/tools/**/test_*.ant.xml"/> |
130 <fileset dir="${helium.dir}" includes="extensions/nokia/tools/**/test_*.ant.xml"/> |
114 <au:plainlistener/> |
131 <au:plainlistener/> |
|
132 <au:xmllistener toDir="${helium.build.dir}/report/antunit"/> |
115 </au:antunit> |
133 </au:antunit> |
116 </target> |
134 </target> |
117 |
135 |
118 |
136 |
119 <!-- Run JUnit unit tests. --> |
137 <!-- Run JUnit unit tests. --> |
120 <target name="ju-unittest" depends="build-java-src"> |
138 <target name="ju-unittest" depends="build-java-src"> |
121 <!-- Source location for test class --> |
139 <!-- Source location for test class --> |
|
140 <!-- Source location for junit test class. |
|
141 @type string |
|
142 @scope private |
|
143 --> |
122 <property name="src" location="tools/common/java/test" /> |
144 <property name="src" location="tools/common/java/test" /> |
123 <!-- Source classes location --> |
145 <!-- Source classes location --> |
|
146 <!-- Java source files location for helium library. |
|
147 @type string |
|
148 @scope private |
|
149 --> |
124 <property name="src.classes" location="tools/common/java/src" /> |
150 <property name="src.classes" location="tools/common/java/src" /> |
125 |
151 |
126 <delete dir="${build.temp.dir}/junit_classes"/> |
152 <delete dir="${build.temp.dir}/junit_classes"/> |
127 <mkdir dir="${build.temp.dir}/junit_classes" /> |
153 <mkdir dir="${build.temp.dir}/junit_classes" /> |
128 |
154 |
161 <include name="**/*Test*.java"/> |
187 <include name="**/*Test*.java"/> |
162 </fileset> |
188 </fileset> |
163 </batchtest> |
189 </batchtest> |
164 </junit> |
190 </junit> |
165 |
191 |
166 <emma enabled="true" > |
192 <emma enabled="true"> |
167 <report> |
193 <report> |
|
194 <sourcepath> |
|
195 <dirset dir="${src.classes}" /> |
|
196 </sourcepath> |
168 <infileset dir="${build.temp.dir}" includes="*.emma" /> |
197 <infileset dir="${build.temp.dir}" includes="*.emma" /> |
169 <txt outfile="${build.temp.dir}/coverage.txt" /> |
198 <txt outfile="${build.temp.dir}/coverage.txt" depth="method" /> |
170 <html outfile="${build.temp.dir}/coverage.html" /> |
199 <html outfile="${build.temp.dir}/coverage.html" /> |
171 </report> |
200 </report> |
172 </emma> |
201 </emma> |
173 <loadfile property="message" srcFile="${build.temp.dir}/coverage.txt"/> |
202 <loadfile property="message" srcFile="${build.temp.dir}/coverage.txt"/> |
174 <echo message="${message}"/> |
203 <echo message="${message}"/> |
175 </target> |
204 </target> |
176 |
|
177 |
|
178 <!-- iMaker Helium feature unittesting. --> |
|
179 <target name="imaker-unittest" depends="rombuild-export-features"> |
|
180 <property name="imaker.unittest.args" value="" /> |
|
181 <for param="unittest.filename"> |
|
182 <path> |
|
183 <fileset dir="${build.drive}/epoc32/rom/config/unittest" casesensitive="yes"> |
|
184 <include name="**/test_*.mk"/> |
|
185 </fileset> |
|
186 </path> |
|
187 <sequential> |
|
188 <echo>Running @{unittest.filename}</echo> |
|
189 <exec executable="${imaker.command}" dir="${build.drive}/"> |
|
190 <arg line="${imaker.unittest.args}"/> |
|
191 <arg line="-f @{unittest.filename}"/> |
|
192 <arg value="unittest"/> |
|
193 </exec> |
|
194 </sequential> |
|
195 </for> |
|
196 </target> |
|
197 |
|
198 <!-- Validates XML files against suitable schema or DTDs. --> |
|
199 <target name="validate-xml"> |
|
200 <!--<schemavalidate fullchecking="false" noNamespaceFile="tools/common/schema/ant.xsd"> |
|
201 <Schema namespace="ant.apache.org" |
|
202 file="tools/common/schema/ant.xsd" /> |
|
203 <schema namespace="http://www.nokia.com/helium" |
|
204 file="tools/common/schema/helium_ant.xsd" /> |
|
205 <fileset dir="tools"> |
|
206 <include name="**/build.xml"/> |
|
207 <include name="**/*.ant.xml"/> |
|
208 <exclude name="**/test_*.ant.xml"/> |
|
209 </fileset> |
|
210 </schemavalidate>--> |
|
211 <schemavalidate noNamespaceFile="tools/common/schema/helium_data_model.xsd" |
|
212 file="${data.model.file}"/> |
|
213 <!--<schemavalidate noNamespaceFile="tools/common/schema/helium_config.xsd"> |
|
214 <fileset dir="testconfig"> |
|
215 <include name="**/delivery.xml"/> |
|
216 <include name="**/*.cfg.xml"/> |
|
217 <exclude name="**/test_*.ant.xml"/> |
|
218 </fileset> |
|
219 </schemavalidate>--> |
|
220 </target> |
|
221 |
|
222 |
205 |
223 </project> |
206 </project> |