buildframework/helium/tools/common/testing.ant.xml
changeset 1 be27ed110b50
child 179 d8ac696cc51f
equal deleted inserted replaced
0:044383f39525 1:be27ed110b50
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!-- 
       
     3 ============================================================================ 
       
     4 Name        : testing.xml 
       
     5 Part of     : Helium 
       
     6 
       
     7 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 All rights reserved.
       
     9 This component and the accompanying materials are made available
       
    10 under the terms of the License "Eclipse Public License v1.0"
       
    11 which accompanies this distribution, and is available
       
    12 at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 
       
    14 Initial Contributors:
       
    15 Nokia Corporation - initial contribution.
       
    16 
       
    17 Contributors:
       
    18 
       
    19 Description:
       
    20 
       
    21 ============================================================================
       
    22 -->
       
    23 <project name="internal.testing" xmlns:au="org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium"> 
       
    24     <description>
       
    25         Targets to test Helium itself.
       
    26     </description>
       
    27     <import file="${helium.dir}/build-jar.ant.xml"/>
       
    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. -->
       
    36     <target name="unittest" depends="ju-unittest,check,ant-unittest,py-unittest"/>
       
    37     
       
    38     <!-- Unit testing -->
       
    39 
       
    40     <!-- Setup environment for Python unit tests -->
       
    41     <target name="setup-py-unittest">
       
    42         <!-- Autogenerate test data for ArchivePreBuilderTest based on ANT properties -->
       
    43         <if>
       
    44             <available file="${helium.dir}/tests/data/archive_test.cfg.xml"/>
       
    45             <then>
       
    46                 <delete file="${helium.dir}/tests/data/archive_test.cfg.xml"/>
       
    47             </then>
       
    48         </if>
       
    49         <copy file="${helium.dir}/tests/data/archive_test_input.cfg.xml" tofile="${helium.dir}/tests/data/archive_test.cfg.xml" overwrite="true">
       
    50             <filterchain>
       
    51                 <expandproperties/>
       
    52             </filterchain>
       
    53         </copy>
       
    54     </target>
       
    55 
       
    56     <!-- Do Python tests. -->
       
    57     <target name="do-py-unittest" depends="setup-py-unittest">
       
    58         <property name="nose.args" value="nokiatest test"/>
       
    59         <exec executable="python" failonerror="true">
       
    60             <arg line="${python.tools}/coverage.py -x ${python.tools}/nosetests-script.py -v ${nose.args}"/>
       
    61         </exec>
       
    62     </target>
       
    63     
       
    64     <!-- Shortcut for Python unit tests. -->
       
    65     <target name="pt" depends="do-py-unittest"/>
       
    66     
       
    67         
       
    68     <!-- Create Python code coverage statistics. -->
       
    69     <target name="py-unittest-coverage">
       
    70         <mkdir dir="${helium.dir}/build/coverage"/>
       
    71         <pathconvert pathsep=" " property="python.modules.coverage">
       
    72             <fileset refid="python.files"/>
       
    73         </pathconvert>
       
    74         <exec executable="python" failonerror="true">
       
    75             <arg line="${python.tools}/coverage.py -a -d ${helium.dir}/build/coverage ${python.modules.coverage}"/>
       
    76         </exec>
       
    77                         
       
    78         <!-- backup the old line coverage report and create the new one -->
       
    79         <mkdir dir="${helium.dir}/build/coverage/report"/>        
       
    80         <if>
       
    81             <available file="${helium.dir}/build/coverage/report/line_coverage.txt"/>
       
    82             <then>
       
    83                 <copy file="${helium.dir}/build/coverage/report/line_coverage.txt" tofile="${helium.dir}/build/coverage/report/line_coverage_old.txt" overwrite="true"/>
       
    84             </then>    
       
    85         </if>        
       
    86         <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="start"/>        
       
    87         <exec executable="python" failonerror="true">
       
    88             <arg line="${python.tools}/coverage.py -r ${python.modules.coverage}"/>
       
    89         </exec>
       
    90         <record name="${helium.dir}/build/coverage/report/line_coverage.txt" action="stop"/>
       
    91         <replace file="${helium.dir}/build/coverage/report/line_coverage.txt">
       
    92             <replacetoken><![CDATA[[exec]]]></replacetoken>
       
    93             <replacevalue><![CDATA[]]></replacevalue>
       
    94         </replace>
       
    95         <hlm:python>
       
    96 for line in open(r'${helium.dir}/build/coverage/report/line_coverage.txt'):
       
    97     if 'TOTAL' in line and '0%' in line:
       
    98         raise Exception('Coverage at 0%')
       
    99         </hlm:python>
       
   100         <delete file="${helium.dir}/.coverage"/>
       
   101     </target>
       
   102     
       
   103     
       
   104     <!-- Run Python unit test cases. -->
       
   105     <target name="py-unittest" depends="do-py-unittest,py-unittest-coverage"/>
       
   106         
       
   107     
       
   108     <!-- Run Ant unit tests. -->
       
   109     <target name="ant-unittest">
       
   110         <mkdir dir="${helium.build.dir}/temp"/>
       
   111         <au:antunit>
       
   112             <fileset dir="${helium.dir}" includes="tools/**/test_*.ant.xml"/>
       
   113             <fileset dir="${helium.dir}" includes="extensions/nokia/tools/**/test_*.ant.xml"/>
       
   114             <au:plainlistener/>
       
   115         </au:antunit>
       
   116     </target>
       
   117     
       
   118     
       
   119     <!-- Run JUnit unit tests. -->
       
   120     <target name="ju-unittest" depends="build-java-src">
       
   121         <!-- Source location for test class -->
       
   122         <property name="src" location="tools/common/java/test" /> 
       
   123         <!-- Source classes location -->
       
   124         <property name="src.classes" location="tools/common/java/src" />
       
   125         
       
   126         <delete dir="${build.temp.dir}/junit_classes"/>
       
   127         <mkdir dir="${build.temp.dir}/junit_classes" />
       
   128                 
       
   129         <!-- Compile the test classes  -->
       
   130         <javac srcdir="${src}" destdir="${build.temp.dir}/junit_classes" debug="true">    
       
   131             <include name="**/*.java"/>
       
   132             <classpath>                         
       
   133                 <pathelement path="${java.class.path}/"/>
       
   134             </classpath>
       
   135         </javac>
       
   136         
       
   137         <path id="build.classpath">
       
   138             <pathelement location="${build.temp.dir}/class" />
       
   139             <pathelement location="${build.temp.dir}/junit_classes" />
       
   140         </path>
       
   141         <emma enabled="true">
       
   142             <instr instrpathref="build.classpath"  
       
   143             destdir="${build.temp.dir}/emma/instrumented"  
       
   144             metadatafile="${build.temp.dir}/metadata.emma"
       
   145             merge="true">
       
   146                 <filter excludes="org.apache.log4j.*" />
       
   147             </instr>
       
   148         </emma>
       
   149                                                     
       
   150         <!-- Execute JUnit-->
       
   151         <junit fork="yes" printsummary="yes" haltonfailure="no" showoutput="yes" >
       
   152             <formatter type="brief" usefile="false"/>
       
   153             <jvmarg value="-Demma.coverage.out.file=${build.temp.dir}/coverage.emma" />
       
   154             <jvmarg value="-Demma.coverage.out.merge=false" />
       
   155             <classpath>
       
   156                 <pathelement path="${build.temp.dir}/emma/instrumented"/>
       
   157                 <pathelement path="${java.class.path}/"/>
       
   158             </classpath>    
       
   159             <batchtest fork="yes" todir="${build.temp.dir}/junit_test">
       
   160                 <fileset dir="${src}">
       
   161                     <include name="**/*Test*.java"/>
       
   162                 </fileset>
       
   163             </batchtest>
       
   164         </junit>
       
   165         
       
   166         <emma enabled="true" >
       
   167             <report>
       
   168                 <infileset dir="${build.temp.dir}" includes="*.emma" />
       
   169                 <txt outfile="${build.temp.dir}/coverage.txt" />
       
   170                 <html outfile="${build.temp.dir}/coverage.html" />
       
   171             </report>
       
   172         </emma>
       
   173         <loadfile property="message" srcFile="${build.temp.dir}/coverage.txt"/>
       
   174         <echo message="${message}"/>
       
   175     </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     
       
   223 </project>