aboutsummaryrefslogtreecommitdiff
path: root/make/code_coverage.xml
blob: 7fe1f3845a1bd106c75a3051dc4667bda69e04ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
 This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.
 
 This code is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 version 2 for more details (a copy is included in the LICENSE file that
 accompanied this code).
 
 You should have received a copy of the GNU General Public License version
 2 along with this work; if not, write to the Free Software Foundation,
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 or visit www.oracle.com if you need additional information or have any
 questions.
-->
<project name="code-coverage" default="generate-code-coverage-report" basedir="..">

  <!-- CODE COVERAGE -->
  <target name="init-cc-enabled" if="${cc.enabled}">

    <echo message="initialize [${jcov}] java coverage"/>


    <property name="cc.report.dir" value="${cc.dir}/CC_${jcov}_report"/>
    <property name="cc.merged.xml" value="${cc.dir}/CC_${jcov}_result-merged.xml"/>

    <condition property="run.test.cc.jvmargs" value="${cc.dynamic.args}">
      <equals arg1="${jcov}" arg2="dynamic" trim="true"/>
    </condition>

    <condition property="cc.generate.template" value="true">
      <equals arg1="${cc.dynamic.genereate.template}" arg2="true" trim="true"/>
    </condition>

    <mkdir dir="${cc.dir}"/>
    <mkdir dir="${build.dir}/to_be_instrumented"/>

    <!-- info -->
    <echo message="jcov=${jcov}"/>
    <echo message="cc.generate.template=${cc.generate.template}"/>
    <echo message="cc.instrument=${cc.instrument}"/>
    <echo message="run.test.cc.jvmargs=${run.test.cc.jvmargs}"/>
    <echo message="cc.report.dir=${cc.report.dir}"/>
    <echo message="cc.merged.xml=${cc.merged.xml}"/>
  </target>

  <target name="init-cc-disabled" unless="${cc.enabled}">
    <property name="run.test.cc.jvmargs" value=""/>
  </target>

  <target name="prepare-to-be-instrumented" depends="compile" description="Prepares to_be_instrumented dir">
    <copy todir="${build.dir}/to_be_instrumented">
      <fileset dir="${build.classes.dir}">
        <include name="**/*.class"/>
      </fileset>
    </copy>
  </target>

  <target name="generate-cc-template" depends="prepare-to-be-instrumented" description="Generates code coverage template for dynamic CC" if="cc.generate.template">
    <property name="cc.instrumented.path" location="${build.dir}/to_be_instrumented"/>
    <java classname="com.sun.tdk.jcov.TmplGen">
      <arg value="-verbose"/>
      <arg line="-include ${cc.include}"/>
      <arg line="-type all"/>
      <arg line="-template ${cc.template}"/>
      <arg value="${cc.instrumented.path}"/>
      <classpath>
        <pathelement location="${jcov.jar}"/>
      </classpath>
    </java>

    <java classname="com.sun.tdk.jcov.RepGen">
      <arg value="-verbose"/>
      <arg line="-output ${cc.dir}/CC_template_report"/>
      <arg value="${cc.template}"/>
      <classpath>
        <pathelement location="${jcov.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="init-cc" depends="init-cc-disabled, init-cc-enabled">
    <property name="run.test.cc.jvmargs" value=""/>
  </target>

  <target name="init-cc-cleanup" if="${cc.enabled}">
    <delete dir="${cc.dir}" failonerror="false" />
    <delete dir="${build.dir}/to_be_instrumented" failonerror="false" />
  </target>

  <target name="check-merging-files" depends="init">
	<echo message="checking avalibility of ${cc.template}"/>
    <condition property="nothing-to-merge" value="true">
		<not>
	      <available file="${cc.template}"/>
		</not>
    </condition>
	<echo message="nothing-to-merge = ${nothing-to-merge}"/>
  </target>

  <target name="fix-merging-files" depends="check-merging-files" if="${nothing-to-merge}">
	<echo message="making pre-merge workaround due to missed template"/>
	<move todir="${cc.dir}" includeemptydirs="false">
		<fileset dir="${cc.dir}">
			<include name="*.xml"/>
		</fileset>
		<mapper type="glob" from="*.xml" to="CC_${jcov}_result-merged.xml"/>
	</move>
  </target>
 
  <target name="merge-code-coverage" depends="fix-merging-files" unless="${nothing-to-merge}">
	<echo message="merging files"/>
    <fileset dir="${cc.dir}" id="cc.xmls">
      <include name="**/*_${jcov}_*.xml"/>
      <include name="**/CC_template.xml"/>
    </fileset>

    <pathconvert pathsep=" " property="cc.all.xmls" refid="cc.xmls"/>
	<echo message="merging files - ${cc.all.xmls}" />
    <java classname="com.sun.tdk.jcov.Merger">
      <arg value="-verbose"/>
      <arg value="-output"/>
      <arg value="${cc.merged.xml}"/>
      <arg value="-exclude"/>
      <arg value="com\.oracle\.nashorn\.runtime\.ScriptRuntime*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.javaadapters*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.objects\.annotations*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.scripts*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.lookup\.MethodHandleFactory*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.test\.framework*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.test\.models*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.ir\.debug*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.runtime\.regexp\.joni\.bench*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.runtime\.DebugLogger*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.runtime\.Timing*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.runtime\.Logging*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.runtime\.Debug*"/>
      <arg value="-exclude"/>
      <arg value="jdk\.nashorn\.internal\.objects\.NativeDebug*"/>
      <arg line="${cc.all.xmls}"/>
      <classpath>
        <pathelement location="${jcov.jar}"/>
      </classpath>
    </java>

  </target>

  <target name="generate-code-coverage-report" depends="merge-code-coverage">
    <java classname="com.sun.tdk.jcov.RepGen">
      <arg value="-verbose"/>
<!--      <arg line ="-exclude_list CC.report.exclude"/> -->
      <arg line="-output ${cc.report.dir}"/>
      <arg value="${cc.merged.xml}"/>
      <classpath>
        <pathelement location="${jcov.jar}"/>
      </classpath>
    </java>
  </target>


</project>