buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djspie...@apache.org
Subject svn commit: r776909 - /buildr/trunk/lib/buildr/java/cobertura.rb
Date Thu, 21 May 2009 01:18:22 GMT
Author: djspiewak
Date: Thu May 21 01:18:22 2009
New Revision: 776909

URL: http://svn.apache.org/viewvc?rev=776909&view=rev
Log:
Applied patch from Marko Sibakov

Modified:
    buildr/trunk/lib/buildr/java/cobertura.rb

Modified: buildr/trunk/lib/buildr/java/cobertura.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/cobertura.rb?rev=776909&r1=776908&r2=776909&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/cobertura.rb (original)
+++ buildr/trunk/lib/buildr/java/cobertura.rb Thu May 21 01:18:22 2009
@@ -19,7 +19,7 @@
 
 module Buildr
 
-  # Provides the <code>cobertura:html</code> and <code>cobertura:xml</code>
tasks.
+  # Provides the <code>cobertura:html</code>, <code>cobertura:xml</code>
and <code>cobertura:check</code> tasks.
   # Require explicitly using <code>require "buildr/cobertura"</code>.
   #
   # You can generate cobertura reports for a single project 
@@ -37,6 +37,16 @@
   #      cobertura.exclude 'some.foo.util.SimpleUtil'
   #      cobertura.exclude /*.Const(ants)?/i
   #   end
+  #
+  # When using <code>cobertura:check</code> you have to specify coverage limits
in <code>buildfile<code>. 
+  #
+  # Buildr::COBERTURA_CHECK_BRANCHRATE = "100"
+  # Buildr::COBERTURA_CHECK_LINERATE = "0"
+  # Buildr::COBERTURA_CHECK_TOTALBRANCHRATE = "100"
+  # Buildr::COBERTURA_CHECK_TOTALLINERATE = "96"
+  # Buildr::COBERTURA_CHECK_PACKAGELINERATE = "75"
+  # Buildr::COBERTURA_CHECK_PACKAGEBRANCHRATE = "100"
+  #
   module Cobertura
 
     VERSION = '1.9'
@@ -171,7 +181,7 @@
             project.test.with Cobertura.dependencies
             project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = cobertura.data_file
             
-            [:xml, :html].each do |format|
+            [:xml, :html, :check].each do |format|
               task format => ['instrument', 'test'] do 
                 info "Creating test coverage reports in #{cobertura.report_to(format)}"
                 Buildr.ant "cobertura" do |ant|
@@ -186,8 +196,22 @@
                 end
               end
             end
+            
+            [:check].each do |format|
+              task format => ['instrument', 'test'] do 
+                Buildr.ant "cobertura" do |ant|
+                  ant.taskdef :classpath=>Cobertura.requires.join(File::PATH_SEPARATOR),
:resource=>"tasks.properties"
+                  ant.send "cobertura-report", :format=>format, 
+                    :destdir=>cobertura.report_to(format), :datafile=>cobertura.data_file
do
+                    cobertura.sources.flatten.each do |src|
+                      ant.fileset(:dir=>src.to_s) if File.exist?(src.to_s)
+                    end
+                  end
+                end
+              end
+            end
+            
           end
-          
         end
 
         project.clean do
@@ -229,6 +253,18 @@
           end
         end
       end
+
+      [:check].each do |format|
+        report_target = report_to(format)
+        desc "Run the cobertura check "
+        task format => ["instrument", "test"] do
+          Buildr.ant "cobertura" do |ant|
+            ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
+            ant.send "cobertura-check", :datafile=>data_file, :branchrate=>COBERTURA_CHECK_BRANCHRATE,
:lineRate=>COBERTURA_CHECK_LINERATE, :totalBranchRate=>COBERTURA_CHECK_TOTALBRANCHRATE,
:totalLineRate=>COBERTURA_CHECK_TOTALLINERATE, :packageLineRate=>COBERTURA_CHECK_PACKAGELINERATE,
:packageBranchRate=>COBERTURA_CHECK_PACKAGEBRANCHRATE do
+          end
+        end
+      end
+    end
       
       task "clean" do
         rm_rf [report_to, data_file]



Mime
View raw message