mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ludovicp
28.52.2010 2ef009229c3b6aff5c044680e398703007490735
opends/tests/staf-tests/shared/ant/tests.xml
@@ -385,7 +385,6 @@
original.archive=${opends.dir.input}/${opends.name.input}.zip</echo>
  </target>
  <target name="coverage-init">
    <path id="emma.lib">
      <pathelement location="${project.home}/ext/emma/lib/emma.jar"     />
@@ -393,40 +392,59 @@
    </path>
    <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
  </target>
  <target name="coverage-on" depends="coverage-init">
    <property name="coverage.on" value="true"/>
  </target>
  <target name="coverage-instrument" if="coverage.on">
    <delete dir="${tests.tmp.dir}/coverage-instr" />
    <mkdir dir="${tests.tmp.dir}/coverage-instr/opends" />
    <mkdir dir="${tests.tmp.dir}/coverage-instr/dsml" />
    <delete dir="${temp.dir}/coverage-instr" />
    <mkdir dir="${temp.dir}/coverage-instr/opends" />
    <mkdir dir="${temp.dir}/coverage-instr/dsml" />
    <!-- unzip the original package in a temporary location to make the
         changes necessary so that the coverage tool is called
     -->
    <unzip src="${opends.dir}/${opends.name}.zip"
           dest="${tests.tmp.dir}/coverage-instr/opends"/>
    <unzip src="${opends.dir}/${opends.name}-DSML.war"
           dest="${tests.tmp.dir}/coverage-instr/dsml"/>
           dest="${temp.dir}/coverage-instr/opends"/>
    <if>
      <matches string="${product.name}" pattern="^OpenDS ."/>
      <then>
        <!-- The war file is not in the opends archive -->
        <unzip src="${opends.dir}/${opends.name}-DSML.war"
               dest="${temp.dir}/coverage-instr/dsml"/>
      </then>
      <else>
        <!-- The war file is in the opends archive -->
        <unzip src="${temp.dir}/coverage-instr/opends/${opends.name}/addons/DSML.war"
               dest="${temp.dir}/coverage-instr/dsml"/>
      </else>
    </if>
    <!-- Add emma in the package along with the other librairies
         this has the advantage of being automatically picked up by the scripts
    -->
    <copy file="${project.home}/ext/emma/lib/emma.jar"
          tofile="${tests.tmp.dir}/coverage-instr/opends/${opends.name}/lib/emma.jar"/>
          tofile="${temp.dir}/coverage-instr/opends/${opends.name}/lib/emma.jar"/>
    <copy file="${project.home}/ext/emma/lib/emma.jar"
          tofile="${tests.tmp.dir}/coverage-instr/dsml/WEB-INF/lib/emma.jar"/>
          tofile="${temp.dir}/coverage-instr/dsml/WEB-INF/lib/emma.jar"/>
    <!-- move the original product package to make room for the coverage
         enabled package
     -->
    <move file="${opends.dir}/${opends.name}.zip" tofile="${opends.dir}/${opends.name}.zip.nocov"/>
    <move file="${opends.dir}/${opends.name}-DSML.war" tofile="${opends.dir}/${opends.name}-DSML.war.nocov"/>
    <if>
      <matches string="${product.name}" pattern="^OpenDS ."/>
      <then>
        <!-- The war file is not in the opends archive, so we need to backup the original package -->
        <move file="${opends.dir}/${opends.name}-DSML.war" tofile="${opends.dir}/${opends.name}-DSML.war.nocov"/>
      </then>
    </if>
    <!-- intrument the OpenDS java archive to gather coverage -->
    <java classpath="${tests.tmp.dir}/coverage-instr/opends/${opends.name}/lib/emma.jar"
    <java classpath="${temp.dir}/coverage-instr/opends/${opends.name}/lib/emma.jar"
          classname="emma" fork="true">
        <jvmarg value="-Demma.metadata.out.file=${tests.tmp.dir}/coverage-instr/opends/${opends.name}/coverage.em" />
        <jvmarg value="-Demma.metadata.out.file=${temp.dir}/coverage-instr/opends/${opends.name}/coverage.em" />
        <arg value="instr" />
        <arg value="-m" />
        <arg value="overwrite" />
