nashorn/make/code_coverage.xml
changeset 16529 fb3208bbd5dc
parent 16255 cb52a2524ca8
child 17742 55c938a4618a
--- a/nashorn/make/code_coverage.xml	Mon Mar 18 21:03:11 2013 +0530
+++ b/nashorn/make/code_coverage.xml	Tue Mar 19 11:03:24 2013 -0300
@@ -36,7 +36,12 @@
       <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}"/>
@@ -51,25 +56,66 @@
     <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"/>
+        <include name="**/*.clazz"/>
+      </fileset>
+    </copy>
+
+    <move todir="${build.dir}/to_be_instrumented/jdk/nashorn/internal/objects">
+      <fileset dir="${build.dir}/to_be_instrumented/jdk/nashorn/internal/objects">
+        <include name="**/*.clazz"/>
+      </fileset>
+      <mapper type="glob" from="*.clazz" to="*.class"/>
+    </move>
+  </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">
-	<resourcecount property="cc.xmls">
-  		<filelist dir="${cc.dir}" files="*.xml" />
-	</resourcecount>	
+	<echo message="checking avalibility of ${cc.template}"/>
     <condition property="nothing-to-merge" value="true">
-      <equals arg1="${cc.xmls}" arg2="1" trim="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"/>
+	<echo message="making pre-merge workaround due to missed template"/>
 	<move todir="${cc.dir}" includeemptydirs="false">
 		<fileset dir="${cc.dir}">
 			<include name="*.xml"/>
@@ -81,12 +127,12 @@
   <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="**/*_${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"/>