Skip to content

Commit

Permalink
Fix tests to work with current FileUtils
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeremyevans committed Jun 12, 2020
1 parent 4fe73ff commit bfdf462
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions test/test_rake_clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ def test_cleanup_ignores_missing_files
def test_cleanup_trace
file_name = create_file

assert_output "", "rm -r #{file_name}\n" do
out, err = capture_io do
with_trace true do
Rake::Cleaner.cleanup(file_name)
end
end

if err == ""
# Current FileUtils
assert_equal "rm -r #{file_name}\n", out
else
# Old FileUtils
assert_equal "", out
assert_equal "rm -r #{file_name}\n", err
end
end

def test_cleanup_without_trace
Expand All @@ -70,11 +79,18 @@ def test_cleanup_opt_overrides_trace_silent
def test_cleanup_opt_overrides_trace_verbose
file_name = create_file

assert_output "", "rm -r #{file_name}\n" do
out, err = capture_io do
with_trace false do
Rake::Cleaner.cleanup(file_name, verbose: true)
end
end

if err == ""
assert_equal "rm -r #{file_name}\n", out
else
assert_equal "", out
assert_equal "rm -r #{file_name}\n", err
end
end

private
Expand Down

0 comments on commit bfdf462

Please sign in to comment.