Skip to content

Commit

Permalink
Suppress colorize on Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Feb 8, 2021
1 parent 629ad57 commit 5be9354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/irb/workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def code_around_binding
body = (start_pos..end_pos).map do |current_pos|
sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos])
end.join("")
"\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
"\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear if use_colorize}\n"
end

def IRB.delete_caller
Expand Down
6 changes: 6 additions & 0 deletions test/irb/test_workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
module TestIRB
class TestWorkSpace < Test::Unit::TestCase
def test_code_around_binding
IRB.conf[:USE_COLORIZE] = false
Tempfile.create('irb') do |f|
code = <<~RUBY
# 1
Expand All @@ -33,6 +34,8 @@ def test_code_around_binding
EOS
end
ensure
IRB.conf.delete(:USE_COLORIZE)
end

def test_code_around_binding_with_existing_unreadable_file
Expand All @@ -52,6 +55,7 @@ def test_code_around_binding_with_existing_unreadable_file
end

def test_code_around_binding_with_script_lines__
IRB.conf[:USE_COLORIZE] = false
with_script_lines do |script_lines|
Tempfile.create('irb') do |f|
code = "IRB::WorkSpace.new(binding)\n"
Expand All @@ -67,6 +71,8 @@ def test_code_around_binding_with_script_lines__
EOS
end
end
ensure
IRB.conf.delete(:USE_COLORIZE)
end

def test_code_around_binding_on_irb
Expand Down

0 comments on commit 5be9354

Please sign in to comment.