Skip to content

Commit

Permalink
Fixed problem with :verbose=>false in sh and ruby commands
Browse files Browse the repository at this point in the history
(http://onestepback.org/redmine/issues/show/52).
Updated tests to cover all scenarios.
  • Loading branch information
jimweirich committed May 25, 2009
1 parent 762e6c5 commit 6afd6fa
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Fixed the silent option parsing problem.
(http://onestepback.org/redmine/issues/show/47)

* Fixed :verbose=>false flag on sh and ruby commands.

== Version 0.8.7

* Fixed EXEEXT for JRuby on windows.
Expand Down
4 changes: 2 additions & 2 deletions lib/rake/file_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def sh(*cmd, &block)
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
}
end
if RakeFileUtils.verbose_flag == :default
if RakeFileUtils.verbose_flag == :default && options[:verbose].nil?
options[:verbose] = true
else
elsif options[:verbose].nil?
options[:verbose] ||= RakeFileUtils.verbose_flag
end
options[:noop] ||= RakeFileUtils.nowrite_flag
Expand Down
2 changes: 1 addition & 1 deletion rakelib/tags.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Tags
PROG = ENV['TAGS'] || 'ctags'
RUBY_FILES = FileList['**/*.rb']
RUBY_FILES = FileList['**/*.rb'].exclude('sys.rb')
RUBY_FILES.include('**/*.rake')
end

Expand Down
34 changes: 34 additions & 0 deletions test/data/verbose/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

task :standalone_verbose_true do
verbose true
sh "ruby -e '0'"
end

task :standalone_verbose_false do
verbose false
sh "ruby -e '0'"
end

task :inline_verbose_default do
sh "ruby -e '0'"
end

task :inline_verbose_false do
sh "ruby -e '0'", :verbose => false
end

task :inline_verbose_true do
sh "ruby -e '0'", :verbose => true
end

task :block_verbose_true do
verbose(true) do
sh "ruby -e '0'"
end
end

task :block_verbose_false do
verbose(false) do
sh "ruby -e '0'"
end
end
49 changes: 49 additions & 0 deletions test/functional/session_based_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,55 @@ def test_invalid_command_line_options
assert_match %r{invalid +option}i, @err
end

def test_inline_verbose_default_should_show_command
in_environment("PWD" => "test/data/verbose") do
rake "inline_verbose_default"
end
assert_match(/ruby -e/, @err)
end

def test_inline_verbose_true_should_show_command
in_environment("PWD" => "test/data/verbose") do
rake "inline_verbose_true"
end
assert_match(/ruby -e/, @err)
end

def test_inline_verbose_false_should_not_show_command
in_environment("PWD" => "test/data/verbose") do
rake "inline_verbose_false"
end
assert_no_match(/ruby -e/, @err)
end

def test_block_verbose_false_should_not_show_command
in_environment("PWD" => "test/data/verbose") do
rake "block_verbose_false"
end
assert_no_match(/ruby -e/, @err)
end

def test_block_verbose_true_should_show_command
in_environment("PWD" => "test/data/verbose") do
rake "block_verbose_true"
end
assert_match(/ruby -e/, @err)
end

def test_standalone_verbose_true_should_show_command
in_environment("PWD" => "test/data/verbose") do
rake "standalone_verbose_true"
end
assert_match(/ruby -e/, @err)
end

def test_standalone_verbose_false_should_not_show_command
in_environment("PWD" => "test/data/verbose") do
rake "standalone_verbose_false"
end
assert_no_match(/ruby -e/, @err)
end

def test_dry_run
in_environment("PWD" => "test/data/default") do rake "-n", "other" end
assert_match %r{Execute \(dry run\) default}, @out
Expand Down

0 comments on commit 6afd6fa

Please sign in to comment.