Skip to content

Commit

Permalink
Suppress irb_info measures ambiguous_width in command test (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored Jan 27, 2025
1 parent 876bfcc commit 5623f0a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 48 deletions.
19 changes: 19 additions & 0 deletions test/irb/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ def without_rdoc(&block)
::Kernel.undef_method :irb_original_require
}
end

def execute_lines(*lines, conf: {}, main: self, irb_path: nil)
# To suppress irb_info measure ambiguous_width with escape sequences
Reline.core.instance_variable_set(:@ambiguous_width, 1)

IRB.init_config(nil)
IRB.conf[:VERBOSE] = false
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf.merge!(conf)
input = TestInputMethod.new(lines)
irb = IRB::Irb.new(IRB::WorkSpace.new(main), input)
irb.context.return_format = "=> %s\n"
irb.context.irb_path = irb_path if irb_path
IRB.conf[:MAIN_CONTEXT] = irb.context
IRB.conf[:USE_PAGER] = false
capture_output do
irb.eval_input
end
end
end

class IntegrationTestCase < TestCase
Expand Down
16 changes: 0 additions & 16 deletions test/irb/test_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@ def teardown
FileUtils.rm_rf(@tmpdir)
restore_encodings
end

def execute_lines(*lines, conf: {}, main: self, irb_path: nil)
capture_output do
IRB.init_config(nil)
IRB.conf[:VERBOSE] = false
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:USE_PAGER] = false
IRB.conf.merge!(conf)
input = TestInputMethod.new(lines)
irb = IRB::Irb.new(IRB::WorkSpace.new(main), input)
irb.context.return_format = "=> %s\n"
irb.context.irb_path = irb_path if irb_path
IRB.conf[:MAIN_CONTEXT] = irb.context
irb.eval_input
end
end
end

class FrozenObjectTest < CommandTestCase
Expand Down
16 changes: 0 additions & 16 deletions test/irb/test_eval_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ def teardown
restore_encodings
end

def execute_lines(*lines, conf: {}, main: self, irb_path: nil)
IRB.init_config(nil)
IRB.conf[:VERBOSE] = false
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:USE_PAGER] = false
IRB.conf.merge!(conf)
input = TestInputMethod.new(lines)
irb = IRB::Irb.new(IRB::WorkSpace.new(main), input)
irb.context.return_format = "=> %s\n"
irb.context.irb_path = irb_path if irb_path
IRB.conf[:MAIN_CONTEXT] = irb.context
capture_output do
irb.eval_input
end
end

def test_eval_history_is_disabled_by_default
out, err = execute_lines(
"a = 1",
Expand Down
16 changes: 0 additions & 16 deletions test/irb/test_helper_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ def teardown
$VERBOSE = @verbosity
restore_encodings
end

def execute_lines(*lines, conf: {}, main: self, irb_path: nil)
IRB.init_config(nil)
IRB.conf[:VERBOSE] = false
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf.merge!(conf)
input = TestInputMethod.new(lines)
irb = IRB::Irb.new(IRB::WorkSpace.new(main), input)
irb.context.return_format = "=> %s\n"
irb.context.irb_path = irb_path if irb_path
IRB.conf[:MAIN_CONTEXT] = irb.context
IRB.conf[:USE_PAGER] = false
capture_output do
irb.eval_input
end
end
end

module TestHelperMethod
Expand Down

0 comments on commit 5623f0a

Please sign in to comment.