diff --git a/lib/zeitwerk/loader/eager_load.rb b/lib/zeitwerk/loader/eager_load.rb index 83fa0cc..2ab2b6b 100644 --- a/lib/zeitwerk/loader/eager_load.rb +++ b/lib/zeitwerk/loader/eager_load.rb @@ -164,8 +164,8 @@ def load_file(path) log("eager load directory #{dir} start") if logger queue = [[dir, namespace]] - while (dir, namespace = queue.shift) - ls(dir) do |basename, abspath, ftype| + while (current_dir, namespace = queue.shift) + ls(current_dir) do |basename, abspath, ftype| next if honour_exclusions && eager_load_exclusions.member?(abspath) if ftype == :file diff --git a/test/lib/zeitwerk/test_logging.rb b/test/lib/zeitwerk/test_logging.rb index c18feeb..2e5eb4e 100644 --- a/test/lib/zeitwerk/test_logging.rb +++ b/test/lib/zeitwerk/test_logging.rb @@ -214,6 +214,26 @@ def logger.debug(message) end end + test "logs when eager loading a directory starts" do + with_files([]) do + assert_logged(%r(eager load directory #{Dir.pwd} start)) do + loader.push_dir(".") + loader.setup + loader.eager_load_dir(".") + end + end + end + + test "logs when eager loading a directory ends" do + with_files([]) do + assert_logged(%r(eager load directory #{Dir.pwd} end)) do + loader.push_dir(".") + loader.setup + loader.eager_load_dir(".") + end + end + end + test "logs when eager loading starts" do with_setup do assert_logged(/eager load start/) do