Skip to content

Commit

Permalink
Abort on warnings again
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Apr 10, 2023
1 parent 7cac78e commit 68da883
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/zeitwerk/loader/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ def log!
# Common use case.
return false if ignored_paths.empty?

walk_up(abspath) do |abspath|
return true if ignored_path?(abspath)
return false if roots.key?(abspath)
walk_up(abspath) do |path|
return true if ignored_path?(path)
return false if roots.key?(path)
end

false
Expand Down
16 changes: 11 additions & 5 deletions test/support/no_warnings_policy.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# frozen_string_literal: true

module NoWarningsPolicy
MESSAGE = "This test suite aborts on warnings, please fix the one above."
def ignore?(msg)
msg.include?("Zeitwerk defines the constant")
end

def halt
abort("This test suite aborts on warnings, please fix the one above.")
end

if Warning.method(:warn).arity == 1
def warn(*)
def warn(msg)
super
abort(MESSAGE)
halt unless ignore?(msg)
end
else
def warn(*, **)
def warn(msg, **)
super
abort(MESSAGE)
halt unless ignore?(msg)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require "minitest/reporters"
Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)

# require_relative "support/no_warnings_policy"
require_relative "support/no_warnings_policy"
require_relative "support/test_macro"
require_relative "support/delete_loaded_feature"
require_relative "support/loader_test"
Expand Down

0 comments on commit 68da883

Please sign in to comment.