Skip to content

Commit be030da

Browse files
kaiquekandykogahsbt
authored andcommitted
Set ENV["TESTOPTS"] with "-v" when verbose is called. Doing that -v and --verbose options will work as expected
Assert ENV
1 parent 68020a7 commit be030da

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

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
@@ -12,6 +12,7 @@ def teardown
1212
FileUtils::LN_SUPPORTED[0] = true
1313
RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
1414
ENV["RAKE_TEST_SH"] = @rake_test_sh
15+
ENV["TESTOPTS"] = nil
1516

1617
super
1718
end
@@ -106,8 +107,13 @@ def test_safe_ln_fails_on_script_error
106107
def test_verbose
107108
verbose true
108109
assert_equal true, verbose
110+
assert_equal '-v', ENV['TESTOPTS']
111+
112+
ENV['TESTOPTS'] = nil
109113
verbose false
110114
assert_equal false, verbose
115+
assert_equal nil, ENV['TESTOPTS']
116+
111117
verbose(true) {
112118
assert_equal true, verbose
113119
}

0 commit comments

Comments
 (0)