mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_require.rb: no guarantees to load FIFO
* test/ruby/test_require.rb (loading_fifo): loading from FIFO is not guaranteed, it just should not block the whole process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7cb20b8fb8
commit
61685c762e
1 changed files with 5 additions and 5 deletions
|
@ -699,11 +699,12 @@ class TestRequire < Test::Unit::TestCase
|
|||
f.close
|
||||
File.unlink(f.path)
|
||||
File.mkfifo(f.path)
|
||||
assert_separately(["-", f.path], <<-END, timeout: 3)
|
||||
assert_ruby_status(["-", f.path], <<-END, timeout: 3)
|
||||
th = Thread.current
|
||||
Thread.start {begin sleep(0.001) end until th.stop?; th.raise(IOError)}
|
||||
assert_raise(IOError) do
|
||||
begin
|
||||
load(ARGV[0])
|
||||
rescue IOError
|
||||
end
|
||||
END
|
||||
}
|
||||
|
@ -715,7 +716,7 @@ class TestRequire < Test::Unit::TestCase
|
|||
File.unlink(f.path)
|
||||
File.mkfifo(f.path)
|
||||
|
||||
assert_separately(["-", f.path], <<-INPUT, timeout: 3)
|
||||
assert_ruby_status(["-", f.path], <<-INPUT, timeout: 3)
|
||||
path = ARGV[0]
|
||||
th = Thread.current
|
||||
Thread.start {
|
||||
|
@ -723,12 +724,11 @@ class TestRequire < Test::Unit::TestCase
|
|||
sleep(0.001)
|
||||
end until th.stop?
|
||||
open(path, File::WRONLY | File::NONBLOCK) {|fifo_w|
|
||||
fifo_w.puts "class C1; FOO='foo'; end"
|
||||
fifo_w.print "__END__\n" # ensure finishing
|
||||
}
|
||||
}
|
||||
|
||||
load(path)
|
||||
assert_equal(C1::FOO, "foo")
|
||||
INPUT
|
||||
}
|
||||
end if defined?(File.mkfifo)
|
||||
|
|
Loading…
Reference in a new issue