From 8737538ce2f7fdf2ed34267801c574facdacc2f6 Mon Sep 17 00:00:00 2001 From: Peter Vandenberk Date: Fri, 3 Apr 2026 08:44:13 +0100 Subject: [PATCH 1/2] Add unit test for "standard" system dir --- test/test_rake_application.rb | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/test_rake_application.rb b/test/test_rake_application.rb index a32d07b17..e661a3c3b 100644 --- a/test/test_rake_application.rb +++ b/test/test_rake_application.rb @@ -365,6 +365,44 @@ def @app.standard_system_dir flunk "failed to find system rakefile" end + def test_load_from_calculated_system_rakefile_on_windows + rakefile_default + def @app.windows? + true + end + + @app.instance_eval do + handle_options [] + options.silent = true + options.load_system = true + options.rakelib = [] + load_rakefile + end + + assert_equal File.join(Dir.home, "Rake"), @app.system_dir + rescue SystemExit + flunk "failed to find system rakefile" + end + + def test_load_from_calculated_system_rakefile_on_unix + rakefile_default + def @app.windows? + false + end + + @app.instance_eval do + handle_options [] + options.silent = true + options.load_system = true + options.rakelib = [] + load_rakefile + end + + assert_equal File.join(Dir.home, ".rake"), @app.system_dir + rescue SystemExit + flunk "failed to find system rakefile" + end + def test_terminal_columns old_rake_columns = ENV["RAKE_COLUMNS"] From 496e60dd6e601d4569cf3f6f8852db2e7a25b7ae Mon Sep 17 00:00:00 2001 From: Peter Vandenberk Date: Fri, 3 Apr 2026 08:49:39 +0100 Subject: [PATCH 2/2] Dedupe and simplify `standard_system_dir` method --- lib/rake/application.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 7bab4cd54..b15d0202a 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -754,12 +754,10 @@ def system_dir # :nodoc: end # The standard directory containing system wide rake files. - if Win32.windows? - def standard_system_dir #:nodoc: + def standard_system_dir #:nodoc: + if windows? File.join(Dir.home, "Rake") - end - else - def standard_system_dir #:nodoc: + else File.join(Dir.home, ".rake") end end