diff options
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index d10926d2c9..9637215509 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2671,19 +2671,43 @@ End def test_write_32bit_boundary bug8431 = '[ruby-core:55098] [Bug #8431]' make_tempfile {|t| - assert_separately(["-", bug8431, t.path], <<-"end;", timeout: 30) - msg = ARGV.shift - f = open(ARGV[0], "wb") - f.seek(0xffff_ffff) - begin - # this will consume very long time or fail by ENOSPC on a - # filesystem which sparse file is not supported - f.write('1') - rescue SystemCallError - else - assert_equal(0x1_0000_0000, f.tell, msg) + def t.close(unlink_now = false) + # TODO: Tempfile should deal with this delay on Windows? + # NOTE: re-opening with O_TEMPORARY does not work. + path = self.path + ret = super + if unlink_now + begin + File.unlink(path) + rescue Errno::ENOENT + rescue Errno::EACCES + sleep(2) + retry + end end - end; + ret + end + + begin + assert_separately(["-", bug8431, t.path], <<-"end;", timeout: 30) + msg = ARGV.shift + f = open(ARGV[0], "wb") + f.seek(0xffff_ffff) + begin + # this will consume very long time or fail by ENOSPC on a + # filesystem which sparse file is not supported + f.write('1') + pos = f.tell + rescue Errno::ENOSPC + skip "non-sparse file system" + rescue SystemCallError + else + assert_equal(0x1_0000_0000, pos, msg) + end + end; + rescue Timeout::Error + skip "Timeout because of slow file writing" + end } end if /mswin|mingw/ =~ RUBY_PLATFORM end |