Skip to content

Commit bfdf462

Browse files
committed
Fix tests to work with current FileUtils
Historically, FileUtils logged verbose output to stderr instead of stdout. This was fixed in FileUtils to log verbose output to stdout (since it isn't an error). This commit adjusts the tests to handle both FileUtils versions.
1 parent 4fe73ff commit bfdf462

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

test/test_rake_clean.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ def test_cleanup_ignores_missing_files
4040
def test_cleanup_trace
4141
file_name = create_file
4242

43-
assert_output "", "rm -r #{file_name}\n" do
43+
out, err = capture_io do
4444
with_trace true do
4545
Rake::Cleaner.cleanup(file_name)
4646
end
4747
end
48+
49+
if err == ""
50+
# Current FileUtils
51+
assert_equal "rm -r #{file_name}\n", out
52+
else
53+
# Old FileUtils
54+
assert_equal "", out
55+
assert_equal "rm -r #{file_name}\n", err
56+
end
4857
end
4958

5059
def test_cleanup_without_trace
@@ -70,11 +79,18 @@ def test_cleanup_opt_overrides_trace_silent
7079
def test_cleanup_opt_overrides_trace_verbose
7180
file_name = create_file
7281

73-
assert_output "", "rm -r #{file_name}\n" do
82+
out, err = capture_io do
7483
with_trace false do
7584
Rake::Cleaner.cleanup(file_name, verbose: true)
7685
end
7786
end
87+
88+
if err == ""
89+
assert_equal "rm -r #{file_name}\n", out
90+
else
91+
assert_equal "", out
92+
assert_equal "rm -r #{file_name}\n", err
93+
end
7894
end
7995

8096
private

0 commit comments

Comments
 (0)