Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,7 @@ def recover(argv)
DIR = File.join(__dir__, '')
def self.filter_backtrace(array)
unless $DEBUG
array.delete_if {|bt| bt.start_with?(DIR)}
array.delete_if {|bt| (bt.respond_to?(:path) ? bt.path : bt).start_with?(DIR)}
end
array
end
Expand Down
6 changes: 6 additions & 0 deletions test/optparse/test_optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ def test_nonopt_pattern
assert_equal(["-t"], e.args)
end

def test_parse_error_set_backtrace
e = assert_raise(OptionParser::InvalidOption) {@opt.parse(%w(-t))}
assert_nothing_raised {e.set_backtrace(e.backtrace)}
assert_nothing_raised {e.set_backtrace(e.backtrace_locations)}
end

def test_help_pager
require 'tmpdir'
Dir.mktmpdir do |dir|
Expand Down