build/coberturautilities.xml
author hgs
Fri, 29 Oct 2010 11:49:32 +0300
changeset 87 1627c337e51e
permissions -rw-r--r--
v2.2.21_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
87
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     1
<!--
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     2
#
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     3
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     4
# All rights reserved.
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     5
# This component and the accompanying materials are made available
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     6
# under the terms of "Eclipse Public License v1.0"
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     7
# which accompanies this distribution, and is available
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     8
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
     9
#
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    10
# Initial Contributors:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    11
# Nokia Corporation - initial contribution.
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    12
#
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    13
# Contributors:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    14
#
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    15
# Description:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    16
#
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    17
-->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    18
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    19
<project name="CoberturaUtilities">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    20
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    21
  <import file="properties.xml"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    22
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    23
  <!--
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    24
      Steps to generate Cobertura coverage report in Symbian^x:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    25
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    26
      1) Build component with cobertura instrumentation from component build dir:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    27
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    28
        cd component_build_dir
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    29
        make -f $JAVA_SRC_ROOT/build/Makefile.comp clean
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    30
        make -f $JAVA_SRC_ROOT/build/Makefile.comp COBERTURA=1
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    31
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    32
        Note that you can also instrument the whole build if necessary:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    33
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    34
        cd $JAVA_SRC_ROOT
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    35
        make -f subsystem.mk reallyclean
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    36
        make -f subsystem.mk COBERTURA=1
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    37
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    38
      2) Run the tests from component test build dir:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    39
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    40
        cd component_tsrc_build_dir
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    41
        ant run
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    42
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    43
      3) Generate coverage report:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    44
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    45
        cd component_build_dir
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    46
        make -f $JAVA_SRC_ROOT/build/Makefile.comp coberturareport
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    47
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    48
        Reports are generated into /tmp/cobertura/results/index.html.
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    49
        in firefox issue command:
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    50
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    51
        firefox /tmp/cobertura/results/index.html
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    52
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    53
      4) To reset coverage measurement, remove all other files from
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    54
        /tmp/coverage except *_instr.ser
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    55
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    56
    -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    57
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    58
  <!-- Begin definitions for cobertura. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    59
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    60
  <!-- Location for cobertura tool. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    61
  <property name="cobertura.dir" value="${java.src.root}/../tools/cobertura"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    62
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    63
  <!-- Directory for cobertura coverage data. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    64
  <property name="cobertura.coverage.dir" location="/tmp/cobertura"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    65
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    66
  <!-- Cobertura jar files. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    67
  <property name="cobertura.runtime.jar" value="cobertura4j2me-runtime.jar"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    68
  <property name="cobertura.classpath" location="${cobertura.dir}/${cobertura.runtime.jar}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    69
  <property name="cobertura.ant.classpath" location="${cobertura.dir}/cobertura4j2me.jar"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    70
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    71
  <!-- Coverage result data directory. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    72
  <property name="cobertura.emulator.path" location="/epoc32/winscw/c/logs/java"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    73
  <!-- Coverage result data file. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    74
  <property name="cobertura.result.file" value="cobertura.ser"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    75
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    76
  <!-- Cobertura jars. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    77
  <path id="cobertura.lib">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    78
    <pathelement location="${cobertura.dir}/${cobertura.runtime.jar}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    79
    <pathelement location="${cobertura.dir}/cobertura4j2me.jar"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    80
  </path>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    81
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    82
  <!-- Cobertura task definitions. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    83
  <taskdef resource="cobertura4j2me-tasks.properties" classpathref="cobertura.lib" />
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    84
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    85
  <!-- Defines do.cobertura to be true for enabling cobertura tasks. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    86
 <target name="cobertura" depends="init.properties">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    87
    <property name="do.cobertura" value="true"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    88
  </target>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    89
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    90
  <!-- Copy cobertura JAR to correct place. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    91
  <target name="cobertura.deploy">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    92
    <copy file="${cobertura.dir}/${cobertura.runtime.jar}" todir="${bcp.dest.directory}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    93
  </target>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    94
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    95
  <!-- Make cobertura instrumentation. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    96
  <target name="cobertura.instr" depends="cobertura, cobertura.deploy">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    97
      <echo message="Cobertura: instrumenting ${ant.project.name}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    98
      <cobertura4j2me-instrument todir="${dst.dir}" keepdata="true" devicepath="c:/logs/java" datafile="${ant.project.name}_instr.ser">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
    99
          <fileset dir="${dst.dir}" includes="**/*.class" />
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   100
      </cobertura4j2me-instrument>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   101
      <!-- Move instrumentation file coverage work dir. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   102
      <move file="${ant.project.name}_instr.ser" todir="${cobertura.coverage.dir}" overwrite="false"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   103
  </target>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   104
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   105
  <!-- Add System property enabling coverage result writing at shut down -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   106
  <target name="cobertura.systemprop">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   107
    <echo file="${component.root.dir}/properties.txt" append="true">jrt.shutdown.extension=com.nokia.mj.impl.rt.test.CoverageResultInvoker</echo>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   108
  </target>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   109
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   110
  <!-- Generate Cobertura coverage report. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   111
  <target name="cobertura.report">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   112
    <echo message="Creating coverage report." />
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   113
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   114
    <!-- Copy coverage data file from the emulator to report directory -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   115
    <copy file="${cobertura.emulator.path}/${cobertura.result.file}" todir="${cobertura.coverage.dir}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   116
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   117
    <!-- Merge instrumentation and coverage data for reporting. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   118
    <echo message="Merge coverage data." />
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   119
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   120
    <!-- Copy cobertura to result dir for merging. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   121
    <copy file="${cobertura.ant.classpath}" todir="${cobertura.coverage.dir}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   122
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   123
    <!-- Copy cobertura for reporting. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   124
    <copy file="${cobertura.dir}/cobertura4j2me.properties" todir="${cobertura.coverage.dir}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   125
    <copy file="${cobertura.dir}/res/build_ant.xml" todir="${cobertura.coverage.dir}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   126
    <copy file="${cobertura.dir}/res/mergeResults.bat" todir="${cobertura.coverage.dir}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   127
    <copy file="${cobertura.dir}/res/reportResults.bat" todir="${cobertura.coverage.dir}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   128
    <copy todir="${cobertura.coverage.dir}/lib">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   129
      <fileset dir="${cobertura.dir}/lib"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   130
    </copy>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   131
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   132
    <!-- Must merge using batch file at local filesystem because of cobertura feature. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   133
    <exec executable="${cobertura.coverage.dir}/mergeResults.bat" dir="${cobertura.coverage.dir}" failonerror="true" />
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   134
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   135
    <!-- Create coverage report. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   136
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   137
    <!-- Must create report using batch file at local filesystem because of cobertura feature. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   138
    <exec executable="${cobertura.coverage.dir}/reportResults.bat" dir="${cobertura.coverage.dir}" failonerror="true" >
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   139
      <arg value="${java.src.root}" />
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   140
    </exec>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   141
  </target>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   142
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   143
  <!-- Clean cobertura related files. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   144
  <target name="cobertura.clean">
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   145
    <delete file="${bcp.dest.directory}/${cobertura.runtime.jar}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   146
    <delete dir="${cobertura.coverage.dir}"/>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   147
  </target>
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   148
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   149
  <!-- End definitions for cobertura. -->
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   150
1627c337e51e v2.2.21_1
hgs
parents:
diff changeset
   151
</project>