Skip to content

Commit

Permalink
Filter Sorbet in backtrace (#959)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Waite <[email protected]>
  • Loading branch information
andyw8 and andyw8 committed Sep 5, 2023
1 parent c3678ee commit 4812fc0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
require "debug"
require "mocha/minitest"

sorbet_paths = Gem.loaded_specs["sorbet-runtime"].full_require_paths.freeze
DEBUGGER__::CONFIG[:skip_path] = Array(DEBUGGER__::CONFIG[:skip_path]) + sorbet_paths
SORBET_PATHS = T.let(Gem.loaded_specs["sorbet-runtime"].full_require_paths.freeze, T::Array[String])
DEBUGGER__::CONFIG[:skip_path] = Array(DEBUGGER__::CONFIG[:skip_path]) + SORBET_PATHS

minitest_reporter = if ENV["SPEC_REPORTER"]
Minitest::Reporters::SpecReporter.new(color: true)
Expand All @@ -28,3 +28,16 @@ class Test
Minitest::Test.make_my_diffs_pretty!
end
end

class BacktraceWithoutSorbetFilter < Minitest::BacktraceFilter
extend T::Sig

sig { override.params(bt: T.nilable(T::Array[String])).returns(T::Array[String]) }
def filter(bt)
super.select do |line|
SORBET_PATHS.none? { |path| line.include?(path) }
end
end
end

Minitest.backtrace_filter = BacktraceWithoutSorbetFilter.new

0 comments on commit 4812fc0

Please sign in to comment.