I'm currently issuing a problem with running tests with rspec. All the test files (*_spec.rb) may run successfully. In same rare cases an error -- Errno::EACCES
may appear and one of the tests may fail. E.g:
All the test in the file *_spec.rb
run:
- Successfully.
- Successfully.
- One the test had failed.
- Successfully.
- One the test had failed (not the same as in #3).
- etc.
The exception raises from the lines like:
FileUtils.mv
FileUtils.mkdir_p
FileUtils.rm_r
All of those list work with files or directories and are used many times in tests. I.e.:
create folder(with subfolders, with files, etc.), rename folder, test something, delete.. and so on.
It looks like the problem is hidden somewhere in "timing"(if something is not done yet and another action tries to access that something). That mind comes from:
begin
FileUtils.mv(a, b) # if an `Errno:EACCESS` was raised here
rescue #
FileUtils.mv(a, b) # it wouldn't be raised now
end
The question is:
How can it be fixed? (i mean Errno:EACCESS
which is reproduced rarely and some tests)
- Adding
sleep
after every operation with files is not acceptable nevertheless it will help. - ruby's methods (
FileUtils.(mv|rm_r|mkdir_p)
) may be modified to retry once onErrno::EACCES
but is this the best solution?
P.S.
Sorry for my English and feel free to ask any question as i've tried to explain as brief as i could. Thanks in advanced, at least for you've read this to the end;