Author: lacton
Date: Sun Sep 28 13:46:18 2008
New Revision: 699889

URL: http://svn.apache.org/viewvc?rev=699889&view=rev
Log:
buildr --prereqs should not display cobertura:html tasks for projects that 
don't have any source files

Modified:
    incubator/buildr/trunk/addon/buildr/cobertura.rb
    incubator/buildr/trunk/addon/buildr/emma.rb
    incubator/buildr/trunk/spec/addon/test_coverage_spec.rb

Modified: incubator/buildr/trunk/addon/buildr/cobertura.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/cobertura.rb?rev=699889&r1=699888&r2=699889&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/cobertura.rb (original)
+++ incubator/buildr/trunk/addon/buildr/cobertura.rb Sun Sep 28 13:46:18 2008
@@ -165,17 +165,17 @@
             project.test.dependencies.unshift cobertura.instrumented_dir
             project.test.with Cobertura.requires
             
project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = 
cobertura.data_file
-          end
-          
-          [:xml, :html].each do |format|
-            task format => ['instrument', 'test'] do 
-              info "Creating test coverage reports in 
#{cobertura.report_to(format)}"
-              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)
+            
+            [:xml, :html].each do |format|
+              task format => ['instrument', 'test'] do 
+                info "Creating test coverage reports in 
#{cobertura.report_to(format)}"
+                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

Modified: incubator/buildr/trunk/addon/buildr/emma.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/emma.rb?rev=699889&r1=699888&r2=699889&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/emma.rb (original)
+++ incubator/buildr/trunk/addon/buildr/emma.rb Sun Sep 28 13:46:18 2008
@@ -156,32 +156,31 @@
             project.test.dependencies.unshift emma.instrumented_dir
             project.test.with Emma.requires
             project.test.options[:properties]["emma.coverage.out.file"] = 
emma.coverage_file
-          end
-          
-          [:xml, :html].each do |format|
-            task format => ['instrument', 'test'] do
-              missing_required_files = [emma.metadata_file, 
emma.coverage_file].reject { |f| File.exist?(f) }
-              if missing_required_files.empty?
-                info "Creating test coverage reports in #{emma.report_dir}"
-                mkdir_p emma.report_dir, :verbose=>false
-                Emma.ant do |ant|
-                  ant.report do
-                    ant.infileset :file=>emma.metadata_file
-                    ant.infileset :file=>emma.coverage_file
-                    ant.send format, 
:outfile=>File.join(emma.report_to(format),"coverage.#{format}")
-                    ant.sourcepath do
-                      emma.sources.flatten.each do |src|
-                        ant.dirset(:dir=>src.to_s) if File.exist?(src.to_s)
+            
+            [:xml, :html].each do |format|
+              task format => ['instrument', 'test'] do
+                missing_required_files = [emma.metadata_file, 
emma.coverage_file].reject { |f| File.exist?(f) }
+                if missing_required_files.empty?
+                  info "Creating test coverage reports in #{emma.report_dir}"
+                  mkdir_p emma.report_dir, :verbose=>false
+                  Emma.ant do |ant|
+                    ant.report do
+                      ant.infileset :file=>emma.metadata_file
+                      ant.infileset :file=>emma.coverage_file
+                      ant.send format, 
:outfile=>File.join(emma.report_to(format),"coverage.#{format}")
+                      ant.sourcepath do
+                        emma.sources.flatten.each do |src|
+                          ant.dirset(:dir=>src.to_s) if File.exist?(src.to_s)
+                        end
                       end
                     end
                   end
+                else
+                  info "No test coverage report for #{project}. Missing: 
#{missing_required_files.join(', ')}"
                 end
-              else
-                info "No test coverage report for #{project}. Missing: 
#{missing_required_files.join(', ')}"
               end
             end
           end
-            
         end
 
         project.clean do

Modified: incubator/buildr/trunk/spec/addon/test_coverage_spec.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/addon/test_coverage_spec.rb?rev=699889&r1=699888&r2=699889&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/addon/test_coverage_spec.rb (original)
+++ incubator/buildr/trunk/spec/addon/test_coverage_spec.rb Sun Sep 28 13:46:18 
2008
@@ -225,6 +225,11 @@
   end
   
   describe 'project with no source' do
+    it 'should not define an html report task' do
+      define 'foo'
+      Rake::Task.task_defined?("foo:#{toolname}:html").should be(false)
+    end
+    
     it 'should not raise an error when instrumenting' do
       define('foo')
       lambda { task("foo:#{toolname}:instrument").invoke }.should_not 
raise_error


Reply via email to