Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis: Add 2.4.0, use jruby-9.1.7.0; don't trap QUIT on JRuby since it's not supported #271

Merged
merged 3 commits into from
Jan 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ cache: bundler
before_install: gem i bundler
matrix:
include:
- rvm: 2.4.0
- rvm: 2.3.3
- rvm: 2.2
- rvm: 2.1
- rvm: 2.0
- rvm: jruby-9.1.6.0
- rvm: jruby-9.1.7.0
jdk: oraclejdk8
env:
- JRUBY_OPTS='--debug'
Expand Down
4 changes: 3 additions & 1 deletion lib/hutch/waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class ContinueProcessingSignals < RuntimeError
end

def self.supported_signals_of(list)
list.keep_if { |s| Signal.list.keys.include? s }
list.keep_if { |s| Signal.list.keys.include?(s) }.tap do |result|
result.delete('QUIT') if defined?(JRUBY_VERSION)
end
end

SHUTDOWN_SIGNALS = supported_signals_of(%w(QUIT TERM INT)).freeze
Expand Down
42 changes: 28 additions & 14 deletions spec/hutch/waiter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,39 @@ def start_kill_thread(signal)
end
end

described_class::SHUTDOWN_SIGNALS.each do |signal|
# JRuby does not support QUIT:
# The signal QUIT is in use by the JVM and will not work correctly on this platform
next if signal == 'QUIT' && defined?(JRUBY_VERSION)

context "a #{signal} signal is received" do
it "logs that hutch is stopping" do
expect(Hutch::Logging.logger).to receive(:info)
.with("caught SIG#{signal}, stopping hutch...")

start_kill_thread(signal)
described_class.wait_until_signaled
end
context 'a QUIT signal is received', if: RSpec::Support::Ruby.mri? do
it 'logs that hutch is stopping' do
expect(Hutch::Logging.logger).to receive(:info)
.with('caught SIGQUIT, stopping hutch...')

start_kill_thread('QUIT')
described_class.wait_until_signaled
end
end

context 'a TERM signal is received' do
it 'logs that hutch is stopping' do
expect(Hutch::Logging.logger).to receive(:info)
.with('caught SIGTERM, stopping hutch...')

start_kill_thread('TERM')
described_class.wait_until_signaled
end
end

context 'a INT signal is received' do
it 'logs that hutch is stopping' do
expect(Hutch::Logging.logger).to receive(:info)
.with('caught SIGINT, stopping hutch...')

start_kill_thread('INT')
described_class.wait_until_signaled
end
end
end

describe described_class::SHUTDOWN_SIGNALS do
it "includes only things in Signal.list.keys" do
it 'includes only things in Signal.list.keys' do
expect(described_class).to eq(described_class & Signal.list.keys)
end
end
Expand Down