Permalink
Browse files

Only warn when the new 'debug' MOCHA_OPTION is supplied.

I've added various debug warning statement in recent commits, but these should not be enabled by default. Also we now need to deal with multiple MOCHA_OPTIONS which should be supplied in a comma-delimited list.
  • Loading branch information...
floehopper committed Jun 5, 2010
1 parent 02e37c9 commit cdfe7db1eeda40fc537418aabf70fc8c2662e251
@@ -1,3 +1,4 @@
require 'mocha/options'
require 'mocha_standalone'
require 'mocha/configuration'
require 'mocha/integration'
@@ -23,7 +23,7 @@ class TestCase
'unknown'
end

warn "Detected MiniTest version: #{mini_test_version}"
warn "Detected MiniTest version: #{mini_test_version}" if $options['debug']

if (mini_test_version >= '1.3.0') && (mini_test_version <= '1.3.1')
include Mocha::Integration::MiniTest::Version13
@@ -34,10 +34,10 @@ class TestCase
elsif (mini_test_version >= '1.4.2') && (mini_test_version <= '1.6.0')
include Mocha::Integration::MiniTest::Version142AndAbove
elsif (mini_test_version > '1.6.0')
warn "*** MiniTest integration has not been verified but patching anyway ***"
warn "*** MiniTest integration has not been verified but patching anyway ***" if $options['debug']
include Mocha::Integration::MiniTest::Version142AndAbove
else
warn "*** No Mocha integration for MiniTest version ***"
warn "*** No Mocha integration for MiniTest version ***" if $options['debug']
end

end
@@ -8,7 +8,7 @@ module MiniTest

module Version13
def self.included(mod)
warn "Monkey patching MiniTest v1.3"
warn "Monkey patching MiniTest v1.3" if $options['debug']
end
def run runner
assertion_counter = AssertionCounter.new(self)
@@ -9,7 +9,7 @@ module MiniTest

module Version140
def self.included(mod)
warn "Monkey patching MiniTest v1.4.0"
warn "Monkey patching MiniTest v1.4.0" if $options['debug']
end
def run runner
assertion_counter = AssertionCounter.new(self)
@@ -9,7 +9,7 @@ module MiniTest

module Version142AndAbove
def self.included(mod)
warn "Monkey patching MiniTest >= v1.4.2"
warn "Monkey patching MiniTest >= v1.4.2" if $options['debug']
end
def run runner
trap 'INFO' do
@@ -24,8 +24,10 @@ class TestCase
'1.x'
end

warn "Detected Ruby version: #{RUBY_VERSION}"
warn "Detected Test::Unit version: #{test_unit_version}"
if $options['debug']
warn "Detected Ruby version: #{RUBY_VERSION}"
warn "Detected Test::Unit version: #{test_unit_version}"
end

if (test_unit_version == '1.x') || (test_unit_version == '1.2.3')
if RUBY_VERSION < '1.8.6'
@@ -40,10 +42,10 @@ class TestCase
elsif (test_unit_version >= '2.0.3') && (test_unit_version <= '2.0.9')
include Mocha::Integration::TestUnit::GemVersion203To209
elsif (test_unit_version > '2.0.9')
warn "*** Test::Unit integration has not been verified but patching anyway ***"
warn "*** Test::Unit integration has not been verified but patching anyway ***" if $options['debug']
include Mocha::Integration::TestUnit::GemVersion203To209
else
warn "*** No Mocha integration for Test::Unit version ***"
warn "*** No Mocha integration for Test::Unit version ***" if $options['debug']
end

end
@@ -10,7 +10,7 @@ module TestUnit

module GemVersion200
def self.included(mod)
warn "Monkey patching Test::Unit gem v2.0.0"
warn "Monkey patching Test::Unit gem v2.0.0" if $options['debug']
end
def run(result)
assertion_counter = AssertionCounter.new(result)
@@ -10,7 +10,7 @@ module TestUnit

module GemVersion201To202
def self.included(mod)
warn "Monkey patching Test::Unit gem >= v2.0.1 and <= v2.0.2"
warn "Monkey patching Test::Unit gem >= v2.0.1 and <= v2.0.2" if $options['debug']
end
def run(result)
assertion_counter = AssertionCounter.new(result)
@@ -10,7 +10,7 @@ module TestUnit

module GemVersion203To209
def self.included(mod)
warn "Monkey patching Test::Unit gem >= v2.0.3 and <= v2.0.9"
warn "Monkey patching Test::Unit gem >= v2.0.3 and <= v2.0.9" if $options['debug']
end
def run(result)
assertion_counter = AssertionCounter.new(result)
@@ -10,7 +10,7 @@ module TestUnit

module RubyVersion185AndBelow
def self.included(mod)
warn "Monkey patching Test::Unit for Ruby <= v1.8.5"
warn "Monkey patching Test::Unit for Ruby <= v1.8.5" if $options['debug']
end
def run(result)
assertion_counter = AssertionCounter.new(result)
@@ -10,7 +10,7 @@ module TestUnit

module RubyVersion186AndAbove
def self.included(mod)
warn "Monkey patching Test::Unit for Ruby >= v1.8.6"
warn "Monkey patching Test::Unit for Ruby >= v1.8.6" if $options['debug']
end
def run(result)
assertion_counter = AssertionCounter.new(result)
@@ -0,0 +1 @@
$options = (ENV['MOCHA_OPTIONS'] || '').split(',').inject({}) { |hash, key| hash[key] = true; hash }
@@ -8,7 +8,8 @@
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'unit', 'parameter_matchers'))
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'acceptance'))

if ENV['MOCHA_OPTIONS'] == 'use_test_unit_gem'
require 'mocha/options'
if $options['use_test_unit_gem']
require 'rubygems'
gem 'test-unit'
end

0 comments on commit cdfe7db

Please sign in to comment.