diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 4c6f71917..cf9855147 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -107,6 +107,8 @@ 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/support/rakefile_definitions.rb b/test/support/rakefile_definitions.rb index d276b2fd5..b4eddb20b 100644 --- a/test/support/rakefile_definitions.rb +++ b/test/support/rakefile_definitions.rb @@ -49,6 +49,16 @@ def rakefile_test_task RAKEFILE end + def rakefile_test_task_verbose + rakefile <<-RAKEFILE + require "rake/testtask" + + Rake::TestTask.new(:unit) do |t| + t.verbose = true + end + RAKEFILE + end + def rakefile_chains rakefile <<-DEFAULT task :default => "play.app" diff --git a/test/test_rake_functional.rb b/test/test_rake_functional.rb index 9113d8616..0d3e1d0c0 100644 --- a/test/test_rake_functional.rb +++ b/test/test_rake_functional.rb @@ -384,6 +384,20 @@ def test_test_task_descriptions assert_match(/custom test task description/, @out) end + def test_test_task_when_verbose_unless_verbose_passed_not_prompt_testopts + rakefile_test_task_verbose + rake 'unit' + exp = /TESTOPTS="--verbose" to pass --verbose/ + 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