Skip to content

Commit

Permalink
Log directories being ignored for having no Ruby file
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed May 26, 2024
1 parent ba26886 commit a5bd1df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/zeitwerk/loader/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ module Zeitwerk::Loader::Helpers

if dir?(abspath)
next if roots.key?(abspath)
next if !has_at_least_one_ruby_file?(abspath)

if !has_at_least_one_ruby_file?(abspath)
log("directory #{abspath} is ignored because it has no Ruby files") if logger
next
end

ftype = :directory
else
next unless ruby?(abspath)
Expand Down
10 changes: 10 additions & 0 deletions test/lib/zeitwerk/test_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ def logger.debug(message)
end
end

test "logs directories being ignored because they have no Ruby files" do
files = [["tasks/foo.rake", ""]]
with_files(files) do
assert_logged(%r{directory .*?/tasks is ignored because it has no Ruby files}) do
loader.push_dir(".")
loader.setup
end
end
end

test "logs when eager loading starts" do
with_setup do
assert_logged(/eager load start/) do
Expand Down

0 comments on commit a5bd1df

Please sign in to comment.