File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 55Bundler . require :default , :development
66require "pry"
77require "support/core_ext/query_cache"
8+ require "support/core_ext/backtrace_cleaner"
89require "support/minitest_sqlserver"
910require "support/test_in_memory_oltp"
1011require "support/table_definition_sqlserver"
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ # Need to handle `ActiveRecord` lines like they are in the source rather than in the Rails gem.
4+ module SQLServer
5+ module BacktraceCleaner
6+ extend ActiveSupport ::Concern
7+
8+ private
9+
10+ def add_gem_filter
11+ gems_paths = ( Gem . path | [ Gem . default_dir ] ) . map { |p | Regexp . escape ( p ) }
12+ return if gems_paths . empty?
13+
14+ gems_regexp = %r{\A (#{ gems_paths . join ( "|" ) } )/(bundler/)?gems/([^/]+)-([\w .]+)/(.*)}
15+ gems_result = '\3 (\4) \5'
16+
17+ add_filter do |line |
18+ if line . match? ( /activerecord/ )
19+ line
20+ else
21+ line . sub ( gems_regexp , gems_result )
22+ end
23+ end
24+ end
25+
26+ def add_gem_silencer
27+ add_silencer do |line |
28+ ActiveSupport ::BacktraceCleaner ::FORMATTED_GEMS_PATTERN . match? ( line ) && !/activerecord/ . match? ( line )
29+ end
30+ end
31+ end
32+ end
33+
34+ ActiveSupport . on_load ( :active_record ) do
35+ ActiveSupport ::BacktraceCleaner . prepend ( SQLServer ::BacktraceCleaner )
36+ end
You can’t perform that action at this time.
0 commit comments