From d17116f3b151373d8ee76a8ecb2a56b3a90995f8 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Thu, 22 Mar 2012 18:20:02 +0100 Subject: [PATCH 1/3] Turn on warnings in tests. --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index cc23a7c2..2ad73ba9 100644 --- a/Rakefile +++ b/Rakefile @@ -8,6 +8,7 @@ Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.test_files = FileList['test/test_*.rb'] test.verbose = true + test.warning = true end require 'cucumber/rake/task' From 186eb990440732c4e8a6470fab6c182a58253e9b Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 23 Mar 2012 20:10:52 +0100 Subject: [PATCH 2/3] Fix all 'instance variable not initialize' warnings. --- lib/simplecov.rb | 2 +- lib/simplecov/configuration.rb | 8 ++++---- lib/simplecov/result.rb | 4 ++-- lib/simplecov/source_file.rb | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/simplecov.rb b/lib/simplecov.rb index 08fc98d7..7395feea 100644 --- a/lib/simplecov.rb +++ b/lib/simplecov.rb @@ -48,7 +48,7 @@ def result SimpleCov::ResultMerger.store_result(@result) if @result return SimpleCov::ResultMerger.merged_result else - return @result + return @result if defined? @result end ensure self.running = false diff --git a/lib/simplecov/configuration.rb b/lib/simplecov/configuration.rb index f6294d43..8c5c48fc 100644 --- a/lib/simplecov/configuration.rb +++ b/lib/simplecov/configuration.rb @@ -14,7 +14,7 @@ module SimpleCov::Configuration # Configure with SimpleCov.root('/my/project/path') # def root(root=nil) - return @root if @root and root.nil? + return @root if defined? @root and root.nil? @root = File.expand_path(root || Dir.getwd) end @@ -24,7 +24,7 @@ def root(root=nil) # Configure with SimpleCov.coverage_dir('cov') # def coverage_dir(dir=nil) - return @coverage_dir if @coverage_dir and dir.nil? + return @coverage_dir if defined? @coverage_dir and dir.nil? @coverage_dir = (dir || 'coverage') end @@ -67,7 +67,7 @@ def command_name(name=nil) # Configure with: SimpleCov.formatter(SimpleCov::Formatter::SimpleFormatter) # def formatter(formatter=nil) - return @formatter if @formatter and formatter.nil? + return @formatter if defined? @formatter and formatter.nil? @formatter = formatter raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter @formatter @@ -81,7 +81,7 @@ def formatter(formatter=nil) # Configure with SimpleCov.nocov_token('skip') or it's alias SimpleCov.skip_token('skip') # def nocov_token(nocov_token=nil) - return @nocov_token if @nocov_token and nocov_token.nil? + return @nocov_token if defined? @nocov_token and nocov_token.nil? @nocov_token = (nocov_token || 'nocov') end alias_method :skip_token, :nocov_token diff --git a/lib/simplecov/result.rb b/lib/simplecov/result.rb index 9a126cf0..83231a84 100644 --- a/lib/simplecov/result.rb +++ b/lib/simplecov/result.rb @@ -58,7 +58,7 @@ def covered_strength # Returns the count of lines that are covered def covered_lines - return @covered_lines if @covered_lines + return @covered_lines if defined? @covered_lines @covered_lines = 0 @files.each do |file| original_result[file.filename].each do |line_result| @@ -70,7 +70,7 @@ def covered_lines # Returns the count of missed lines def missed_lines - return @missed_lines if @missed_lines + return @missed_lines if defined? @missed_lines @missed_lines = 0 @files.each do |file| original_result[file.filename].each do |line_result| diff --git a/lib/simplecov/source_file.rb b/lib/simplecov/source_file.rb index fdf343ef..4e7899e5 100644 --- a/lib/simplecov/source_file.rb +++ b/lib/simplecov/source_file.rb @@ -84,7 +84,7 @@ def initialize(filename, coverage) # Returns all source lines for this file as instances of SimpleCov::SourceFile::Line, # and thus including coverage data. Aliased as :source_lines def lines - return @lines unless @lines.nil? + return @lines if defined? @lines # Warning to identify condition from Issue #56 if coverage.size > src.size From 07a134be747f34143696c1358d3f4650f4caaf88 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 23 Mar 2012 20:12:25 +0100 Subject: [PATCH 3/3] Fix 'ambiguous first argument' warning. --- test/test_source_file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_source_file.rb b/test/test_source_file.rb index 0689d33a..182a5bc7 100644 --- a/test/test_source_file.rb +++ b/test/test_source_file.rb @@ -68,7 +68,7 @@ class TestSourceFile < Test::Unit::TestCase @source_file.lines end - assert_match /^Warning: coverage data provided/, captured_output + assert_match(/^Warning: coverage data provided/, captured_output) end end