Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'tempfile'
- require 'java' if defined?(JRUBY_VERSION)
- require 'test/unit'
- require 'fileutils'
- class FileOpener
- def initialize(tmp)
- path = Tempfile.open('blah', tmp).path
- # fails on MRI without this!!! :)
- p path
- end
- end
- class TestTempfilesCleanUp < Test::Unit::TestCase
- def setup
- @tmpdir = "tmp_#{$$}"
- Dir.mkdir @tmpdir rescue nil
- end
- def teardown
- FileUtils.rm_f @tmpdir
- end
- def test_open_files
- loop do
- FileOpener.new(@tmpdir)
- if defined?(JRUBY_VERSION)
- java.lang.System.gc
- else
- GC.start
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment