Skip to content

Commit

Permalink
Add workaround for Ruby 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrictson committed Aug 25, 2024
1 parent 616b136 commit 15ed958
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/mighty_test/watcher/event_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,28 @@ def stopped?
attr_reader :console, :file_system, :file_system_listener, :file_system_queue

def pop_files_changed
paths = file_system_queue.pop(timeout: 0.2)
paths = try_file_system_pop(timeout: 0.2)
return if paths.nil?

paths += file_system_queue.pop until file_system_queue.empty?
paths.uniq
end

if RUBY_VERSION.start_with?("3.1.")
# TODO: Remove once we drop support for Ruby 3.1
require "timeout"
def try_file_system_pop(timeout:)
Timeout.timeout(timeout) do
file_system_queue.pop
end
rescue Timeout::Error
nil
end
else
def try_file_system_pop(timeout:)
file_system_queue.pop(timeout:)
end
end
end
end
end

0 comments on commit 15ed958

Please sign in to comment.