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

add ruby 2.2, 2.3, and 2.4 to CI matrix #537

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/development.yml
Expand Up @@ -14,6 +14,9 @@ jobs:
- macos

ruby:
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
- 2.7
Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Expand Up @@ -26,14 +26,16 @@ group :test do
gem 'rspec', '~> 3.3'
end

RUBY_VERSION_FLOAT = RUBY_VERSION[/\d+\.\d+/].to_f

group :development do
gem 'bundler'
gem 'gems', require: false
gem 'guard-rspec', require: false
gem 'guard-rubocop'
gem 'guard-rubocop' unless RUBY_VERSION_FLOAT < 2.4
gem 'netrc', require: false
gem 'octokit', require: false
gem 'pry-rescue'
gem 'rubocop', '0.91.0'
gem 'rubocop', '0.91.0' unless RUBY_VERSION_FLOAT < 2.4
gem 'yard', require: false
end
2 changes: 1 addition & 1 deletion lib/listen/adapter/base.rb
Expand Up @@ -88,7 +88,7 @@ def stop
private

def _stop
@run_thread&.kill
@run_thread && @run_thread.kill
ColinDKelley marked this conversation as resolved.
Show resolved Hide resolved
@run_thread = nil
end

Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/darwin.rb
Expand Up @@ -69,7 +69,7 @@ def _process_event(dir, path)
end

def _stop
@worker_thread&.kill
@worker_thread && @worker_thread.kill
ColinDKelley marked this conversation as resolved.
Show resolved Hide resolved
super
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/linux.rb
Expand Up @@ -102,7 +102,7 @@ def _dir_event?(event)
end

def _stop
@worker&.close
@worker && @worker.close
ColinDKelley marked this conversation as resolved.
Show resolved Hide resolved

super
end
Expand Down
2 changes: 1 addition & 1 deletion lib/listen/event/config.rb
Expand Up @@ -25,7 +25,7 @@ def sleep(seconds)
end

def call(*args)
@block&.call(*args)
@block && @block.call(*args)
ColinDKelley marked this conversation as resolved.
Show resolved Hide resolved
end

def callable?
Expand Down
4 changes: 2 additions & 2 deletions lib/listen/event/loop.rb
Expand Up @@ -29,7 +29,7 @@ def initialize(config)
end

def wakeup_on_event
if started? && @wait_thread&.alive?
if started? && @wait_thread && @wait_thread.alive?
_wakeup(:event)
end
end
Expand Down Expand Up @@ -67,7 +67,7 @@ def pause
def stop
transition! :stopped

@wait_thread&.join
@wait_thread && @wait_thread.join
ColinDKelley marked this conversation as resolved.
Show resolved Hide resolved
@wait_thread = nil
end

Expand Down
6 changes: 3 additions & 3 deletions lib/listen/record.rb
Expand Up @@ -45,16 +45,16 @@ def file_data(rel_path)
end

def dir_entries(rel_path)
subtree = if ['', '.'].include? rel_path.to_s
subtree = if ['', '.'].include?(rel_path.to_s)
@tree
else
@tree[rel_path.to_s] ||= _auto_hash
@tree[rel_path.to_s]
end

subtree.transform_values do |values|
subtree.each_with_object({}) do |(key, values), result|
ColinDKelley marked this conversation as resolved.
Show resolved Hide resolved
# only get data for file entries
values.key?(:mtime) ? values : {}
result[key] = values.has_key?(:mtime) ? values : {}
end
end

Expand Down
9 changes: 7 additions & 2 deletions lib/listen/thread.rb
Expand Up @@ -17,7 +17,7 @@ def new(name, &block)
::Thread.new do
rescue_and_log(thread_name, caller_stack: caller_stack, &block)
end.tap do |thread|
thread.name = thread_name
thread.name = thread_name unless RUBY_VERSION[/\d+\.\d+/].to_f < 2.3
end
end
# rubocop:enable Style/MultilineBlockChain
Expand All @@ -41,7 +41,12 @@ def _log_exception(exception, thread_name, caller_stack: nil)
end

def _exception_with_causes(exception)
result = +"#{exception.class}: #{exception}"
result =
if RUBY_VERSION[/\d+\.\d+/].to_f < 2.3
"#{exception.class}: #{exception}"
else
+"#{exception.class}: #{exception}"
end
if exception.cause
result << "\n"
result << "--- Caused by: ---\n"
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/listen/thread_spec.rb
Expand Up @@ -43,7 +43,7 @@
end

it "rescues and logs exceptions" do
pattern = <<~EOS.strip
pattern = <<-EOS.gsub(/^ +/, '').strip
Exception rescued in listen-worker_thread:
ArgumentError: boom!
.*\\/listen\\/thread_spec\\.rb
Expand All @@ -53,7 +53,7 @@
end

it "rescues and logs backtrace + exception backtrace" do
pattern = <<~EOS.strip
pattern = <<-EOS.gsub(/^ +/, '').strip
Exception rescued in listen-worker_thread:
ArgumentError: boom!
.*\\/listen\\/thread\\.rb.*--- Thread.new ---.*\\/listen\\/thread_spec\\.rb
Expand Down Expand Up @@ -93,7 +93,7 @@ class TestExceptionDerivedFromException < Exception; end # rubocop:disable Lint/
let(:block) { raise_nested_exception_block }

it "details exception causes" do
pattern = <<~EOS
pattern = <<-EOS.gsub(/^ +/, '')
RuntimeError: nested outer
--- Caused by: ---
RuntimeError: nested inner
Expand All @@ -108,7 +108,7 @@ class TestExceptionDerivedFromException < Exception; end # rubocop:disable Lint/

describe '.rescue_and_log' do
it 'rescues and logs nested exceptions' do
pattern = <<~EOS
pattern = <<-EOS.gsub(/^ +/, '')
Exception rescued in method:
RuntimeError: nested outer
--- Caused by: ---
Expand Down