You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by la...@apache.org on 2008/09/28 20:43:26 UTC

svn commit: r699879 - in /incubator/buildr/trunk: addon/buildr/cobertura.rb addon/buildr/emma.rb spec/addon/test_coverage_spec.rb

Author: lacton
Date: Sun Sep 28 11:43:26 2008
New Revision: 699879

URL: http://svn.apache.org/viewvc?rev=699879&view=rev
Log:
Cobertura and Emma instrumentation should handle gracefully a project with no source file

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=699879&r1=699878&r2=699879&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/cobertura.rb (original)
+++ incubator/buildr/trunk/addon/buildr/cobertura.rb Sun Sep 28 11:43:26 2008
@@ -158,6 +158,13 @@
             end
             
             task 'instrument' => instrumented
+            
+            # We now have two target directories with bytecode. It would make sense to remove compile.target
+            # and add instrumented instead, but apparently Cobertura only creates some of the classes, so
+            # we need both directories and instrumented must come first.
+            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|
@@ -177,13 +184,6 @@
           
         end
 
-        # We now have two target directories with bytecode. It would make sense to remove compile.target
-        # and add instrumented instead, but apparently Cobertura only creates some of the classes, so
-        # we need both directories and instrumented must come first.
-        project.test.dependencies.unshift cobertura.instrumented_dir
-        project.test.with Cobertura.requires
-        project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = cobertura.data_file
-        
         project.clean do
           rm_rf [cobertura.report_to, cobertura.data_file, cobertura.instrumented_dir], :verbose=>false
         end

Modified: incubator/buildr/trunk/addon/buildr/emma.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/emma.rb?rev=699879&r1=699878&r2=699879&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/emma.rb (original)
+++ incubator/buildr/trunk/addon/buildr/emma.rb Sun Sep 28 11:43:26 2008
@@ -151,6 +151,11 @@
             end
             
             task 'instrument' => instrumented
+            
+            # We now have two target directories with bytecode.
+            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|
@@ -179,11 +184,6 @@
             
         end
 
-        # We now have two target directories with bytecode.
-        project.test.dependencies.unshift emma.instrumented_dir
-        project.test.with Emma.requires
-        project.test.options[:properties]["emma.coverage.out.file"] = emma.coverage_file
-        
         project.clean do
           rm_rf [emma.report_dir, emma.coverage_file, emma.metadata_file, emma.instrumented_dir], :verbose=>false
         end

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=699879&r1=699878&r2=699879&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/addon/test_coverage_spec.rb (original)
+++ incubator/buildr/trunk/spec/addon/test_coverage_spec.rb Sun Sep 28 11:43:26 2008
@@ -60,6 +60,10 @@
     @tool_module.name.split('::').last.downcase
   end
 
+  def test_coverage_config
+    project('foo').send(toolname)
+  end
+  
   describe 'project-specific' do
 
     before do
@@ -67,10 +71,6 @@
       write_test :for=>'Foo', :in=>'src/test/java'
     end
 
-    def test_coverage_config
-      project('foo').send(toolname)
-    end
-
     describe 'clean' do
       before { define('foo') }
       
@@ -139,12 +139,6 @@
         task("foo:#{toolname}:instrument").invoke
         instrumented_dir.timestamp.should be_close(a_long_time_ago, 2)
       end
-      
-      it 'should not raise an error if project has no source files' do
-        rm 'src/main/java/Foo.java'
-        define('foo')
-        lambda { task("foo:#{toolname}:instrument").invoke }.should_not raise_error(RuntimeError)
-      end
     end
 
     describe 'testing classpath' do
@@ -229,4 +223,22 @@
       end
     end
   end
+  
+  describe 'project with no source' do
+    it 'should not raise an error when instrumenting' do
+      define('foo')
+      lambda { task("foo:#{toolname}:instrument").invoke }.should_not raise_error
+    end
+    
+    it 'should not add the instrumented directory to the testing classpath' do
+      define 'foo'
+      depends = project('foo').test.dependencies
+      depends.should_not include(test_coverage_config.instrumented_dir)
+    end
+    
+    it 'should not add the test coverage tools artifacts to the testing classpath' do
+      define('foo')
+      @tool_module.requires.each { |artifact| project('foo').test.dependencies.should_not include(artifact) }
+    end
+  end
 end
\ No newline at end of file