relevance-rcov 0.9.0 → 0.9.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -40,11 +40,27 @@ Rcov::RcovTask.new(:rcov_ccanalyzer) do |t|
40
40
  end
41
41
 
42
42
  desc "Run the unit tests with rcovrt."
43
- Rake::TestTask.new(:test_rcovrt => ["ext/rcovrt/rcovrt.so"]) do |t|
44
- system("cd ext/rcovrt && make clean && rm Makefile")
45
- t.libs << "ext/rcovrt"
46
- t.test_files = FileList['test/*_test.rb']
47
- t.verbose = true
43
+ if RUBY_PLATFORM == 'java'
44
+ Rake::TestTask.new(:test_rcovrt => ["lib/rcovrt.jar"]) do |t|
45
+ t.libs << "lib"
46
+ t.ruby_opts << "--debug"
47
+ t.test_files = FileList['test/*_test.rb']
48
+ t.verbose = true
49
+ end
50
+
51
+ file "lib/rcovrt.jar" => FileList["ext/java/**/*.java"] do |t|
52
+ rm_f "lib/rcovrt.jar"
53
+ mkdir_p "pkg/classes"
54
+ sh "javac -classpath #{Java::JavaLang::System.getProperty('java.class.path')} -d pkg/classes #{t.prerequisites.join(' ')}"
55
+ sh "jar cf #{t.name} -C pkg/classes ."
56
+ end
57
+ else
58
+ Rake::TestTask.new(:test_rcovrt => ["ext/rcovrt/rcovrt.so"]) do |t|
59
+ system("cd ext/rcovrt && make clean && rm Makefile")
60
+ t.libs << "ext/rcovrt"
61
+ t.test_files = FileList['test/*_test.rb']
62
+ t.verbose = true
63
+ end
48
64
  end
49
65
 
50
66
  file "ext/rcovrt/rcovrt.so" => FileList["ext/rcovrt/*.c"] do
data/THANKS CHANGED
@@ -1,3 +1,11 @@
1
+ Jay McGaffigan:
2
+ * JRuby support integrated from original rcov4j
3
+
4
+ Aaron Bedra:
5
+ * major refactoring
6
+ * added threshold testing
7
+ * Took on the task of keeping RCov going
8
+
1
9
  Corey Ehmke (Bantik):
2
10
  * redesigned index and detail XHTML
3
11
  * added sortable columns in coverage table
@@ -1,8 +1,12 @@
1
1
  module Rcov
2
2
  class BaseFormatter # :nodoc:
3
3
  require 'pathname'