@@ -439,12 +457,12 @@
        <arg value="-ix" />
        <arg value="com.*" />
        <arg value="-ip" />
        <arg value="${tests.tmp.dir}/coverage-instr/opends/${opends.name}/lib/OpenDS.jar:${tests.tmp.dir}/coverage-instr/opends/${opends.name}/lib/extensions/snmp-mib2605.jar" />
        <arg value="${temp.dir}/coverage-instr/opends/${opends.name}/lib/OpenDS.jar:${temp.dir}/coverage-instr/opends/${opends.name}/lib/extensions/snmp-mib2605.jar" />
    </java>
    <java classpath="${tests.tmp.dir}/coverage-instr/dsml/WEB-INF/lib/emma.jar"
    <java classpath="${temp.dir}/coverage-instr/dsml/WEB-INF/lib/emma.jar"
          classname="emma" fork="true">
        <jvmarg value="-Demma.metadata.out.file=${tests.tmp.dir}/coverage-instr/dsml/WEB-INF/lib/coverage.em" />
        <jvmarg value="-Demma.metadata.out.file=${temp.dir}/coverage-instr/dsml/WEB-INF/lib/coverage.em" />
        <arg value="instr" />
        <arg value="-m" />
        <arg value="overwrite" />
@@ -457,29 +475,53 @@
        <arg value="-ix" />
        <arg value="com.*" />
        <arg value="-ip" />
        <arg value="${tests.tmp.dir}/coverage-instr/dsml/WEB-INF/classes" />
        <arg value="${temp.dir}/coverage-instr/dsml/WEB-INF/classes" />
    </java>
    <!-- Repackage DSML Gateway the product with coverage enabled scripts -->
    <if>
      <matches string="${product.name}" pattern="^OpenDS ."/>
      <then>
        <!-- The war file is not in the opends archive, so we need to repackage the war file -->
        <zip basedir="${temp.dir}/coverage-instr/dsml" destfile="${opends.dir}/${opends.name}-DSML.war">
        <zipfileset dir="${temp.dir}/coverage-instr/dsml"
                    includes="WEB-INF/**,META-INF/**"/>
        </zip>
      </then>
      <else>
        <!-- The war file is in the opends archive, so we need to replace the war file -->
        <delete file="${temp.dir}/coverage-instr/opends/${opends.name}/addons/DSML.war"/>
        <zip basedir="${temp.dir}/coverage-instr/dsml" destfile="${temp.dir}/coverage-instr/opends/${opends.name}/addons/DSML.war">
        <zipfileset dir="${temp.dir}/coverage-instr/dsml"
                    includes="WEB-INF/**,META-INF/**"/>
        </zip>
      </else>
    </if>
    <!-- Repackage OpenDS the product with coverage enabled scripts -->
    <zip basedir="${tests.tmp.dir}/coverage-instr/opends" destfile="${opends.dir}/${opends.name}.zip">
    <zipfileset dir="${tests.tmp.dir}/coverage-instr/opends"
    <zip basedir="${temp.dir}/coverage-instr/opends" destfile="${opends.dir}/${opends.name}.zip">
    <zipfileset dir="${temp.dir}/coverage-instr/opends"
                includes="${opends.name}/setup,${opends.name}/uninstall,${opends.name}/upgrade,${opends.name}/bin/*,${opends.name}/lib/*.sh"
                filemode="755" dirmode="755" />
    </zip>
    <!-- Repackage DSML Gateway the product with coverage enabled scripts -->
    <zip basedir="${tests.tmp.dir}/coverage-instr/dsml" destfile="${opends.dir}/${opends.name}-DSML.war">
    <zipfileset dir="${tests.tmp.dir}/coverage-instr/dsml"
                includes="WEB-INF/**,META-INF/**"/>
    </zip>
    <!-- <delete dir="${tests.tmp.dir}/coverage-instr"/> -->
    <delete dir="${temp.dir}/coverage-instr"/>
  </target>
  <target name="restore-pkg" if="coverage.on">
    <delete file="${opends.dir}/${opends.name}.zip"/>
    <move file="${opends.dir}/${opends.name}.zip.nocov" tofile="${opends.dir}/${opends.name}.zip"/>
    <delete file="${opends.dir}/${opends.name}-DSML.war"/>
    <move file="${opends.dir}/${opends.name}-DSML.war.nocov" tofile="${opends.dir}/${opends.name}-DSML.war"/>
    <if>
      <matches string="${product.name}" pattern="^OpenDS ."/>
      <then>
        <!-- The war file is not in the opends archive, so we need to restore the original package -->
        <delete file="${opends.dir}/${opends.name}-DSML.war"/>
        <move file="${opends.dir}/${opends.name}-DSML.war.nocov" tofile="${opends.dir}/${opends.name}-DSML.war"/>
      </then>
    </if>
  </target>
  <target name="testwithcoverage" depends="coverage-on,coverage-instrument,run,restore-pkg"/>
</project>