Skip to content

Commit a8f36f1

Browse files
Set ENV["TESTOPTS"] with "-v" when verbose is called. Doing that -v and --verbose options will work as expected
Assert ENV
1 parent 5c60da8 commit a8f36f1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/rake/file_utils_ext.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def #{name}(*args, **options, &block)
5353
def verbose(value=nil)
5454
oldvalue = FileUtilsExt.verbose_flag
5555
FileUtilsExt.verbose_flag = value unless value.nil?
56+
ENV["TESTOPTS"] = "-v" if value
5657
if block_given?
5758
begin
5859
yield

test/test_rake_file_utils.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def teardown
1313
FileUtils::LN_SUPPORTED[0] = true
1414
RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
1515
ENV["RAKE_TEST_SH"] = @rake_test_sh
16+
ENV["TESTOPTS"] = nil
1617

1718
super
1819
end
@@ -107,8 +108,13 @@ def test_safe_ln_fails_on_script_error
107108
def test_verbose
108109
verbose true
109110
assert_equal true, verbose
111+
assert_equal '-v', ENV['TESTOPTS']
112+
113+
ENV['TESTOPTS'] = nil
110114
verbose false
111115
assert_equal false, verbose
116+
assert_equal nil, ENV['TESTOPTS']
117+
112118
verbose(true) {
113119
assert_equal true, verbose
114120
}

0 commit comments

Comments
 (0)