Skip to content

Commit

Permalink
WIP: Fix minitest bug and RM reporters double backtrace
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jan 29, 2025
1 parent 45ba52c commit c5d21bb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,33 @@
require_relative '../gem/lib/pagy'
require 'minitest/autorun'

# /usr/local/lib/ruby/gems/3.4.0/gems/minitest-5.25.4/lib/minitest.rb
module Minitest
class UnexpectedError
module AvoidBacktraceMangling
def message # :nodoc:
bt = Minitest.filter_backtrace(backtrace)
.map { |p| p.sub(%r{^#{Dir.pwd}/}, "") }.join("\n ") # <-- sub and not gsub, inside map
"#{error.class}: #{error.message}\n #{bt}"
end
end
prepend AvoidBacktraceMangling
end

# /home/dd/.local/share/JetBrains/Toolbox/apps/rubymine/plugins/ruby/rb/testing/patch/testunit/minitest/rm_reporter_plugin.rb
class RubyMineReporter < Reporter
module AvoidDoubleBacktrace
def with_message_and_backtrace(result)
exception = result.failure
msg = exception.nil? ? '' : "#{exception.class.name}: #{exception.message}"
# backtrace = exception.nil? ? '' : Minitest::filter_backtrace(exception.backtrace).join("\n")

# yield(msg, backtrace)
yield(msg)
end
end
prepend AvoidDoubleBacktrace
end
end

require_relative 'helpers/warning_filters'

0 comments on commit c5d21bb

Please sign in to comment.