jimweirich/rake — pull request #266 by randycoulman (2014-04-09 13:55:33+00:00)
Title: Don't report an error when cleaning missing files

When doing a `rake clean` or `rake clobber`, it is often the case that
some of the files don't exist. The desired end state of the clean or
clobber task is that the specified files no longer be present at the
end of the task; if they weren't there in the first place, the
post-condition is still satisfied.

Without this change, running a `rake clean` or `rake clobber` is too
noisy, and yet silently failing to delete a file is not a good
solution either.

This may not be the best fix for this. I tried two options:

1) Add a second rescue block for `Errno::ENOENT`. This fails
`test_cleanup` in JRuby, because JRuby raises `Errno::ENOENT` for that
case.

2) Use `File.exist?` as I've done. In order to make this work, I had
to modify the permissions used in `create_undeletable_file`, because
`File.exist?` returns false for a file in an unreadable directory.

With either of these solutions, there are corner cases where one or
more Ruby implementations will silently fail to delete a file. My
opinion is that those corner cases are rare enough that this PR makes
sense for the far more common case.