From b329f983b137b396c651ee03a6dae14b6f834bd8 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Sat, 11 May 2024 15:17:30 -0700 Subject: [PATCH] Fix Rake.verbose to return true/false even if unset Unset returns FileUtilsExt.verbose_flag which is set to Object.new by default, which is truthy. Compare against DEFAULT and return verbose_flag only if set. --- lib/rake/file_utils_ext.rb | 2 +- test/test_rake_file_utils.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb index 687d80584..ac2e55c12 100644 --- a/lib/rake/file_utils_ext.rb +++ b/lib/rake/file_utils_ext.rb @@ -60,7 +60,7 @@ def verbose(value=nil) FileUtilsExt.verbose_flag = oldvalue end end - FileUtilsExt.verbose_flag + FileUtilsExt.verbose_flag != DEFAULT && FileUtilsExt.verbose_flag end # Get/set the nowrite flag controlling output from the FileUtils diff --git a/test/test_rake_file_utils.rb b/test/test_rake_file_utils.rb index 3af5e96f1..829f61cae 100644 --- a/test/test_rake_file_utils.rb +++ b/test/test_rake_file_utils.rb @@ -105,6 +105,8 @@ def test_safe_ln_fails_on_script_error end def test_verbose + RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT + assert_equal false, verbose verbose true assert_equal true, verbose verbose false