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