1
0
Fork 0
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:
nobu 2015-10-18 03:07:39 +00:00
parent 7cb20b8fb8
commit 61685c762e

View file

@ -699,11 +699,12 @@ class TestRequire < Test::Unit::TestCase
f.close f.close
File.unlink(f.path) File.unlink(f.path)
File.mkfifo(f.path) File.mkfifo(f.path)
assert_separately(["-", f.path], <<-END, timeout: 3) assert_ruby_status(["-", f.path], <<-END, timeout: 3)
th = Thread.current th = Thread.current
Thread.start {begin sleep(0.001) end until th.stop?; th.raise(IOError)} Thread.start {begin sleep(0.001) end until th.stop?; th.raise(IOError)}
assert_raise(IOError) do begin
load(ARGV[0]) load(ARGV[0])
rescue IOError
end end
END END
} }
@ -715,7 +716,7 @@ class TestRequire < Test::Unit::TestCase
File.unlink(f.path) File.unlink(f.path)
File.mkfifo(f.path) File.mkfifo(f.path)
assert_separately(["-", f.path], <<-INPUT, timeout: 3) assert_ruby_status(["-", f.path], <<-INPUT, timeout: 3)
path = ARGV[0] path = ARGV[0]
th = Thread.current th = Thread.current
Thread.start { Thread.start {
@ -723,12 +724,11 @@ class TestRequire < Test::Unit::TestCase
sleep(0.001) sleep(0.001)
end until th.stop? end until th.stop?
open(path, File::WRONLY | File::NONBLOCK) {|fifo_w| 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) load(path)
assert_equal(C1::FOO, "foo")
INPUT INPUT
} }
end if defined?(File.mkfifo) end if defined?(File.mkfifo)