tool test/unit/testcase: rename vars @passed, @@current
to @__passed__, @@__current__. @passed is redefined in a few test suites, and this could lead to bugs. Also rename @options (Runner#options) to @__runner_options__, which is only used in make test-tool anyway.
This commit is contained in:
parent
ad06addbfe
commit
7717684d16
@ -144,8 +144,7 @@ module Test
|
|||||||
# Runs the tests reporting the status to +runner+
|
# Runs the tests reporting the status to +runner+
|
||||||
|
|
||||||
def run runner
|
def run runner
|
||||||
@options = runner.options
|
@__runner_options__ = runner.options
|
||||||
|
|
||||||
trap "INFO" do
|
trap "INFO" do
|
||||||
runner.report.each_with_index do |msg, i|
|
runner.report.each_with_index do |msg, i|
|
||||||
warn "\n%3d) %s" % [i + 1, msg]
|
warn "\n%3d) %s" % [i + 1, msg]
|
||||||
@ -161,7 +160,7 @@ module Test
|
|||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@passed = nil
|
@__passed__ = nil
|
||||||
self.before_setup
|
self.before_setup
|
||||||
self.setup
|
self.setup
|
||||||
self.after_setup
|
self.after_setup
|
||||||
@ -169,11 +168,11 @@ module Test
|
|||||||
result = "." unless io?
|
result = "." unless io?
|
||||||
time = Time.now - start_time
|
time = Time.now - start_time
|
||||||
runner.record self.class, self.__name__, self._assertions, time, nil
|
runner.record self.class, self.__name__, self._assertions, time, nil
|
||||||
@passed = true
|
@__passed__ = true
|
||||||
rescue *PASSTHROUGH_EXCEPTIONS
|
rescue *PASSTHROUGH_EXCEPTIONS
|
||||||
raise
|
raise
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@passed = Test::Unit::PendedError === e
|
@__passed__ = Test::Unit::PendedError === e
|
||||||
time = Time.now - start_time
|
time = Time.now - start_time
|
||||||
runner.record self.class, self.__name__, self._assertions, time, e
|
runner.record self.class, self.__name__, self._assertions, time, e
|
||||||
result = runner.puke self.class, self.__name__, e
|
result = runner.puke self.class, self.__name__, e
|
||||||
@ -184,7 +183,7 @@ module Test
|
|||||||
rescue *PASSTHROUGH_EXCEPTIONS
|
rescue *PASSTHROUGH_EXCEPTIONS
|
||||||
raise
|
raise
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@passed = false
|
@__passed__ = false
|
||||||
runner.record self.class, self.__name__, self._assertions, time, e
|
runner.record self.class, self.__name__, self._assertions, time, e
|
||||||
result = runner.puke self.class, self.__name__, e
|
result = runner.puke self.class, self.__name__, e
|
||||||
end
|
end
|
||||||
@ -206,12 +205,12 @@ module Test
|
|||||||
def initialize name # :nodoc:
|
def initialize name # :nodoc:
|
||||||
@__name__ = name
|
@__name__ = name
|
||||||
@__io__ = nil
|
@__io__ = nil
|
||||||
@passed = nil
|
@__passed__ = nil
|
||||||
@@current = self # FIX: make thread local
|
@@__current__ = self # FIX: make thread local
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.current # :nodoc:
|
def self.current # :nodoc:
|
||||||
@@current # FIX: make thread local
|
@@__current__ # FIX: make thread local
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -263,7 +262,7 @@ module Test
|
|||||||
# Returns true if the test passed.
|
# Returns true if the test passed.
|
||||||
|
|
||||||
def passed?
|
def passed?
|
||||||
@passed
|
@__passed__
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -13,7 +13,7 @@ class TestHideSkip < Test::Unit::TestCase
|
|||||||
private
|
private
|
||||||
|
|
||||||
def hideskip(*args)
|
def hideskip(*args)
|
||||||
IO.popen([*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb",
|
IO.popen([*@__runner_options__[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb",
|
||||||
"--verbose", *args], err: [:child, :out]) {|f|
|
"--verbose", *args], err: [:child, :out]) {|f|
|
||||||
f.read
|
f.read
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ module TestParallel
|
|||||||
def setup
|
def setup
|
||||||
i, @worker_in = IO.pipe
|
i, @worker_in = IO.pipe
|
||||||
@worker_out, o = IO.pipe
|
@worker_out, o = IO.pipe
|
||||||
@worker_pid = spawn(*@options[:ruby], PARALLEL_RB,
|
@worker_pid = spawn(*@__runner_options__[:ruby], PARALLEL_RB,
|
||||||
"--ruby", @options[:ruby].join(" "),
|
"--ruby", @__runner_options__[:ruby].join(" "),
|
||||||
"-j", "t1", "-v", out: o, in: i)
|
"-j", "t1", "-v", out: o, in: i)
|
||||||
[i,o].each(&:close)
|
[i,o].each(&:close)
|
||||||
end
|
end
|
||||||
@ -145,8 +145,8 @@ module TestParallel
|
|||||||
class TestParallel < Test::Unit::TestCase
|
class TestParallel < Test::Unit::TestCase
|
||||||
def spawn_runner(*opt_args, jobs: "t1")
|
def spawn_runner(*opt_args, jobs: "t1")
|
||||||
@test_out, o = IO.pipe
|
@test_out, o = IO.pipe
|
||||||
@test_pid = spawn(*@options[:ruby], TESTS+"/runner.rb",
|
@test_pid = spawn(*@__runner_options__[:ruby], TESTS+"/runner.rb",
|
||||||
"--ruby", @options[:ruby].join(" "),
|
"--ruby", @__runner_options__[:ruby].join(" "),
|
||||||
"-j", jobs, *opt_args, out: o, err: o)
|
"-j", jobs, *opt_args, out: o, err: o)
|
||||||
o.close
|
o.close
|
||||||
end
|
end
|
||||||
|
@ -10,7 +10,7 @@ class TestTestUnitSorting < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sorting(*args)
|
def sorting(*args)
|
||||||
IO.popen([*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_sorting.rb",
|
IO.popen([*@__runner_options__[:ruby], "#{File.dirname(__FILE__)}/test4test_sorting.rb",
|
||||||
"--verbose", *args], err: [:child, :out]) {|f|
|
"--verbose", *args], err: [:child, :out]) {|f|
|
||||||
f.read
|
f.read
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user