mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
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
This commit is contained in:
parent
6f0caa5667
commit
6729b532b9
4 changed files with 12 additions and 18 deletions
|
@ -102,7 +102,7 @@ module Puma
|
|||
|
||||
PUMA_VERSION = VERSION = "5.0.0.beta2".freeze
|
||||
CODE_NAME = "Spoony Bard".freeze
|
||||
|
||||
|
||||
PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
|
||||
|
||||
FAST_TRACK_KA_TIMEOUT = 0.2
|
||||
|
|
|
@ -78,6 +78,9 @@ module TimeoutEveryTestCase
|
|||
}
|
||||
end
|
||||
end
|
||||
if respond_to? :clean_tmp_paths
|
||||
clean_tmp_paths
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -85,9 +88,8 @@ module TimeoutEveryTestCase
|
|||
end
|
||||
end
|
||||
|
||||
Minitest::Test.prepend TimeoutEveryTestCase
|
||||
if ENV['CI']
|
||||
Minitest::Test.prepend TimeoutEveryTestCase
|
||||
|
||||
require 'minitest/retry'
|
||||
Minitest::Retry.use!
|
||||
end
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
module TmpPath
|
||||
def capture_exceptions
|
||||
super
|
||||
ensure
|
||||
clean_tmp_paths
|
||||
def clean_tmp_paths
|
||||
while path = tmp_paths.pop
|
||||
delete_tmp_path(path)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tmp_path(extension=nil)
|
||||
sock_file = Tempfile.new(['', extension])
|
||||
path = sock_file.path
|
||||
sock_file.close!
|
||||
path = Tempfile.create(['', extension]) { |f| f.path }
|
||||
tmp_paths << path
|
||||
path
|
||||
end
|
||||
|
@ -19,12 +17,6 @@ module TmpPath
|
|||
@tmp_paths ||= []
|
||||
end
|
||||
|
||||
def clean_tmp_paths
|
||||
while path = tmp_paths.pop
|
||||
delete_tmp_path(path)
|
||||
end
|
||||
end
|
||||
|
||||
def delete_tmp_path(path)
|
||||
File.unlink(path)
|
||||
rescue Errno::ENOENT
|
||||
|
|
|
@ -5,6 +5,7 @@ class TestRedirectIO < TestIntegration
|
|||
parallelize_me!
|
||||
|
||||
def setup
|
||||
skip_unless_signal_exist? :HUP
|
||||
super
|
||||
|
||||
# Keep the Tempfile instances alive to avoid being GC'd
|
||||
|
@ -15,6 +16,7 @@ class TestRedirectIO < TestIntegration
|
|||
end
|
||||
|
||||
def teardown
|
||||
return if skipped?
|
||||
super
|
||||
|
||||
paths = (skipped? ? [@out_file_path, @err_file_path] :
|
||||
|
@ -27,7 +29,6 @@ class TestRedirectIO < TestIntegration
|
|||
|
||||
def test_sighup_redirects_io_single
|
||||
skip_on :jruby # Server isn't coming up in CI, TODO Fix
|
||||
skip_unless_signal_exist? :HUP
|
||||
|
||||
cli_args = [
|
||||
'--redirect-stdout', @out_file_path,
|
||||
|
@ -55,7 +56,6 @@ class TestRedirectIO < TestIntegration
|
|||
|
||||
def test_sighup_redirects_io_cluster
|
||||
skip NO_FORK_MSG unless HAS_FORK
|
||||
skip_unless_signal_exist? :HUP
|
||||
|
||||
cli_args = [
|
||||
'-w', '1',
|
||||
|
|
Loading…
Add table
Reference in a new issue