diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb index e91ad595f..3e6de827c 100644 --- a/lib/rake/file_utils_ext.rb +++ b/lib/rake/file_utils_ext.rb @@ -53,6 +53,7 @@ def #{name}(*args, **options, &block) def verbose(value=nil) oldvalue = FileUtilsExt.verbose_flag FileUtilsExt.verbose_flag = value unless value.nil? + ENV["TESTOPTS"] = "-v" if value if block_given? begin yield diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 56521d23d..896155e4a 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -109,8 +109,6 @@ def define desc @description task @name => Array(deps) do FileUtilsExt.verbose(@verbose) do - puts "Use TESTOPTS=\"--verbose\" to pass --verbose" \ - ", etc. to runners." if ARGV.include? "--verbose" args = "#{ruby_opts_string} #{run_code} " + "#{file_list_string} #{option_list}" diff --git a/test/test_rake_file_utils.rb b/test/test_rake_file_utils.rb index ebedd56b2..1eae13fd5 100644 --- a/test/test_rake_file_utils.rb +++ b/test/test_rake_file_utils.rb @@ -13,6 +13,7 @@ def teardown FileUtils::LN_SUPPORTED[0] = true RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT ENV["RAKE_TEST_SH"] = @rake_test_sh + ENV["TESTOPTS"] = nil super end @@ -107,8 +108,13 @@ def test_safe_ln_fails_on_script_error def test_verbose verbose true assert_equal true, verbose + assert_equal '-v', ENV['TESTOPTS'] + + ENV['TESTOPTS'] = nil verbose false assert_equal false, verbose + assert_equal nil, ENV['TESTOPTS'] + verbose(true) { assert_equal true, verbose } diff --git a/test/test_rake_functional.rb b/test/test_rake_functional.rb index afc31d28f..569f5476c 100644 --- a/test/test_rake_functional.rb +++ b/test/test_rake_functional.rb @@ -422,13 +422,6 @@ def test_test_task_when_verbose_unless_verbose_passed_not_prompt_testopts refute_match exp, @out end - def test_test_task_when_verbose_passed_prompts_testopts - rakefile_test_task - rake "--verbose", "unit" - exp = /TESTOPTS="--verbose" to pass --verbose/ - assert_match exp, @out - end - def test_comment_before_task_acts_like_desc rakefile_comments