Diff
Modified: trunk/rcov4jr/README.txt (950 => 951)
--- trunk/rcov4jr/README.txt 2008-03-19 15:51:31 UTC (rev 950)
+++ trunk/rcov4jr/README.txt 2008-03-20 06:17:48 UTC (rev 951)
@@ -18,4 +18,8 @@
script with the --without-ext switch. You can download the tarball here:
http://rubyforge.org/frs/download.php/28270/rcov-0.8.1.2.tar.gz
+== ISSUES
+ * There may be a bug in report. There's a place where the possiblility of a file
+ being nil is never accounted for. Everything around it does account for nil.
+ This looks like it may be an rcov bug.
Modified: trunk/rcov4jr/java/src/CallsiteHook.java (950 => 951)
--- trunk/rcov4jr/java/src/CallsiteHook.java 2008-03-19 15:51:31 UTC (rev 950)
+++ trunk/rcov4jr/java/src/CallsiteHook.java 2008-03-20 06:17:48 UTC (rev 951)
@@ -93,6 +93,14 @@
return context.getRuntime().newArray((IRubyObject) ary);
}
+ /**
+ * TODO: The logic in this method really needs to be wrapped in a backtrace
+ * object or something. Then I could fix the file path issues that cause
+ * test failures.
+ * @param runtime
+ * @param backtrace
+ * @return
+ */
private RubyArray formatBacktrace(Ruby runtime, String backtrace) {
if ( backtrace == null ) {
System.out.println( "backtrace is null" );
@@ -102,7 +110,7 @@
Matcher matcher = backtracePattern.matcher(backtrace);
RubyArray ary = runtime.newArray();
- if (matcher.matches()) {
+ if (matcher.matches()) {
String method = matcher.group(4);
String file = matcher.group(1);
String line = matcher.group(2);
@@ -110,8 +118,9 @@
Long.valueOf( 0 ) :
Long.valueOf( line ) );
- ary.add((method == null ? runtime.getNil() : runtime
- .newSymbol(method)));
+ ary.add( ( method == null ?
+ runtime.getNil() :
+ runtime.newSymbol( method ) ) );
ary.add(file);
ary.add(lineNum);
}
Modified: trunk/rcov4jr/java/src/RcovrtService.java (950 => 951)
--- trunk/rcov4jr/java/src/RcovrtService.java 2008-03-19 15:51:31 UTC (rev 950)
+++ trunk/rcov4jr/java/src/RcovrtService.java 2008-03-20 06:17:48 UTC (rev 951)
@@ -39,6 +39,7 @@
return true;
}
+
public static IRubyObject resetCallsite(IRubyObject recv) {
CallsiteHook hook = CallsiteHook.getCallsiteHook();
if (hook.isActive()) {
@@ -67,51 +68,50 @@
return installRcovHook(recv, CoverageHook.getCoverageHook());
}
+ /**
+ TODO: I think this is broken. I'm not sure why, but recreating cover all the time seems bad.
+ */
public static IRubyObject generateCoverageInfo(IRubyObject recv) {
IRubyObject cover = CoverageHook.getCoverageHook().getCover(recv.getRuntime()).dup();
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"));
}
- rcov__.defineConstant("COVER", cover);
+ rcov__.defineConstant( "COVER", cover );
return cover;
}
public static IRubyObject removeCallsiteHook(IRubyObject recv) {
- return removeRcovHook(recv, CallsiteHook.getCallsiteHook());
+ return removeRcovHook( recv, CallsiteHook.getCallsiteHook() );
}
public static IRubyObject installCallsiteHook(IRubyObject recv) {
- return installRcovHook(recv, CallsiteHook.getCallsiteHook());
+ return installRcovHook( recv, CallsiteHook.getCallsiteHook() );
}
public static IRubyObject generateCallsiteInfo(IRubyObject recv) {
- return CallsiteHook.getCallsiteHook().getCallsiteInfo(recv.getRuntime()).dup();
+ return CallsiteHook.getCallsiteHook().getCallsiteInfo( recv.getRuntime() ).dup();
}
- public static IRubyObject getAbi(IRubyObject recv) {
+ public static IRubyObject getAbi( IRubyObject recv ) {
RubyArray ary = recv.getRuntime().newArray();
- ary.add(RubyFixnum.int2fix(recv.getRuntime(), 2L));
- ary.add(RubyFixnum.int2fix(recv.getRuntime(), 0L));
- ary.add(RubyFixnum.int2fix(recv.getRuntime(), 0L));
+ ary.add( RubyFixnum.int2fix( recv.getRuntime(), 2L ) );
+ ary.add( RubyFixnum.int2fix( recv.getRuntime(), 0L ) );
+ ary.add( RubyFixnum.int2fix( recv.getRuntime(), 0L ) );
return ary;
}
- private static IRubyObject removeRcovHook(IRubyObject recv, RcovHook hook) {
- if (!hook.isActive()) {
- hook.setActive(true);
- recv.getRuntime().addEventHook(hook);
- return recv.getRuntime().getTrue();
- } else {
- return recv.getRuntime().getFalse();
- }
+ private static IRubyObject removeRcovHook( IRubyObject recv, RcovHook hook ) {
+ hook.setActive( false );
+ recv.getRuntime().removeEventHook( hook );
+ return recv.getRuntime().getFalse();
}
- private static IRubyObject installRcovHook(IRubyObject recv, RcovHook hook) {
- if (!hook.isActive()) {
- hook.setActive(true);
- recv.getRuntime().addEventHook(hook);
+ private static IRubyObject installRcovHook( IRubyObject recv, RcovHook hook ) {
+ if ( !hook.isActive() ) {
+ hook.setActive( true );
+ recv.getRuntime().addEventHook( hook );
return recv.getRuntime().getTrue();
} else {
return recv.getRuntime().getFalse();
Modified: trunk/rcov4jr/specs/code_coverage_analyzer_spec.rb (950 => 951)
--- trunk/rcov4jr/specs/code_coverage_analyzer_spec.rb 2008-03-19 15:51:31 UTC (rev 950)
+++ trunk/rcov4jr/specs/code_coverage_analyzer_spec.rb 2008-03-20 06:17:48 UTC (rev 951)
@@ -1,3 +1,5 @@
+# Capturing some of the current behavior of rcov's CodeCoverageAnalyzer.
+# Not, strictly BDD, but should help isolate broken code when debugging.
require 'rubygems'
require 'rcov'
@@ -2,3 +4,3 @@
-describe Rcov::CodeCoverageAnalyzer, "hooks" do
+describe Rcov::CodeCoverageAnalyzer, "hooks" do
def hook_level
@@ -16,10 +18,10 @@
@code_coverage_analyzer.remove_hook
end
end
-
- it "should increase hook_level when a new one is installed" do
+
+ it "should increase hook_level on install" do
@code_coverage_analyzer.install_hook
- Rcov::CodeCoverageAnalyzer.send( :hook_level ).should == 1
+ hook_level.should == 1
end
it "should not throw an exception if one is removed without one being installed" do
@@ -29,3 +31,4 @@
end
end
+
Modified: trunk/rcov4jr/test/test_CodeCoverageAnalyzer.rb (950 => 951)
--- trunk/rcov4jr/test/test_CodeCoverageAnalyzer.rb 2008-03-19 15:51:31 UTC (rev 950)
+++ trunk/rcov4jr/test/test_CodeCoverageAnalyzer.rb 2008-03-20 06:17:48 UTC (rev 951)
@@ -168,13 +168,29 @@
a1.run_hooked do
100.times do |i|
Rcov::Test::Temporary::Sample02.foo(1, 1)
- a1.reset if i == 49
+ a1.reset if i == 49
end
end
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]}