buildframework/helium/tools/common/testing.ant.xml
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
child 217 0f5e3a7fb6af
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
    22 -->
    22 -->
    23 <project name="internal.testing" xmlns:au="org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium"> 
    23 <project name="internal.testing" xmlns:au="org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium"> 
    24     <description>
    24     <description>
    25         Targets to test Helium itself.
    25         Targets to test Helium itself.
    26     </description>
    26     </description>
    27     <import file="${helium.dir}/build-jar.ant.xml"/>
       
    28     
    27     
    29     <fileset id="python.files" dir="${helium.dir}">
    28     <fileset id="python.files" dir="${helium.dir}">
    30         <include name="tools/**/*.py"/>
    29         <include name="tools/**/*.py"/>
    31         <include name="extensions/nokia/tools/**/*.py"/>
    30         <include name="extensions/nokia/tools/**/*.py"/>
    32         <exclude name="tools/startup/bootstrap/site.py"/>
    31         <exclude name="tools/startup/bootstrap/site.py"/>
    53         </copy>
    52         </copy>
    54     </target>
    53     </target>
    55 
    54 
    56     <!-- Do Python tests. -->
    55     <!-- Do Python tests. -->
    57     <target name="do-py-unittest" depends="setup-py-unittest">
    56     <target name="do-py-unittest" depends="setup-py-unittest">
    58         <property name="nose.args" value="nokiatest test"/>
    57         <property name="nose.args" value="cpythontest nokiacpythontest nokiatest test"/>
    59         <exec executable="python" failonerror="true">
    58         <exec executable="python" failonerror="true">
    60             <arg line="${python.tools}/coverage.py -x ${python.tools}/nosetests-script.py -v ${nose.args}"/>
    59             <arg line="${python.tools}/coverage.py -x ${python.tools}/nosetests-script.py -v ${nose.args}"/>
    61         </exec>
    60         </exec>
       
    61         <script language="jython" setbeans="false">
       
    62 import sys
       
    63 import os
       
    64 sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'external/python/lib/common/nose-0.11.1-py2.6.egg'))
       
    65 sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'external/python/lib/common/mocker-0.10.1-py2.5.egg'))
       
    66 import nose
       
    67 args = project.getProperty('nose.args')
       
    68 if args == 'cpythontest nokiacpythontest nokiatest test':
       
    69     nose.run(argv=['-v', os.path.join(os.environ['HELIUM_HOME'], 'tools/common/python/lib/test'), 'nokiatest'])
       
    70 elif args.startswith('nokiatest.') or args.startswith('test.'):
       
    71     nose.run(argv=['-v', args])
       
    72 print >> sys.stderr
       
    73         </script>
    62     </target>
    74     </target>
    63     
    75     
    64     <!-- Shortcut for Python unit tests. -->
    76     <!-- Shortcut for Python unit tests. -->
    65     <target name="pt" depends="do-py-unittest"/>
    77     <target name="pt" depends="do-py-unittest"/>
    66     
    78     
    67         
    79         
    68     <!-- Create Python code coverage statistics. -->
    80     <!-- Create Python code coverage statistics. -->
    69     <target name="py-unittest-coverage">
    81     <target name="py-unittest-coverage">
    70         <mkdir dir="${helium.dir}/build/coverage"/>
    82         <mkdir dir="${helium.build.dir}/coverage"/>
    71         <pathconvert pathsep=" " property="python.modules.coverage">
    83         <pathconvert pathsep=" " property="python.modules.coverage">
    72             <fileset refid="python.files"/>
    84             <fileset refid="python.files"/>
    73         </pathconvert>
    85         </pathconvert>
    74         <exec executable="python" failonerror="true">
    86         <exec executable="python" failonerror="true">
    75             <arg line="${python.tools}/coverage.py -a -d ${helium.dir}/build/coverage ${python.modules.coverage}"/>
    87             <arg line="${python.tools}/coverage.py -a -d ${helium.build.dir}/coverage ${python.modules.coverage}"/>
    76         </exec>
    88         </exec>
    77                         
    89                         
    78         <!-- backup the old line coverage report and create the new one -->
    90         <!-- backup the old line coverage report and create the new one -->
    79         <mkdir dir="${helium.dir}/build/coverage/report"/>        
    91         <mkdir dir="${helium.build.dir}/coverage/report"/>        
    80         <if>
    92         <if>
    81             <available file="${helium.dir}/build/coverage/report/line_coverage.txt"/>
    93             <available file="${helium.build.dir}/coverage/report/line_coverage.txt"/>
    82             <then>
    94             <then>
    83                 <copy file="${helium.dir}/build/coverage/report/line_coverage.txt" tofile="${helium.dir}/build/coverage/report/line_coverage_old.txt" overwrite="true"/>
    95                 <copy file="${helium.build.dir}/coverage/report/line_coverage.txt" tofile="${helium.build.dir}/coverage/report/line_coverage_old.txt" overwrite="true"/>
    84             </then>    
    96             </then>    
    85         </if>        
    97         </if>        
    86         <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="start"/>        
    98         <hlm:record name="${helium.build.dir}/coverage/report/line_coverage.txt" action="start"/>        
    87         <exec executable="python" failonerror="true">
    99         <exec executable="python" failonerror="true">
    88             <arg line="${python.tools}/coverage.py -r ${python.modules.coverage}"/>
   100             <arg line="${python.tools}/coverage.py -r ${python.modules.coverage}"/>
    89         </exec>
   101         </exec>
    90         <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="stop"/>
   102         <hlm:record name="${helium.build.dir}/coverage/report/line_coverage.txt" action="stop"/>
    91         <replace file="${helium.dir}/build/coverage/report/line_coverage.txt">
   103         <replace file="${helium.build.dir}/coverage/report/line_coverage.txt">
    92             <replacetoken><![CDATA[[exec]]]></replacetoken>
   104             <replacetoken><![CDATA[[exec]]]></replacetoken>
    93             <replacevalue><![CDATA[]]></replacevalue>
   105             <replacevalue><![CDATA[]]></replacevalue>
    94         </replace>
   106         </replace>
    95         <hlm:python>
   107         <hlm:python>
    96 for line in open(r'${helium.dir}/build/coverage/report/line_coverage.txt'):
   108 for line in open(r'${helium.build.dir}/coverage/report/line_coverage.txt'):
    97     if 'TOTAL' in line and '0%' in line:
   109     if 'TOTAL' in line and ' 0%' in line:
    98         raise Exception('Coverage at 0%')
   110         raise Exception('Coverage at 0%')
    99         </hlm:python>
   111         </hlm:python>
   100         <delete file="${helium.dir}/.coverage"/>
   112         <delete file="${helium.dir}/.coverage"/>
   101     </target>
   113     </target>
   102     
   114     
   106         
   118         
   107     
   119     
   108     <!-- Run Ant unit tests. -->
   120     <!-- Run Ant unit tests. -->
   109     <target name="ant-unittest">
   121     <target name="ant-unittest">
   110         <mkdir dir="${helium.build.dir}/temp"/>
   122         <mkdir dir="${helium.build.dir}/temp"/>
       
   123         <mkdir dir="${helium.build.dir}/report/antunit"/>
   111         <au:antunit>
   124         <au:antunit>
       
   125             <propertyset>
       
   126                 <propertyref name="cache.dir"/>
       
   127             </propertyset>
   112             <fileset dir="${helium.dir}" includes="tools/**/test_*.ant.xml"/>
   128             <fileset dir="${helium.dir}" includes="tools/**/test_*.ant.xml"/>
   113             <fileset dir="${helium.dir}" includes="extensions/nokia/tools/**/test_*.ant.xml"/>
   129             <fileset dir="${helium.dir}" includes="extensions/nokia/tools/**/test_*.ant.xml"/>
   114             <au:plainlistener/>
   130             <au:plainlistener/>
       
   131             <au:xmllistener toDir="${helium.build.dir}/report/antunit"/>
   115         </au:antunit>
   132         </au:antunit>
   116     </target>
   133     </target>
   117     
   134     
   118     
   135     
   119     <!-- Run JUnit unit tests. -->
   136     <!-- Run JUnit unit tests. -->
   161                     <include name="**/*Test*.java"/>
   178                     <include name="**/*Test*.java"/>
   162                 </fileset>
   179                 </fileset>
   163             </batchtest>
   180             </batchtest>
   164         </junit>
   181         </junit>
   165         
   182         
   166         <emma enabled="true" >
   183         <emma enabled="true">
   167             <report>
   184             <report>
       
   185                 <sourcepath>
       
   186                     <dirset dir="${src.classes}" />
       
   187                 </sourcepath>
   168                 <infileset dir="${build.temp.dir}" includes="*.emma" />
   188                 <infileset dir="${build.temp.dir}" includes="*.emma" />
   169                 <txt outfile="${build.temp.dir}/coverage.txt" />
   189                 <txt outfile="${build.temp.dir}/coverage.txt" depth="method" />
   170                 <html outfile="${build.temp.dir}/coverage.html" />
   190                 <html outfile="${build.temp.dir}/coverage.html" />
   171             </report>
   191             </report>
   172         </emma>
   192         </emma>
   173         <loadfile property="message" srcFile="${build.temp.dir}/coverage.txt"/>
   193         <loadfile property="message" srcFile="${build.temp.dir}/coverage.txt"/>
   174         <echo message="${message}"/>
   194         <echo message="${message}"/>