1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/helpers/tmp_path.rb
MSP-Greg 6729b532b9
Small test fixes - helpers/tmp_path.rb, helper.rb & test_redirect_io.rb
Currently, helpers/tmp_path.rb uses `#capture_exceptions` to run cleanup code, which is called several times for each test.
Adjusted code in it and test/helpers.rb to run once, after teardown.
This also allows asserts in teardown to work properly, see test_integration_pumactl.rb.

Also, `Tempfile.new` attaches finalizers to each object, which seemed to be intermittently bothering JRuby.
Changed to `Tempfile.create`

test_redirect_io.rb - small fix for setup and teardown.

helper.rb - changed `if ENV['CI']` conditional so that local and cloud CI both use TimeoutEveryTestCase..

Fix RuboCop in Update const.rb
2020-09-09 14:44:02 -05:00

24 lines
377 B
Ruby

module TmpPath
def clean_tmp_paths
while path = tmp_paths.pop
delete_tmp_path(path)
end
end
private
def tmp_path(extension=nil)
path = Tempfile.create(['', extension]) { |f| f.path }
tmp_paths << path
path
end
def tmp_paths
@tmp_paths ||= []
end
def delete_tmp_path(path)
File.unlink(path)
rescue Errno::ENOENT
end
end