diff options
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_io.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 3df7771d6c..0325867496 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1955,4 +1955,24 @@ End assert_nothing_raised(TypeError) { File.binwrite(path, "string", mode: "w", encoding: "EUC-JP") } end end + + def test_race_between_read + file = Tempfile.new("test") + path = file.path + file.close + write_file = File.open(path, "wt") + read_file = File.open(path, "rt") + + threads = [] + 10.times do |i| + threads << Thread.new {write_file.print(i)} + threads << Thread.new {read_file.read} + end + threads.each {|t| t.join} + assert(true, "[ruby-core:37197]") + ensure + read_file.close + write_file.close + file.close! + end end |