4
- require 'mkmf'
5
- ignore_files = [/\A#{Regexp.escape(Pathname.new(::Config::CONFIG['libdir']).cleanpath.to_s)}/, /\btc_[^.]*.rb/, /_test\.rb\z/, /\btest\//, /\bvendor\//, /\A#{Regexp.escape(__FILE__)}\z/]
4
+ ignore_files = [ /\btc_[^.]*.rb/, /_test\.rb\z/, /\btest\//, /\bvendor\//, /\A#{Regexp.escape(__FILE__)}\z/]
5
+
6
+ unless RUBY_PLATFORM =~ /java/
7
+ require 'mkmf'
8
+ ignore_files << [/\A#{Regexp.escape(Pathname.new(::Config::CONFIG['libdir']).cleanpath.to_s)}/]
9
+ end
6
10
 
7
11
  DEFAULT_OPTS = { :ignore => ignore_files, :sort => :name, :sort_reverse => false,
8
12
  :output_threshold => 101, :dont_ignore => [], :callsite_analyzer => nil, \
@@ -3,7 +3,7 @@
3
3
  # See LICENSE for licensing information.
4
4
 
5
5
  module Rcov
6
- VERSION = "0.9.0"
6
+ VERSION = "0.9.1.1"
7
7
  RELEASE_DATE = "2009-08-30"
8
8
  RCOVRT_ABI = [2,0,0]
9
9
  UPSTREAM_URL = "http://github.com/relevance/rcov"
@@ -47,7 +47,9 @@ EOF
47
47
  line_info, cov_info, count_info = analyzer.data(sample_file)
48
48
  assert_equal(lines, line_info)
49
49
  assert_equal([true, true, false, false, true, false, true], cov_info)
50
- assert_equal([1, 2, 0, 0, 1, 0, 11], count_info)
50
+ assert_equal([1, 2, 0, 0, 1, 0, 11], count_info) unless RUBY_PLATFORM =~ /java/
51
+ # 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.
52
+ assert_equal([1, 3, 0, 0, 1, 0, 33], count_info) if RUBY_PLATFORM =~ /java/
51
53
  analyzer.reset
52
54
  assert_equal(nil, analyzer.data(sample_file))
53
55
  assert_equal([], analyzer.analyzed_files)
@@ -80,6 +82,18 @@ EOF
80
82
  assert_equal(counts, ncounts)
81
83
  end
82
84
 
85
+ def test_if_elsif_reports_correctly
86
+ sample_file = File.join(File.dirname(__FILE__), "assets/sample_06.rb")
87
+ lines = File.readlines(sample_file)
88
+ analyzer = Rcov::CodeCoverageAnalyzer.new
89
+ analyzer.run_hooked{ load sample_file }
90
+ assert_equal(lines, SCRIPT_LINES__[sample_file][0, lines.size])
91
+ assert(analyzer.analyzed_files.include?(sample_file))
92
+ line_info, cov_info, count_info = analyzer.data(sample_file)
93
+ assert_equal(lines, line_info)
94
+ assert_equal([true, true, false, true, true, false, false, false], cov_info) unless RUBY_PLATFORM == "java"
95
+ end
96
+
83
97
  def test_differential_coverage_data
84
98
  sample_file = File.join(File.dirname(__FILE__), "assets/sample_01.rb")
85
99
  lines = File.readlines(sample_file)
@@ -94,23 +108,33 @@ EOF
94
108
  sample_file = File.join(File.dirname(__FILE__), "assets/sample_02.rb")
95
109
  analyzer.run_hooked{ load sample_file }
96
110
  line_info, cov_info, count_info = analyzer.data(sample_file)
97
- assert_equal([8, 1, 0, 0, 0], count_info) unless RUBY_VERSION =~ /1.9/
98
- assert_equal([4, 1, 0, 0, 4], count_info) if RUBY_VERSION =~ /1.9/
111
+ if RUBY_PLATFORM == "java"
112
+ assert_equal([8, 3, 0, 0, 0], count_info)
113
+ else
114
+ assert_equal([8, 1, 0, 0, 0], count_info) unless RUBY_VERSION =~ /1.9/
115
+ assert_equal([4, 1, 0, 0, 4], count_info) if RUBY_VERSION =~ /1.9/
116
+ end
99
117
 
100
118
  analyzer.reset
101
119
  assert_equal([], analyzer.analyzed_files)
102
120
  analyzer.run_hooked{ Rcov::Test::Temporary::Sample02.foo(1, 1) }
103
121
  line_info, cov_info, count_info = analyzer.data(sample_file)
104
- assert_equal([0, 1, 1, 1, 0], count_info) unless RUBY_VERSION =~ /1.9/
105
- assert_equal([0, 2, 1, 0, 0], count_info) if RUBY_VERSION =~ /1.9/
122
+ if RUBY_PLATFORM == "java"
123
+ assert_equal([0, 1, 3, 1, 0], count_info) unless RUBY_VERSION =~ /1.9/
124
+ else
125
+ assert_equal([0, 1, 1, 1, 0], count_info) unless RUBY_VERSION =~ /1.9/
126
+ assert_equal([0, 2, 1, 0, 0], count_info) if RUBY_VERSION =~ /1.9/
127
+ end
106
128
  analyzer.run_hooked do
107
129
  10.times{ Rcov::Test::Temporary::Sample02.foo(1, 1) }
108
130
  end
109
131
  line_info, cov_info, count_info = analyzer.data(sample_file)
110
- assert_equal([0, 11, 11, 11, 0], count_info)
132
+ assert_equal([0, 11, 33, 11, 0], count_info) if RUBY_PLATFORM == "java"
133
+ assert_equal([0, 11, 11, 11, 0], count_info) unless RUBY_PLATFORM == "java"
111
134
  10.times{ analyzer.run_hooked{ Rcov::Test::Temporary::Sample02.foo(1, 1) } }
112
135
  line_info, cov_info, count_info = analyzer.data(sample_file)
113
- assert_equal([0, 21, 21, 21, 0], count_info)
136
+ assert_equal([0, 21, 63, 21, 0], count_info) if RUBY_PLATFORM == "java"
137
+ assert_equal([0, 21, 21, 21, 0], count_info) unless RUBY_PLATFORM == "java"
114
138
 
115
139
  count_info2 = nil
116
140
  10.times do |i|
@@ -120,8 +144,13 @@ EOF
120
144
  line_info2, cov_info2, count_info2 = analyzer.data(sample_file)
121
145
  end
122
146
  end
123
- assert_equal([0, 25, 25, 25, 0], count_info)
124
- assert_equal([0, 31, 31, 31, 0], count_info2)
147
+ if RUBY_PLATFORM == "java"
148
+ assert_equal([0, 25, 75, 25, 0], count_info)
149
+ assert_equal([0, 31, 93, 31, 0], count_info2)
150
+ else
151
+ assert_equal([0, 25, 25, 25, 0], count_info)
152
+ assert_equal([0, 31, 31, 31, 0], count_info2)
153
+ end
125
154
  end
126
155
 
127
156
  def test_nested_analyzer_blocks
@@ -154,8 +183,13 @@ EOF
154
183
 
155
184
  _, _, counts1 = a1.data(sample_file)
156
185
  _, _, counts2 = a2.data(sample_file)
157
- assert_equal([0, 221, 221, 221, 0], counts1)
158
- assert_equal([0, 121, 121, 121, 0], counts2)
186
+ if RUBY_PLATFORM == "java"
187
+ assert_equal([0, 221, 663, 221, 0], counts1)
188
+ assert_equal([0, 121, 363, 121, 0], counts2)
189
+ else
190
+ assert_equal([0, 221, 221, 221, 0], counts1)
191
+ assert_equal([0, 121, 121, 121, 0], counts2)
192
+ end
159
193
  end
160
194
 
161
195
  def test_reset
@@ -171,7 +205,8 @@ EOF
171
205
  end
172
206
  end
173
207
 
174
- assert_equal([0, 50, 50, 50, 0], a1.data(sample_file)[2])
208
+ assert_equal([0, 50, 50, 50, 0], a1.data(sample_file)[2]) unless RUBY_PLATFORM == "java"
209
+ assert_equal([0, 50, 150, 50, 0], a1.data(sample_file)[2]) if RUBY_PLATFORM == "java"
175
210
  end
176
211
 
177
212
  def test_compute_raw_difference
@@ -41,8 +41,10 @@ class TestFunctional < Test::Unit::TestCase
41
41
  def run_rcov(opts, script="assets/sample_04.rb", opts_tail="")
42
42
  rcov = @@dir+"../bin/rcov"
43
43
  ruby_opts = "-I../lib:../ext/rcovrt"
44
+ ruby = "ruby"
45
+ ruby = "jruby" if RUBY_PLATFORM =~ /java/
44
46
  with_testdir do
45
- `cd #{@@dir}; ruby #{ruby_opts} #{rcov} #{opts} -o actual_coverage #{script} #{opts_tail}`
47
+ `cd #{@@dir}; #{ruby} #{ruby_opts} #{rcov} #{opts} -o actual_coverage #{script} #{opts_tail}`
46
48
  yield if block_given?
47
49
  end
48
50
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relevance-rcov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Relevance
8
8
  - Chad Humphries (spicycode)
9
9
  - Aaron Bedra (abedra)
10
+ - Jay McGaffigan
10
11
  - Mauricio Fernandez
11
12
  autorequire:
12
13
  bindir: bin