1- require 'active_support/testing/strict_warnings'
2-
3- # This module flags methods in rails tests and blows up ours
4- module ActiveSupport
5- module RaiseWarnings # :nodoc:
6- begin
7- allowed = remove_const ( :ALLOWED_WARNINGS )
8- const_set ( :ALLOWED_WARNINGS , Regexp . union ( allowed , /previous definition of/ ) )
9- end
1+ # frozen_string_literal: true
2+
3+ $VERBOSE = true
4+ Warning [ :deprecated ] = true
5+
6+ module RailsStrictWarnings # :nodoc:
7+ class WarningError < StandardError ; end
8+
9+ PROJECT_ROOT = File . expand_path ( "../" , __dir__ )
10+ ALLOWED_WARNINGS = Regexp . union (
11+ /circular require considered harmful.*delayed_job/ , # Bug in delayed job.
12+
13+ # Expected non-verbose warning emitted by Rails.
14+ /Ignoring .*\. yml because it has expired/ ,
15+ /Failed to validate the schema cache because/ ,
16+ /previous definition of/
17+ )
18+
19+ SUPPRESSED_WARNINGS = Regexp . union (
20+ # TODO: remove if https://github.com/mikel/mail/pull/1557 or similar fix
21+ %r{/lib/mail/parsers/.*statement not reached} ,
22+ %r{/lib/mail/parsers/.*assigned but unused variable - disp_type_s} ,
23+ %r{/lib/mail/parsers/.*assigned but unused variable - testEof}
24+ )
25+
26+ def warn ( message , ...)
27+ return if SUPPRESSED_WARNINGS . match? ( message )
28+
29+ super
30+
31+ return unless message . include? ( PROJECT_ROOT )
32+ return if ALLOWED_WARNINGS . match? ( message )
33+ return unless ENV [ "RAILS_STRICT_WARNINGS" ] || ENV [ "BUILDKITE" ]
34+
35+ raise WarningError . new ( message )
1036 end
11- end
37+ end
38+
39+ Warning . singleton_class . prepend ( RailsStrictWarnings )
40+
0 commit comments