Fri, 22 Feb 2013 11:27:40 +0100
8008575: Re-integrate code coverage
Reviewed-by: attila, hannesw
Contributed-by: eugene.drobitko@oracle.com, ilya.dergalin@oracle.com
make/build.xml | file | annotate | diff | comparison | revisions | |
make/code_coverage.xml | file | annotate | diff | comparison | revisions | |
make/project.properties | file | annotate | diff | comparison | revisions |
1.1 --- a/make/build.xml Fri Feb 22 08:57:22 2013 +0100 1.2 +++ b/make/build.xml Fri Feb 22 11:27:40 2013 +0100 1.3 @@ -24,8 +24,13 @@ 1.4 <project name="nashorn" default="all" basedir=".."> 1.5 <import file="build-nasgen.xml"/> 1.6 <import file="build-benchmark.xml"/> 1.7 + <import file="code_coverage.xml"/> 1.8 1.9 - <target name="init"> 1.10 + 1.11 + <target name="init-conditions"> 1.12 + <!-- loading locally defined resources and properties. NB they owerwrite default ones defined later --> 1.13 + <property file="${user.home}/.nashorn.project.local.properties"/> 1.14 + 1.15 <loadproperties srcFile="make/project.properties"/> 1.16 <path id="nashorn.ext.path"> 1.17 <pathelement location="${dist.dir}"/> 1.18 @@ -41,6 +46,22 @@ 1.19 <available property="asm.available" classname="jdk.internal.org.objectweb.asm.Type"/> 1.20 <!-- check if testng.jar is avaiable --> 1.21 <available property="testng.available" file="${file.reference.testng.jar}"/> 1.22 + 1.23 + <!-- enable/disable make code coverage --> 1.24 + <condition property="cc.enabled"> 1.25 + <istrue value="${make.code.coverage}" /> 1.26 + </condition> 1.27 + </target> 1.28 + 1.29 + <target name="init" depends="init-conditions, init-cc"> 1.30 + 1.31 + <!-- extends jvm args --> 1.32 + <property name="run.test.jvmargs">${run.test.jvmargs.main} ${run.test.cc.jvmargs}</property> 1.33 + <property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main} ${run.test.cc.jvmargs}" /> 1.34 + 1.35 + <echo message="run.test.jvmargs=${run.test.jvmargs}"/> 1.36 + <echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/> 1.37 + 1.38 </target> 1.39 1.40 <target name="prepare" depends="init"> 1.41 @@ -52,7 +73,7 @@ 1.42 <mkdir dir="${dist.javadoc.dir}"/> 1.43 </target> 1.44 1.45 - <target name="clean" depends="init, clean-nasgen"> 1.46 + <target name="clean" depends="init, clean-nasgen, init-cc-cleanup"> 1.47 <delete includeemptydirs="true"> 1.48 <fileset dir="${build.dir}" erroronmissingdir="false"/> 1.49 </delete>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/make/code_coverage.xml Fri Feb 22 11:27:40 2013 +0100 2.3 @@ -0,0 +1,117 @@ 2.4 +<?xml version="1.0" encoding="UTF-8"?> 2.5 +<!-- 2.6 + Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 + 2.9 + This code is free software; you can redistribute it and/or modify it 2.10 + under the terms of the GNU General Public License version 2 only, as 2.11 + published by the Free Software Foundation. 2.12 + 2.13 + This code is distributed in the hope that it will be useful, but WITHOUT 2.14 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.15 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.16 + version 2 for more details (a copy is included in the LICENSE file that 2.17 + accompanied this code). 2.18 + 2.19 + You should have received a copy of the GNU General Public License version 2.20 + 2 along with this work; if not, write to the Free Software Foundation, 2.21 + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.22 + 2.23 + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.24 + or visit www.oracle.com if you need additional information or have any 2.25 + questions. 2.26 +--> 2.27 +<project name="code-coverage" default="generate-code-coverage-report" basedir=".."> 2.28 + 2.29 + <!-- CODE COVERAGE --> 2.30 + <target name="init-cc-enabled" if="${cc.enabled}"> 2.31 + 2.32 + <echo message="initialize [${jcov}] java coverage"/> 2.33 + 2.34 + 2.35 + <property name="cc.report.dir" value="${cc.dir}/CC_${jcov}_report"/> 2.36 + <property name="cc.merged.xml" value="${cc.dir}/CC_${jcov}_result-merged.xml"/> 2.37 + 2.38 + <condition property="run.test.cc.jvmargs" value="${cc.dynamic.args}"> 2.39 + <equals arg1="${jcov}" arg2="dynamic" trim="true"/> 2.40 + </condition> 2.41 + 2.42 + <mkdir dir="${cc.dir}"/> 2.43 + 2.44 + <!-- info --> 2.45 + <echo message="jcov=${jcov}"/> 2.46 + <echo message="cc.generate.template=${cc.generate.template}"/> 2.47 + <echo message="cc.instrument=${cc.instrument}"/> 2.48 + <echo message="run.test.cc.jvmargs=${run.test.cc.jvmargs}"/> 2.49 + <echo message="cc.report.dir=${cc.report.dir}"/> 2.50 + <echo message="cc.merged.xml=${cc.merged.xml}"/> 2.51 + </target> 2.52 + 2.53 + <target name="init-cc-disabled" unless="${cc.enabled}"> 2.54 + <property name="run.test.cc.jvmargs" value=""/> 2.55 + </target> 2.56 + 2.57 + <target name="init-cc" depends="init-cc-disabled, init-cc-enabled"> 2.58 + <property name="run.test.cc.jvmargs" value=""/> 2.59 + </target> 2.60 + 2.61 + <target name="init-cc-cleanup" if="${cc.enabled}"> 2.62 + <delete dir="${cc.dir}" failonerror="false" /> 2.63 + </target> 2.64 + 2.65 + <target name="check-merging-files" depends="init"> 2.66 + <resourcecount property="cc.xmls"> 2.67 + <filelist dir="${cc.dir}" files="*.xml" /> 2.68 + </resourcecount> 2.69 + <condition property="nothing-to-merge" value="true"> 2.70 + <equals arg1="${cc.xmls}" arg2="1" trim="true"/> 2.71 + </condition> 2.72 + </target> 2.73 + 2.74 + <target name="fix-merging-files" depends="check-merging-files" if="${nothing-to-merge}"> 2.75 + <echo message="making pre-merge workaround"/> 2.76 + <move todir="${cc.dir}" includeemptydirs="false"> 2.77 + <fileset dir="${cc.dir}"> 2.78 + <include name="*.xml"/> 2.79 + </fileset> 2.80 + <mapper type="glob" from="*.xml" to="CC_${jcov}_result-merged.xml"/> 2.81 + </move> 2.82 + </target> 2.83 + 2.84 + <target name="merge-code-coverage" depends="fix-merging-files" unless="${nothing-to-merge}"> 2.85 + <echo message="merging files"/> 2.86 + <fileset dir="${cc.dir}" id="cc.xmls"> 2.87 + <include name="**/*${jcov}*.xml"/> 2.88 + <include name="**/CC_template.xml"/> 2.89 + </fileset> 2.90 + 2.91 + <pathconvert pathsep=" " property="cc.all.xmls" refid="cc.xmls"/> 2.92 + 2.93 + <java classname="com.sun.tdk.jcov.Merger"> 2.94 + <arg value="-verbose"/> 2.95 + <arg value="-output"/> 2.96 + <arg value="${cc.merged.xml}"/> 2.97 + <arg value="-exclude"/> 2.98 + <arg value="com\.oracle\.nashorn\.runtime\.ScriptRuntime*"/> 2.99 + <arg line="${cc.all.xmls}"/> 2.100 + <classpath> 2.101 + <pathelement location="${jcov.jar}"/> 2.102 + </classpath> 2.103 + </java> 2.104 + 2.105 + </target> 2.106 + 2.107 + <target name="generate-code-coverage-report" depends="merge-code-coverage"> 2.108 + <java classname="com.sun.tdk.jcov.RepGen"> 2.109 + <arg value="-verbose"/> 2.110 +<!-- <arg line ="-exclude_list CC.report.exclude"/> --> 2.111 + <arg line="-output ${cc.report.dir}"/> 2.112 + <arg value="${cc.merged.xml}"/> 2.113 + <classpath> 2.114 + <pathelement location="${jcov.jar}"/> 2.115 + </classpath> 2.116 + </java> 2.117 + </target> 2.118 + 2.119 + 2.120 +</project>
3.1 --- a/make/project.properties Fri Feb 22 08:57:22 2013 +0100 3.2 +++ b/make/project.properties Fri Feb 22 11:27:40 2013 +0100 3.3 @@ -208,9 +208,9 @@ 3.4 3.5 # -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods 3.6 # add '-Dtest.js.outofprocess' to run each test in a new sub-process 3.7 -run.test.jvmargs=-server -Xmx${run.test.xmx} -XX:-TieredCompilation -esa -ea -Dnashorn.debug=true -Dfile.encoding=UTF-8 3.8 +run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:-TieredCompilation -esa -ea -Dnashorn.debug=true -Dfile.encoding=UTF-8 3.9 #-XX:+HeapDumpOnOutOfMemoryError -XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M 3.10 -run.test.jvmargs.octane=-Xms${run.test.xms} ${run.test.jvmargs} 3.11 +run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs} 3.12 3.13 run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy 3.14 3.15 @@ -224,3 +224,21 @@ 3.16 3.17 #timeout for performance tests in minutes 3.18 octaneperf-sys-prop.timeout.value=10 3.19 + 3.20 +################ 3.21 +# codecoverage # 3.22 +################ 3.23 + #enable/disable code coverage; please redifine in the ${user.home}/.nashorn.project.local.properties 3.24 +make.code.coverage=false 3.25 + #type of codecoverage; one of static or dynamic. Now only dynamic is supported 3.26 +jcov=dynamic 3.27 + #naming of CC results 3.28 + #NB directory specified in the cc.dir will be cleaned up!!! 3.29 +cc.dir=${basedir}/../Codecoverage_Nashorn 3.30 +cc.result.file.name=cc_nashorn.xml 3.31 + #dynamic CC parameters; please redefine in the ${user.home}/.nashorn.project.local.properties 3.32 +jcov2.lib.dir=${basedir}/../jcov2/lib 3.33 +jcov.jar=${jcov2.lib.dir}/jcov.jar 3.34 +cc.include=jdk\.nashorn\.* 3.35 +cc.exclude=jdk\.nashorn\.internal\.scripts\.* 3.36 +cc.dynamic.args=-javaagent:${jcov.jar}=include=${cc.include},exclude=${cc.exclude},type=all,verbose=0,file=${cc.dir}/${cc.result.file.name}