Skip to content

Commit

Permalink
Drop Ruby 2.5 support
Browse files Browse the repository at this point in the history
Because it has reached EOL for more than 1.5 years and it won't be
supported by the next reline version either.
  • Loading branch information
st0012 committed Jul 25, 2022
1 parent 4b38229 commit 2084a9a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 46 deletions.
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: 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")
if message
msg = "#{message}\n#{msg}"
Expand Down

0 comments on commit 2084a9a

Please sign in to comment.