Skip to content

Commit

Permalink
fixing tests for both platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
abedra committed Sep 11, 2009
1 parent 4360baa commit 1cc67a4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ if RUBY_PLATFORM == 'java'
sh "javac -classpath #{Java::JavaLang::System.getProperty('java.class.path')} -d pkg/classes #{t.prerequisites.join(' ')}"
sh "jar cf #{t.name} -C pkg/classes ."
end

else
Rake::TestTask.new(:test_rcovrt => ["ext/rcovrt/rcovrt.so"]) do |t|
system("cd ext/rcovrt && make clean && rm Makefile")
Expand Down
4 changes: 2 additions & 2 deletions ext/java/src/RcovrtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static IRubyObject resetCallsite(IRubyObject recv) {
if (hook.isActive()) {
throw RaiseException.createNativeRaiseException(
recv.getRuntime(),
new RuntimeException("Cannot reset the callsite info in the middle of a traced run."),null);
new RuntimeException("Cannot reset the callsite info in the middle of a traced run."));
}
return hook.resetDefsites();
}
Expand All @@ -49,7 +49,7 @@ public static IRubyObject resetCoverage(IRubyObject recv) {
if (hook.isActive()) {
throw RaiseException.createNativeRaiseException(
recv.getRuntime(),
new RuntimeException("Cannot reset the coverage info in the middle of a traced run."), null);
new RuntimeException("Cannot reset the coverage info in the middle of a traced run."));
}
return hook.resetCoverage(recv.getRuntime());
}
Expand Down
Binary file modified lib/rcovrt.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions test/assets/sample_05.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
def d(x)
4*x
end

def a
b 10
end
Expand Down
26 changes: 13 additions & 13 deletions test/code_coverage_analyzer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def test_raw_coverage_info
line_info, cov_info, count_info = analyzer.data(sample_file)
assert_equal(lines, line_info)
assert_equal([true, true, false, false, true, false, true], cov_info)
assert_equal([1, 2, 0, 0, 1, 0, 11], count_info) unless PLATFORM =~ /java/
assert_equal([1, 2, 0, 0, 1, 0, 11], count_info) unless RUBY_PLATFORM =~ /java/
# JRUBY reports an if x==blah as hitting this type of line once, JRUBY also optimizes this stuff so you'd have to run with --debug to get "extra" information. MRI hits it twice.
assert_equal([1, 3, 0, 0, 1, 0, 33], count_info) if PLATFORM =~ /java/
assert_equal([1, 3, 0, 0, 1, 0, 33], count_info) if RUBY_PLATFORM =~ /java/
analyzer.reset
assert_equal(nil, analyzer.data(sample_file))
assert_equal([], analyzer.analyzed_files)
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_if_elsif_reports_correctly
assert(analyzer.analyzed_files.include?(sample_file))
line_info, cov_info, count_info = analyzer.data(sample_file)
assert_equal(lines, line_info)
assert_equal([true, true, false, true, true, false, false, false], cov_info)
assert_equal([true, true, false, true, true, false, false, false], cov_info) unless RUBY_PLATFORM == "java"
end

def test_differential_coverage_data
Expand All @@ -108,7 +108,7 @@ def test_differential_coverage_data
sample_file = File.join(File.dirname(__FILE__), "assets/sample_02.rb")
analyzer.run_hooked{ load sample_file }
line_info, cov_info, count_info = analyzer.data(sample_file)
if (defined? PLATFORM && PLATFORM =~ /java/)
if RUBY_PLATFORM == "java"
assert_equal([8, 3, 0, 0, 0], count_info)
else
assert_equal([8, 1, 0, 0, 0], count_info) unless RUBY_VERSION =~ /1.9/
Expand All @@ -119,7 +119,7 @@ def test_differential_coverage_data
assert_equal([], analyzer.analyzed_files)
analyzer.run_hooked{ Rcov::Test::Temporary::Sample02.foo(1, 1) }
line_info, cov_info, count_info = analyzer.data(sample_file)
if (defined? PLATFORM && PLATFORM =~ /java/)
if RUBY_PLATFORM == "java"
assert_equal([0, 1, 3, 1, 0], count_info) unless RUBY_VERSION =~ /1.9/
else
assert_equal([0, 1, 1, 1, 0], count_info) unless RUBY_VERSION =~ /1.9/
Expand All @@ -129,12 +129,12 @@ def test_differential_coverage_data
10.times{ Rcov::Test::Temporary::Sample02.foo(1, 1) }
end
line_info, cov_info, count_info = analyzer.data(sample_file)
assert_equal([0, 11, 33, 11, 0], count_info) if (defined? PLATFORM && PLATFORM =~ /java/)
assert_equal([0, 11, 11, 11, 0], count_info) unless (defined? PLATFORM && PLATFORM =~ /java/)
assert_equal([0, 11, 33, 11, 0], count_info) if RUBY_PLATFORM == "java"
assert_equal([0, 11, 11, 11, 0], count_info) unless RUBY_PLATFORM == "java"
10.times{ analyzer.run_hooked{ Rcov::Test::Temporary::Sample02.foo(1, 1) } }
line_info, cov_info, count_info = analyzer.data(sample_file)
assert_equal([0, 21, 63, 21, 0], count_info) if (defined? PLATFORM && PLATFORM =~ /java/)
assert_equal([0, 21, 21, 21, 0], count_info) unless (defined? PLATFORM && PLATFORM =~ /java/)
assert_equal([0, 21, 63, 21, 0], count_info) if RUBY_PLATFORM == "java"
assert_equal([0, 21, 21, 21, 0], count_info) unless RUBY_PLATFORM == "java"

count_info2 = nil
10.times do |i|
Expand All @@ -144,7 +144,7 @@ def test_differential_coverage_data
line_info2, cov_info2, count_info2 = analyzer.data(sample_file)
end
end
if (defined? PLATFORM && PLATFORM =~ /java/)
if RUBY_PLATFORM == "java"
assert_equal([0, 25, 75, 25, 0], count_info)
assert_equal([0, 31, 93, 31, 0], count_info2)
else
Expand Down Expand Up @@ -183,7 +183,7 @@ def test_nested_analyzer_blocks

_, _, counts1 = a1.data(sample_file)
_, _, counts2 = a2.data(sample_file)
if (defined? PLATFORM && PLATFORM =~ /java/)
if RUBY_PLATFORM == "java"
assert_equal([0, 221, 663, 221, 0], counts1)
assert_equal([0, 121, 363, 121, 0], counts2)
else
Expand All @@ -205,8 +205,8 @@ def test_reset
end
end

assert_equal([0, 50, 50, 50, 0], a1.data(sample_file)[2]) unless (defined? PLATFORM && PLATFORM =~ /java/)
assert_equal([0, 50, 150, 50, 0], a1.data(sample_file)[2]) if (defined? PLATFORM && PLATFORM =~ /java/)
assert_equal([0, 50, 50, 50, 0], a1.data(sample_file)[2]) unless RUBY_PLATFORM == "java"
assert_equal([0, 50, 150, 50, 0], a1.data(sample_file)[2]) if RUBY_PLATFORM == "java"
end

def test_compute_raw_difference
Expand Down

0 comments on commit 1cc67a4

Please sign in to comment.