mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_io.rb (test_copy_stream_socket): wait a child process
before SIGUSR1 handler is removed. * test/pathname/test_pathname.rb (define_assertion): use line number for test method names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
071b8d76f0
commit
19853fc49b
3 changed files with 43 additions and 26 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Jun 15 12:35:11 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* test/ruby/test_io.rb (test_copy_stream_socket): wait a child process
|
||||||
|
before SIGUSR1 handler is removed.
|
||||||
|
|
||||||
|
* test/pathname/test_pathname.rb (define_assertion): use line number
|
||||||
|
for test method names.
|
||||||
|
|
||||||
Wed Jun 15 10:37:43 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
Wed Jun 15 10:37:43 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (rb_stat_rdev): use DEVT2NUM.
|
* file.c (rb_stat_rdev): use DEVT2NUM.
|
||||||
|
|
|
@ -10,15 +10,21 @@ require 'enumerator'
|
||||||
require_relative '../ruby/envutil'
|
require_relative '../ruby/envutil'
|
||||||
|
|
||||||
class TestPathname < Test::Unit::TestCase
|
class TestPathname < Test::Unit::TestCase
|
||||||
def self.define_assertion(name, &block)
|
def self.define_assertion(name, linenum, &block)
|
||||||
@defassert_num ||= {}
|
name = "test_#{name}_#{linenum}"
|
||||||
@defassert_num[name] ||= 0
|
define_method(name, &block)
|
||||||
@defassert_num[name] += 1
|
end
|
||||||
define_method("test_#{name}_#{@defassert_num[name]}", &block)
|
|
||||||
|
def self.get_linenum
|
||||||
|
if /:(\d+):/ =~ caller[1]
|
||||||
|
$1.to_i
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.defassert(name, result, *args)
|
def self.defassert(name, result, *args)
|
||||||
define_assertion(name) {
|
define_assertion(name, get_linenum) {
|
||||||
mesg = "#{name}(#{args.map {|a| a.inspect }.join(', ')})"
|
mesg = "#{name}(#{args.map {|a| a.inspect }.join(', ')})"
|
||||||
assert_nothing_raised(mesg) {
|
assert_nothing_raised(mesg) {
|
||||||
assert_equal(result, self.send(name, *args), mesg)
|
assert_equal(result, self.send(name, *args), mesg)
|
||||||
|
@ -26,6 +32,13 @@ class TestPathname < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.defassert_raise(name, exc, *args)
|
||||||
|
define_assertion(name, get_linenum) {
|
||||||
|
message = "#{name}(#{args.map {|a| a.inspect }.join(', ')})"
|
||||||
|
assert_raise(exc, message) { self.send(name, *args) }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
DOSISH = File::ALT_SEPARATOR != nil
|
DOSISH = File::ALT_SEPARATOR != nil
|
||||||
DOSISH_DRIVE_LETTER = File.dirname("A:") == "A:."
|
DOSISH_DRIVE_LETTER = File.dirname("A:") == "A:."
|
||||||
DOSISH_UNC = File.dirname("//") == "//"
|
DOSISH_UNC = File.dirname("//") == "//"
|
||||||
|
@ -294,13 +307,6 @@ class TestPathname < Test::Unit::TestCase
|
||||||
defassert(:relative_path_from, "a", "a", "b/..")
|
defassert(:relative_path_from, "a", "a", "b/..")
|
||||||
defassert(:relative_path_from, "b/c", "b/c", "b/..")
|
defassert(:relative_path_from, "b/c", "b/c", "b/..")
|
||||||
|
|
||||||
def self.defassert_raise(name, exc, *args)
|
|
||||||
define_assertion(name) {
|
|
||||||
message = "#{name}(#{args.map {|a| a.inspect }.join(', ')})"
|
|
||||||
assert_raise(exc, message) { self.send(name, *args) }
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
defassert_raise(:relative_path_from, ArgumentError, "/", ".")
|
defassert_raise(:relative_path_from, ArgumentError, "/", ".")
|
||||||
defassert_raise(:relative_path_from, ArgumentError, ".", "/")
|
defassert_raise(:relative_path_from, ArgumentError, ".", "/")
|
||||||
defassert_raise(:relative_path_from, ArgumentError, "a", "..")
|
defassert_raise(:relative_path_from, ArgumentError, "a", "..")
|
||||||
|
|
|
@ -610,6 +610,7 @@ class TestIO < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
trapping_usr1 do
|
trapping_usr1 do
|
||||||
nr = 10
|
nr = 10
|
||||||
|
begin
|
||||||
pid = fork do
|
pid = fork do
|
||||||
s1.close
|
s1.close
|
||||||
IO.select([s2])
|
IO.select([s2])
|
||||||
|
@ -622,7 +623,9 @@ class TestIO < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
assert_equal(1, @usr1_rcvd)
|
assert_equal(1, @usr1_rcvd)
|
||||||
s1.close
|
s1.close
|
||||||
_, status = Process.waitpid2(pid)
|
ensure
|
||||||
|
_, status = Process.waitpid2(pid) if pid
|
||||||
|
end
|
||||||
assert status.success?, status.inspect
|
assert status.success?, status.inspect
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue