mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/test/: [DOC] Document Test::Unit, hide most submodules and
classes from rdoc. Since lib/test is only present as a compatibility layer with the legacy test suite many test/unit users will be using minitest or the test/unit gem instead. It is recommended to use one of these alternatives for writing new tests. This patch was based on a patch submitted by Steve Klabnik. [ruby-core:56694] [Bug #8778] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2572a9bf83
commit
b8ef79884b
5 changed files with 50 additions and 26 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Tue Aug 20 02:32:52 2013 Zachary Scott <e@zzak.io>
|
||||
|
||||
* lib/test/: [DOC] Document Test::Unit, hide most submodules and
|
||||
classes from rdoc. Since lib/test is only present as a compatibility
|
||||
layer with the legacy test suite many test/unit users will be using
|
||||
minitest or the test/unit gem instead. It is recommended to use one
|
||||
of these alternatives for writing new tests.
|
||||
|
||||
This patch was based on a patch submitted by Steve Klabnik.
|
||||
[ruby-core:56694] [Bug #8778]
|
||||
|
||||
Tue Aug 20 02:10:19 2013 Zachary Scott <e@zzak.io>
|
||||
|
||||
* lib/rss/rss.rb: [DOC] Document for constants by Steve Klabnik
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
# test/unit compatibility layer using minitest.
|
||||
|
||||
require 'minitest/unit'
|
||||
require 'test/unit/assertions'
|
||||
require 'test/unit/testcase'
|
||||
require 'optparse'
|
||||
|
||||
# See Test::Unit
|
||||
module Test
|
||||
##
|
||||
# Test::Unit is an implementation of the xUnit testing framework for Ruby.
|
||||
#
|
||||
# If you are writing new test code, please use MiniTest instead of Test::Unit.
|
||||
#
|
||||
# Test::Unit has been left in the standard library to support legacy test
|
||||
# suites.
|
||||
module Unit
|
||||
TEST_UNIT_IMPLEMENTATION = 'test/unit compatibility layer using minitest'
|
||||
TEST_UNIT_IMPLEMENTATION = 'test/unit compatibility layer using minitest' # :nodoc:
|
||||
|
||||
module RunCount
|
||||
module RunCount # :nodoc: all
|
||||
@@run_count = 0
|
||||
|
||||
def self.have_run?
|
||||
|
@ -29,7 +35,7 @@ module Test
|
|||
module_function :run_once
|
||||
end
|
||||
|
||||
module Options
|
||||
module Options # :nodoc: all
|
||||
def initialize(*, &block)
|
||||
@init_hook = block
|
||||
@options = nil
|
||||
|
@ -151,7 +157,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
module GlobOption
|
||||
module GlobOption # :nodoc: all
|
||||
@@testfile_prefix = "test"
|
||||
|
||||
def setup_options(parser, options)
|
||||
|
@ -197,7 +203,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
module LoadPathOption
|
||||
module LoadPathOption # :nodoc: all
|
||||
def setup_options(parser, options)
|
||||
super
|
||||
parser.on '-Idirectory', 'Add library load path' do |dirs|
|
||||
|
@ -206,7 +212,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
module GCStressOption
|
||||
module GCStressOption # :nodoc: all
|
||||
def setup_options(parser, options)
|
||||
super
|
||||
parser.on '--[no-]gc-stress', 'Set GC.stress as true' do |flag|
|
||||
|
@ -232,7 +238,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
module RequireFiles
|
||||
module RequireFiles # :nodoc: all
|
||||
def non_options(files, options)
|
||||
return false if !super
|
||||
result = false
|
||||
|
@ -252,7 +258,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
class Runner < MiniTest::Unit
|
||||
class Runner < MiniTest::Unit # :nodoc: all
|
||||
include Test::Unit::Options
|
||||
include Test::Unit::GlobOption
|
||||
include Test::Unit::LoadPathOption
|
||||
|
@ -759,7 +765,7 @@ module Test
|
|||
rep
|
||||
end
|
||||
|
||||
def initialize # :nodoc:
|
||||
def initialize
|
||||
super
|
||||
@tty = $stdout.tty?
|
||||
end
|
||||
|
@ -777,7 +783,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
class StatusLineOutput < Struct.new(:runner)
|
||||
class StatusLineOutput < Struct.new(:runner) # :nodoc: all
|
||||
def puts(*a) $stdout.puts(*a) unless a.empty? end
|
||||
def respond_to_missing?(*a) $stdout.respond_to?(*a) end
|
||||
def method_missing(*a, &b) $stdout.__send__(*a, &b) end
|
||||
|
@ -798,7 +804,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
class AutoRunner
|
||||
class AutoRunner # :nodoc: all
|
||||
class Runner < Test::Unit::Runner
|
||||
include Test::Unit::RequireFiles
|
||||
end
|
||||
|
@ -839,7 +845,7 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
class ProxyError < StandardError
|
||||
class ProxyError < StandardError # :nodoc: all
|
||||
def initialize(ex)
|
||||
@message = ex.message
|
||||
@backtrace = ex.backtrace
|
||||
|
@ -850,7 +856,12 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
class MiniTest::Unit::TestCase
|
||||
module MiniTest # :nodoc: all
|
||||
module Unit
|
||||
end
|
||||
end
|
||||
|
||||
class MiniTest::Unit::TestCase # :nodoc: all
|
||||
undef run_test
|
||||
RUN_TEST_TRACE = "#{__FILE__}:#{__LINE__+3}:in `run_test'".freeze
|
||||
def run_test(name)
|
||||
|
|
|
@ -358,7 +358,7 @@ EOT
|
|||
template.gsub(/\G((?:[^\\]|\\.)*?)(\\)?\?/) { $1 + ($2 ? "?" : mu_pp(arguments.shift)) }
|
||||
end
|
||||
|
||||
def message(msg = nil, *args, &default)
|
||||
def message(msg = nil, *args, &default) # :nodoc:
|
||||
if Proc === msg
|
||||
super(nil, *args) do
|
||||
[msg.call, (default.call if default)].compact.reject(&:empty?).join(".\n")
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'test/unit'
|
|||
|
||||
module Test
|
||||
module Unit
|
||||
class Worker < Runner
|
||||
class Worker < Runner # :nodoc:
|
||||
class << self
|
||||
undef autorun
|
||||
end
|
||||
|
@ -12,19 +12,19 @@ module Test
|
|||
undef _run_suites
|
||||
undef run
|
||||
|
||||
def increment_io(orig)
|
||||
def increment_io(orig) # :nodoc:
|
||||
*rest, io = 32.times.inject([orig.dup]){|ios, | ios << ios.last.dup }
|
||||
rest.each(&:close)
|
||||
io
|
||||
end
|
||||
|
||||
def _run_suites(suites, type)
|
||||
def _run_suites(suites, type) # :nodoc:
|
||||
suites.map do |suite|
|
||||
_run_suite(suite, type)
|
||||
end
|
||||
end
|
||||
|
||||
def _run_suite(suite, type)
|
||||
def _run_suite(suite, type) # :nodoc:
|
||||
@partial_report = []
|
||||
orig_testout = MiniTest::Unit.output
|
||||
i,o = IO.pipe
|
||||
|
@ -81,7 +81,7 @@ module Test
|
|||
i.close if i && !i.closed?
|
||||
end
|
||||
|
||||
def run(args = [])
|
||||
def run(args = []) # :nodoc:
|
||||
process_args args
|
||||
@@stop_auto_run = true
|
||||
@opts = @options.dup
|
||||
|
@ -149,12 +149,12 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
def _report(res, *args)
|
||||
def _report(res, *args) # :nodoc:
|
||||
res = "#{res} #{args.pack("m0")}" unless args.empty?
|
||||
@stdout.puts(res)
|
||||
end
|
||||
|
||||
def puke(klass, meth, e)
|
||||
def puke(klass, meth, e) # :nodoc:
|
||||
@partial_report << [klass.name, meth, e.is_a?(MiniTest::Assertion) ? e : ProxyError.new(e)]
|
||||
super
|
||||
end
|
||||
|
@ -165,7 +165,7 @@ end
|
|||
if $0 == __FILE__
|
||||
module Test
|
||||
module Unit
|
||||
class TestCase < MiniTest::Unit::TestCase
|
||||
class TestCase < MiniTest::Unit::TestCase # :nodoc: all
|
||||
undef on_parallel_worker?
|
||||
def on_parallel_worker?
|
||||
true
|
||||
|
@ -174,7 +174,9 @@ if $0 == __FILE__
|
|||
end
|
||||
end
|
||||
require 'rubygems'
|
||||
class Gem::TestCase < MiniTest::Unit::TestCase
|
||||
module Gem # :nodoc:
|
||||
end
|
||||
class Gem::TestCase < MiniTest::Unit::TestCase # :nodoc:
|
||||
@@project_dir = File.expand_path('../../../..', __FILE__)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Test
|
|||
# remove silly TestCase class
|
||||
remove_const(:TestCase) if defined?(self::TestCase)
|
||||
|
||||
class TestCase < MiniTest::Unit::TestCase
|
||||
class TestCase < MiniTest::Unit::TestCase # :nodoc: all
|
||||
include Assertions
|
||||
|
||||
def on_parallel_worker?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue