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

Drop Ruby 2.5 support #383

Merged
merged 1 commit into from
Nov 17, 2022
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
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ jobs:
- '3.0'
- '2.7'
- '2.6'
- '2.5'
- head
- truffleruby-head
os: [ubuntu-latest]
with_latest_reline: [true, false]
exclude:
- ruby: '2.5'
os: ubuntu-latest
with_latest_reline: true
fail-fast: false
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion irb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
spec.required_ruby_version = Gem::Requirement.new(">= 2.6")

spec.add_dependency "reline", ">= 0.3.0"
end
6 changes: 1 addition & 5 deletions lib/irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,7 @@ def handle_exception(exc)

if exc.backtrace
order = nil
if '2.5.0' == RUBY_VERSION
# Exception#full_message doesn't have keyword arguments.
message = exc.full_message # the same of (highlight: true, order: bottom)
order = :bottom
elsif '2.5.1' <= RUBY_VERSION && RUBY_VERSION < '3.0.0'
if RUBY_VERSION < '3.0.0'
if STDOUT.tty?
message = exc.full_message(order: :bottom)
order = :bottom
Expand Down
47 changes: 17 additions & 30 deletions test/irb/test_color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,19 @@ def test_colorize_code
end

tests.each do |code, result|
if colorize_code_supported?
assert_equal_with_term(result, code, complete: true)
assert_equal_with_term(result, code, complete: false)
assert_equal_with_term(result, code, complete: true)
assert_equal_with_term(result, code, complete: false)

assert_equal_with_term(code, code, complete: true, tty: false)
assert_equal_with_term(code, code, complete: false, tty: false)
assert_equal_with_term(code, code, complete: true, tty: false)
assert_equal_with_term(code, code, complete: false, tty: false)

assert_equal_with_term(code, code, complete: true, colorable: false)
assert_equal_with_term(code, code, complete: true, colorable: false)

assert_equal_with_term(code, code, complete: false, colorable: false)
assert_equal_with_term(code, code, complete: false, colorable: false)

assert_equal_with_term(result, code, complete: true, tty: false, colorable: true)
assert_equal_with_term(result, code, complete: true, tty: false, colorable: true)

assert_equal_with_term(result, code, complete: false, tty: false, colorable: true)
else
assert_equal_with_term(code, code)
end
assert_equal_with_term(result, code, complete: false, tty: false, colorable: true)
end
end

Expand Down Expand Up @@ -171,26 +167,22 @@ def test_colorize_code_complete_false
"'foo' + 'bar" => "#{RED}#{BOLD}'#{CLEAR}#{RED}foo#{CLEAR}#{RED}#{BOLD}'#{CLEAR} + #{RED}#{BOLD}'#{CLEAR}#{RED}bar#{CLEAR}",
"('foo" => "(#{RED}#{BOLD}'#{CLEAR}#{RED}foo#{CLEAR}",
}.each do |code, result|
if colorize_code_supported?
assert_equal_with_term(result, code, complete: false)
assert_equal_with_term(result, code, complete: false)

assert_equal_with_term(code, code, complete: false, tty: false)
assert_equal_with_term(code, code, complete: false, tty: false)

assert_equal_with_term(code, code, complete: false, colorable: false)
assert_equal_with_term(code, code, complete: false, colorable: false)

assert_equal_with_term(result, code, complete: false, tty: false, colorable: true)
assert_equal_with_term(result, code, complete: false, tty: false, colorable: true)

unless complete_option_supported?
assert_equal_with_term(result, code, complete: true)
unless complete_option_supported?
assert_equal_with_term(result, code, complete: true)

assert_equal_with_term(code, code, complete: true, tty: false)
assert_equal_with_term(code, code, complete: true, tty: false)

assert_equal_with_term(code, code, complete: true, colorable: false)
assert_equal_with_term(code, code, complete: true, colorable: false)

assert_equal_with_term(result, code, complete: true, tty: false, colorable: true)
end
else
assert_equal_with_term(code, code)
assert_equal_with_term(result, code, complete: true, tty: false, colorable: true)
end
end
end
Expand All @@ -217,11 +209,6 @@ def test_inspect_colorable

private

# `#colorize_code` is supported only for Ruby 2.5+. It just returns the original code in 2.4-.
def colorize_code_supported?
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
end

# `complete: true` is the same as `complete: false` in Ruby 2.6-
def complete_option_supported?
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
Expand Down
6 changes: 3 additions & 3 deletions test/irb/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def test_eval_input_with_exception
irb.eval_input
end
assert_empty err
if '2.5.0' <= RUBY_VERSION && RUBY_VERSION < '3.0.0' && STDOUT.tty?
if RUBY_VERSION < '3.0.0' && STDOUT.tty?
expected = [
:*, /Traceback \(most recent call last\):\n/,
:*, /\t 2: from \(irb\):1:in `<main>'\n/,
Expand Down Expand Up @@ -538,7 +538,7 @@ def test_eval_input_with_invalid_byte_sequence_exception
irb.eval_input
end
assert_empty err
if '2.5.0' <= RUBY_VERSION && RUBY_VERSION < '3.0.0' && STDOUT.tty?
if RUBY_VERSION < '3.0.0' && STDOUT.tty?
expected = [
:*, /Traceback \(most recent call last\):\n/,
:*, /\t 2: from \(irb\):1:in `<main>'\n/,
Expand Down Expand Up @@ -575,7 +575,7 @@ def test_eval_input_with_long_exception
irb.eval_input
end
assert_empty err
if '2.5.0' <= RUBY_VERSION && RUBY_VERSION < '3.0.0' && STDOUT.tty?
if RUBY_VERSION < '3.0.0' && STDOUT.tty?
expected = [
:*, /Traceback \(most recent call last\):\n/,
:*, /\t... \d+ levels...\n/,
Expand Down
3 changes: 0 additions & 3 deletions test/irb/test_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ def test_symbols
end

def test_endless_range_at_end_of_line
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6.0')
pend 'Endless range is available in 2.6.0 or later'
end
input_with_prompt = [
PromptRow.new('001:0: :> ', %q(a = 3..)),
PromptRow.new('002:0: :* ', %q()),
Expand Down
3 changes: 1 addition & 2 deletions test/lib/core_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,7 @@ def assert_join_threads(threads, message = nil)
if !errs.empty?
msg = "exceptions on #{errs.length} threads:\n" +
errs.map {|t, err|
"#{t.inspect}:\n" +
RUBY_VERSION >= "2.5.0" ? err.full_message(highlight: false, order: :top) : err.message
"#{t.inspect}:\n" + err.full_message(highlight: false, order: :top)
}.join("\n---\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that this isn't the fault of this PR, but the indentation of these lines look odd. Could you fix it?

if message
msg = "#{message}\n#{msg}"
Expand Down