Title: [1047] trunk/rcov4jr: Code tweaks and added event listening for c-call events.
Revision
1047
Author
kofno
Date
2008-07-10 23:03:52 -0400 (Thu, 10 Jul 2008)

Log Message

Code tweaks and added event listening for c-call events.
I also removed a test I had added for debugging, but that
isn't valid any more.

Modified Paths

Diff

Modified: trunk/rcov4jr/java/src/CallsiteHook.java (1046 => 1047)


--- trunk/rcov4jr/java/src/CallsiteHook.java	2008-07-10 19:16:37 UTC (rev 1046)
+++ trunk/rcov4jr/java/src/CallsiteHook.java	2008-07-11 03:03:52 UTC (rev 1047)
@@ -34,7 +34,7 @@
     }
 
     public boolean isInterestedInEvent(int event) {
-        return event == RUBY_EVENT_CALL;
+        return event == RUBY_EVENT_CALL || event == RUBY_EVENT_C_CALL;
     }
 
     public RubyArray getCallsiteInfo(Ruby runtime) {

Modified: trunk/rcov4jr/java/src/CoverageHook.java (1046 => 1047)


--- trunk/rcov4jr/java/src/CoverageHook.java	2008-07-10 19:16:37 UTC (rev 1046)
+++ trunk/rcov4jr/java/src/CoverageHook.java	2008-07-11 03:03:52 UTC (rev 1047)
@@ -61,7 +61,6 @@
         // update counts in COVER
         Long count = (Long) counts.get(line);
         if (count == null) {
-            System.out.println("Null count in " + file + ":" + line + ":" + name);
             count = Long.valueOf(0);
         }
         count = Long.valueOf(count.longValue() + 1);

Modified: trunk/rcov4jr/java/src/RcovrtService.java (1046 => 1047)


--- trunk/rcov4jr/java/src/RcovrtService.java	2008-07-10 19:16:37 UTC (rev 1046)
+++ trunk/rcov4jr/java/src/RcovrtService.java	2008-07-11 03:03:52 UTC (rev 1047)
@@ -7,9 +7,11 @@
 import org.jruby.RubySymbol;
 import org.jruby.exceptions.RaiseException;
 import org.jruby.anno.JRubyMethod;
+import org.jruby.runtime.ThreadContext;
 import org.jruby.runtime.builtin.IRubyObject;
 import org.jruby.runtime.load.BasicLibraryService;
 import org.jruby.javasupport.JavaEmbedUtils;
+import org.jruby.javasupport.JavaUtil;
 
 public class RcovrtService implements BasicLibraryService {
     
@@ -68,22 +70,21 @@
     */
     @JRubyMethod(name="generate_coverage_info", meta = true)
     public static IRubyObject generateCoverageInfo(IRubyObject recv) {
-        RubyHash cover = (RubyHash)CoverageHook.getCoverageHook().getCover(recv.getRuntime());
-		//copy a hash not sure there is a better way.
-		Ruby run = recv.getRuntime();
-		RubyHash xcover = RubyHash.newHash(run);
-		RubyArray keys = cover.keys();
-		RubyArray temp;
-		org.jruby.runtime.ThreadContext  ctx = run.getCurrentContext();
-		for (int i=0; i < keys.length().getLongValue(); i++) {
-			IRubyObject key = keys.aref(org.jruby.javasupport.JavaUtil.convertJavaToRuby(run, Long.valueOf(i)));
-			temp = ((RubyArray)cover.op_aref(ctx, key)).aryDup();
-			xcover.op_aset(ctx,key, temp);
-		}
+        Ruby run = recv.getRuntime();
+        RubyHash cover = (RubyHash)CoverageHook.getCoverageHook().getCover(run);
+        RubyHash xcover = RubyHash.newHash(run);
+        RubyArray keys = cover.keys();
+        RubyArray temp;
+        ThreadContext  ctx = run.getCurrentContext();
+        for (int i=0; i < keys.length().getLongValue(); i++) {
+            IRubyObject key = keys.aref(JavaUtil.convertJavaToRuby(run, Long.valueOf(i)));
+            temp = ((RubyArray)cover.op_aref(ctx, key)).aryDup();
+            xcover.op_aset(ctx,key, temp);
+        }
         RubyModule rcov__ = (RubyModule) recv.getRuntime().getModule("Rcov").getConstant("RCOV__");
 
-        if (rcov__.const_defined_p(RubySymbol.newSymbol(recv.getRuntime(), "COVER")).isTrue()) {
-            rcov__.remove_const(recv.getRuntime().newString("COVER"));
+        if (rcov__.const_defined_p(ctx, RubySymbol.newSymbol(recv.getRuntime(), "COVER")).isTrue()) {
+            rcov__.remove_const(ctx, recv.getRuntime().newString("COVER"));
         } 
         rcov__.defineConstant( "COVER", xcover );
 

Modified: trunk/rcov4jr/test/test_CodeCoverageAnalyzer.rb (1046 => 1047)


--- trunk/rcov4jr/test/test_CodeCoverageAnalyzer.rb	2008-07-10 19:16:37 UTC (rev 1046)
+++ trunk/rcov4jr/test/test_CodeCoverageAnalyzer.rb	2008-07-11 03:03:52 UTC (rev 1047)
@@ -175,22 +175,6 @@
     assert_equal([0, 50, 50, 50, 0], a1.data(sample_file)[2])
   end
 
-  def test_analyzed_files
-    a1 = Rcov::CodeCoverageAnalyzer.new
-    
-    sample_file = File.join(File.dirname(__FILE__), "sample_02.rb")
-    load sample_file
-
-    a1.run_hooked do
-      2.times do | i |
-        Rcov::Test::Temporary::Sample02.foo( 1, 1 )
-        a1.reset if ( i == 1 )        
-      end
-    end
-
-    assert_equal(  [0, 50, 50, 50, 0 ], a1.data( sample_file )[ 2 ] )
-  end
-
   def test_compute_raw_difference
     first = {"a" => [1,1,1,1,1]}
     last =  {"a" => [2,1,5,2,1], "b" => [1,2,3,4,5]}
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to