Skip to content

Commit 6afd6fa

Browse files
committed
Fixed problem with :verbose=>false in sh and ruby commands
(http://onestepback.org/redmine/issues/show/52). Updated tests to cover all scenarios.
1 parent 762e6c5 commit 6afd6fa

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Fixed the silent option parsing problem.
1616
(http://onestepback.org/redmine/issues/show/47)
1717

18+
* Fixed :verbose=>false flag on sh and ruby commands.
19+
1820
== Version 0.8.7
1921

2022
* Fixed EXEEXT for JRuby on windows.

lib/rake/file_utils.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def sh(*cmd, &block)
3737
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
3838
}
3939
end
40-
if RakeFileUtils.verbose_flag == :default
40+
if RakeFileUtils.verbose_flag == :default && options[:verbose].nil?
4141
options[:verbose] = true
42-
else
42+
elsif options[:verbose].nil?
4343
options[:verbose] ||= RakeFileUtils.verbose_flag
4444
end
4545
options[:noop] ||= RakeFileUtils.nowrite_flag

rakelib/tags.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Tags
44
PROG = ENV['TAGS'] || 'ctags'
5-
RUBY_FILES = FileList['**/*.rb']
5+
RUBY_FILES = FileList['**/*.rb'].exclude('sys.rb')
66
RUBY_FILES.include('**/*.rake')
77
end
88

test/data/verbose/Rakefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
task :standalone_verbose_true do
3+
verbose true
4+
sh "ruby -e '0'"
5+
end
6+
7+
task :standalone_verbose_false do
8+
verbose false
9+
sh "ruby -e '0'"
10+
end
11+
12+
task :inline_verbose_default do
13+
sh "ruby -e '0'"
14+
end
15+
16+
task :inline_verbose_false do
17+
sh "ruby -e '0'", :verbose => false
18+
end
19+
20+
task :inline_verbose_true do
21+
sh "ruby -e '0'", :verbose => true
22+
end
23+
24+
task :block_verbose_true do
25+
verbose(true) do
26+
sh "ruby -e '0'"
27+
end
28+
end
29+
30+
task :block_verbose_false do
31+
verbose(false) do
32+
sh "ruby -e '0'"
33+
end
34+
end

test/functional/session_based_tests.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,55 @@ def test_invalid_command_line_options
163163
assert_match %r{invalid +option}i, @err
164164
end
165165

166+
def test_inline_verbose_default_should_show_command
167+
in_environment("PWD" => "test/data/verbose") do
168+
rake "inline_verbose_default"
169+
end
170+
assert_match(/ruby -e/, @err)
171+
end
172+
173+
def test_inline_verbose_true_should_show_command
174+
in_environment("PWD" => "test/data/verbose") do
175+
rake "inline_verbose_true"
176+
end
177+
assert_match(/ruby -e/, @err)
178+
end
179+
180+
def test_inline_verbose_false_should_not_show_command
181+
in_environment("PWD" => "test/data/verbose") do
182+
rake "inline_verbose_false"
183+
end
184+
assert_no_match(/ruby -e/, @err)
185+
end
186+
187+
def test_block_verbose_false_should_not_show_command
188+
in_environment("PWD" => "test/data/verbose") do
189+
rake "block_verbose_false"
190+
end
191+
assert_no_match(/ruby -e/, @err)
192+
end
193+
194+
def test_block_verbose_true_should_show_command
195+
in_environment("PWD" => "test/data/verbose") do
196+
rake "block_verbose_true"
197+
end
198+
assert_match(/ruby -e/, @err)
199+
end
200+
201+
def test_standalone_verbose_true_should_show_command
202+
in_environment("PWD" => "test/data/verbose") do
203+
rake "standalone_verbose_true"
204+
end
205+
assert_match(/ruby -e/, @err)
206+
end
207+
208+
def test_standalone_verbose_false_should_not_show_command
209+
in_environment("PWD" => "test/data/verbose") do
210+
rake "standalone_verbose_false"
211+
end
212+
assert_no_match(/ruby -e/, @err)
213+
end
214+
166215
def test_dry_run
167216
in_environment("PWD" => "test/data/default") do rake "-n", "other" end
168217
assert_match %r{Execute \(dry run\) default}, @out

0 commit comments

Comments
 (0)