nashorn/make/code_coverage.xml
author serb
Tue, 14 Apr 2015 09:34:59 +0300
changeset 30457 8934b8474110
parent 19097 f544a2ea40ef
permissions -rw-r--r--
8076214: [Findbugs]sun.awt.datatransfer.SunClipboard.checkChange(long[]) may expose internal representation Reviewed-by: azvegint, alexsch

<?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>