1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Launcher test cleanup (#1966)

* Add no-bundler skip

* Remove unnecessary test requires

* Little bit of launcher test cleanup
This commit is contained in:
Nate Berkopec 2019-09-13 16:44:02 +00:00 committed by GitHub
parent e96e798068
commit e864e28b13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 26 deletions

View file

@ -99,11 +99,12 @@ module TestSkips
skip_msg = false
engs.each do |eng|
skip_msg = case eng
when :darwin then "Skipped on darwin#{suffix}" if RUBY_PLATFORM[/darwin/]
when :jruby then "Skipped on JRuby#{suffix}" if Puma.jruby?
when :windows then "Skipped on Windows#{suffix}" if Puma.windows?
when :appveyor then "Skipped on Appveyor#{suffix}" if ENV["APPVEYOR"]
when :ci then "Skipped on ENV['CI']#{suffix}" if ENV["CI"]
when :darwin then "Skipped on darwin#{suffix}" if RUBY_PLATFORM[/darwin/]
when :jruby then "Skipped on JRuby#{suffix}" if Puma.jruby?
when :windows then "Skipped on Windows#{suffix}" if Puma.windows?
when :appveyor then "Skipped on Appveyor#{suffix}" if ENV["APPVEYOR"]
when :ci then "Skipped on ENV['CI']#{suffix}" if ENV["CI"]
when :no_bundler then "Skipped w/o Bundler#{suffix}" if !defined?(Bundler)
else false
end
skip skip_msg, bt if skip_msg

View file

@ -1,31 +1,28 @@
require_relative "helper"
require "puma/configuration"
require "puma/const"
require "puma/launcher"
class TestLauncher < Minitest::Test
def test_dependencies_and_files_to_require_after_prune_is_correctly_built_for_no_extra_deps
skip_on :appveyor, suffix: " - bundler not used in appveyor so prune bundler logic tests unavailable"
skip_on :no_bundler
l = Puma::Launcher.new Puma::Configuration.new
deps, dirs = l.send(:dependencies_and_files_to_require_after_prune)
deps, dirs = launcher.send(:dependencies_and_files_to_require_after_prune)
assert_equal(1, deps.length)
assert_match(%r{^nio4r:[\d.]+$}, deps.first)
assert_equal(2, dirs.length)
assert_match(%r{puma/lib$}, dirs[0]) # lib dir
assert_match(%r{puma-#{Puma::Const::PUMA_VERSION}$}, dirs[1]) # native extension dir
refute_match(%r{gems/rdoc-[\d.]+/lib$}, dirs[2])
end
def test_dependencies_and_files_to_require_after_prune_is_correctly_built_with_extra_deps
skip_on :appveyor, suffix: " - bundler not used in appveyor so prune bundler logic tests unavailable"
skip_on :no_bundler
conf = Puma::Configuration.new do |c|
c.extra_runtime_dependencies ['rdoc']
end
l = Puma::Launcher.new conf
deps, dirs = l.send(:dependencies_and_files_to_require_after_prune)
deps, dirs = launcher(conf).send(:dependencies_and_files_to_require_after_prune)
assert_equal(1, deps.length)
assert_match(%r{^nio4r:[\d.]+$}, deps.first)
@ -36,38 +33,43 @@ class TestLauncher < Minitest::Test
end
def test_extra_runtime_deps_directories_is_empty_for_no_config
l = Puma::Launcher.new Puma::Configuration.new
assert_equal([], l.send(:extra_runtime_deps_directories))
assert_equal([], launcher.send(:extra_runtime_deps_directories))
end
def test_extra_runtime_deps_directories_is_correctly_built
skip_on :appveyor, suffix: " - bundler not used in appveyor so prune bundler logic tests unavailable"
skip_on :no_bundler
conf = Puma::Configuration.new do |c|
c.extra_runtime_dependencies ['rdoc']
end
l = Puma::Launcher.new conf
dep_dirs = l.send(:extra_runtime_deps_directories)
dep_dirs = launcher(conf).send(:extra_runtime_deps_directories)
assert_equal(1, dep_dirs.length)
assert_match(%r{gems/rdoc-[\d.]+/lib$}, dep_dirs.first)
end
def test_puma_wild_location_is_an_absolute_path
skip_on :appveyor, suffix: " - bundler not used in appveyor so prune bundler logic tests unavailable"
l = Puma::Launcher.new Puma::Configuration.new
puma_wild_location = l.send(:puma_wild_location)
skip_on :no_bundler
puma_wild_location = launcher.send(:puma_wild_location)
assert_match(%r{bin/puma-wild$}, puma_wild_location)
# assert no "/../" in path
refute_match(%r{/\.\./}, puma_wild_location)
end
def test_prints_thread_traces
events = Puma::Events.strings
l = Puma::Launcher.new(Puma::Configuration.new, events: events)
l.send(:log_thread_status)
launcher.send(:log_thread_status)
events.stdout.rewind
assert_match "Thread TID", events.stdout.read
end
private
def events
@events ||= Puma::Events.strings
end
def launcher(config = Puma::Configuration.new, evts = events)
@launcher ||= Puma::Launcher.new(config, events: evts)
end
end