I have Cobertura running and producing reports against contrib, sort-of. Problems:
(1) AFAICT, cobertura *insists* in trying to parse the source code as Java to do cyclomatic complexity analysis. This blows up, of course. (2) The red/green coloring of the lines does not match what I know is happening in the test run. This may be caused by #1 but I doubt it. I have attached a modified contrib build.xml if anyone wants to play with this. Note that you will need to drop cobertura and its various jars into a cobertura directory. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
<project name="clojure-contrib" default="jar" xmlns:mvn="urn:maven-artifact-ant"> <description> Pack all clojure-contrib sources into a JAR. Compile those that can be compiled standalone if the clojure.jar property points us to clojure.jar. </description> <property name="src" location="src"/> <property name="build" location="classes"/> <property name="test.temp.dir" location="test/tmp"/> <available property="hasclojure" file="${clojure.jar}"/> <!-- The JAR file to create. --> <property name="jarfile" location="clojure-contrib.jar"/> <property name="slimjarfile" location="clojure-contrib-slim.jar"/> <!-- These make sense for building on tapestry.formos.com --> <property name="snapshot.repo.dir" location="/var/www/maven-snapshot-repository"/> <property name="stable.repo.dir" location="/var/www/maven-repository"/> <target name="init"> <tstamp/> <mkdir dir="${build}"/> </target> <target name="clean" description="Remove generated files and directories."> <delete file="${jarfile}"/> <delete file="${slimjarfile}"/> <delete dir="${build}"/> </target> <target name="test_clojure" description = "Run clojure tests" if="hasclojure"> <java classname="clojure.main"> <classpath> <path location="${build}"/> <path location="${src}"/> <path location="${clojure.jar}"/> </classpath> <arg value="-e"/> <arg value="(require '(clojure.contrib [test-clojure :as main])) (main/run)"/> </java> </target> <target name="test_contrib" description = "Run contrib tests" if="hasclojure"> <mkdir dir="${test.temp.dir}"/> <java classname="clojure.main"> <classpath> <path location="${build}"/> <path location="${src}"/> <path location="${clojure.jar}"/> </classpath> <arg value="-e"/> <arg value="(require '(clojure.contrib [test-contrib :as main])) (main/run)"/> </java> </target> <target name="cover_contrib" description = "Run contrib tests for coverage" if="hasclojure" depends="instrument"> <mkdir dir="${test.temp.dir}"/> <java fork="yes" classname="clojure.main"> <sysproperty key="net.sourceforge.cobertura.datafile" file="${basedir}/cobertura.ser" /> <sysproperty key="clojure.jar" file="${clojure.jar}" /> <classpath> <path location="cobertura/instrumented"/> <path refid="cobertura.classpath"/> <path location="${src}"/> <path location="${clojure.jar}"/> </classpath> <arg value="-e"/> <arg value="(require '(clojure.contrib [test-contrib :as main])) (main/run)"/> </java> <cobertura-report format="html" srcdir="${src}" destdir="cobertura/report"/> </target> <target name="test_datalog" description = "Run datalog tests" if="hasclojure"> <java classname="clojure.main"> <classpath> <path location="${build}"/> <path location="${src}"/> <path location="${clojure.jar}"/> </classpath> <arg value="-e"/> <arg value="(require '(clojure.contrib.datalog.tests [test :as main])) (main/run)"/> </java> </target> <target name="test" depends="test_clojure,test_contrib,test_datalog" description="Run all tests"/> <target name="check_hasclojure" description="Print a warning message if clojure.jar is undefined" unless="hasclojure"> <echo>WARNING: You have not defined a path to clojure.jar so I can't compile files. This will cause some parts of clojure.contrib not to work (e.g., pretty print). To enable compiling, run "ant -Dclojure.jar=<...path to clojure.jar..>" </echo> </target> <target name="compile_clojure" depends="init,check_hasclojure" description="Compile Clojure sources." if="hasclojure"> <java classname="clojure.lang.Compile"> <classpath> <path location="${build}"/> <path location="${src}"/> <path location="${clojure.jar}"/> </classpath> <sysproperty key="clojure.compile.path" value="${build}"/> <arg value="clojure.contrib.accumulators"/> <arg value="clojure.contrib.command-line"/> <arg value="clojure.contrib.complex-numbers"/> <arg value="clojure.contrib.cond"/> <arg value="clojure.contrib.core"/> <arg value="clojure.contrib.def"/> <arg value="clojure.contrib.duck-streams"/> <arg value="clojure.contrib.except"/> <arg value="clojure.contrib.fcase"/> <arg value="clojure.contrib.generic"/> <arg value="clojure.contrib.generic.arithmetic"/> <arg value="clojure.contrib.generic.collection"/> <arg value="clojure.contrib.generic.comparison"/> <arg value="clojure.contrib.generic.functor"/> <arg value="clojure.contrib.generic.math-functions"/> <arg value="clojure.contrib.import-static"/> <arg value="clojure.contrib.javadoc.browse"/> <arg value="clojure.contrib.javadoc.browse-ui"/> <arg value="clojure.contrib.lazy-seqs"/> <arg value="clojure.contrib.mmap"/> <arg value="clojure.contrib.macros"/> <arg value="clojure.contrib.monads"/> <arg value="clojure.contrib.ns-utils"/> <arg value="clojure.contrib.pprint.ColumnWriter"/> <arg value="clojure.contrib.pprint.PrettyWriter"/> <arg value="clojure.contrib.pprint"/> <arg value="clojure.contrib.pprint.utilities"/> <arg value="clojure.contrib.probabilities.dist"/> <arg value="clojure.contrib.prxml"/> <arg value="clojure.contrib.repl-ln"/> <arg value="clojure.contrib.repl-utils"/> <arg value="clojure.contrib.seq-utils"/> <arg value="clojure.contrib.set"/> <arg value="clojure.contrib.server-socket"/> <arg value="clojure.contrib.sql.internal"/> <arg value="clojure.contrib.sql"/> <arg value="clojure.contrib.str-utils"/> <arg value="clojure.contrib.stream-utils"/> <arg value="clojure.contrib.test-clojure"/> <arg value="clojure.contrib.test-is"/> <arg value="clojure.contrib.trace"/> <arg value="clojure.contrib.types"/> <arg value="clojure.contrib.zip-filter"/> <arg value="clojure.contrib.graph"/> <arg value="clojure.contrib.datalog"/> <arg value="clojure.contrib.datalog.database"/> <arg value="clojure.contrib.datalog.literals"/> <arg value="clojure.contrib.datalog.magic"/> <arg value="clojure.contrib.datalog.rules"/> <arg value="clojure.contrib.datalog.softstrat"/> <arg value="clojure.contrib.datalog.util"/> <arg value="clojure.contrib.dataflow"/> </java> </target> <target name="jar" description="Create jar files." depends="compile_clojure"> <jar jarfile="${jarfile}"> <fileset file="epl-v10.html"/> <fileset dir="${src}" includes="**/*.clj"/> <fileset dir="${build}" includes="**/*.class"/> <manifest> <attribute name="Class-Path" value="."/> </manifest> </jar> <jar jarfile="${slimjarfile}"> <fileset file="epl-v10.html"/> <fileset dir="${src}" includes="**/*.clj"/> <manifest> <attribute name="Class-Path" value="."/> </manifest> </jar> </target> <target name="clean-build" depends="clean,compile_clojure,test,jar" description="Clean build with tests."/> <macrodef name="build-and-deploy"> <attribute name="target-dir" description="Root of Maven repository"/> <sequential> <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"/> <mvn:pom file="pom.xml" id="contrib.pom"/> <mvn:dependencies pomRefId="contrib.pom"/> <antcall target="clean-build"> <param name="clojure.jar" value="${org.clojure:clojure-lang:jar}"/> </antcall> <mvn:deploy file="${jarfile}" pomrefid="contrib.pom"> <attach file="${slimjarfile}" classifier="slim"/> <remoteRepository url="file:@{target-dir}"/> </mvn:deploy> </sequential> </macrodef> <target name="nightly-build" description="Build and deploy to nightly (snapshot) repository."> <build-and-deploy target-dir="${snapshot.repo.dir}"/> </target> <target name="stable-build" description="Build and deploy to stable repository."> <build-and-deploy target-dir="${stable.repo.dir}"/> </target> <path id="cobertura.classpath"> <fileset dir="cobertura"> <include name="cobertura.jar" /> <include name="lib/**/*.jar" /> </fileset> </path> <taskdef classpathref="cobertura.classpath" resource="tasks.properties" /> <target name="instrument" depends="compile_clojure"> <mkdir dir="cobertura/instrumented"/> <delete file="cobertura.ser" /> <cobertura-instrument todir="cobertura/instrumented"> <ignore regex="org.apache.log4j.*" /> <fileset dir="${build}"> <include name="**/*.class" /> <exclude name="**/*Test.class" /> </fileset> </cobertura-instrument> </target> </project>