diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-29 11:19:42 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-29 11:19:42 +0000 |
commit | 01ebc04fa242eaa9ea6129e69a37570e92360056 (patch) | |
tree | 2a39d8b605a16bb62fb2d066ed2830abdddeef9f /spec/mspec/lib | |
parent | fc7241ffe2238d228e5121caf8e5ae18fa1ea20e (diff) |
Simplify, avoid extra exceptions and add test for concurrent mspec mkdir_p
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec/lib')
-rw-r--r-- | spec/mspec/lib/mspec/helpers/fs.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/spec/mspec/lib/mspec/helpers/fs.rb b/spec/mspec/lib/mspec/helpers/fs.rb index 5a9c3bdba1..2200339bd7 100644 --- a/spec/mspec/lib/mspec/helpers/fs.rb +++ b/spec/mspec/lib/mspec/helpers/fs.rb @@ -17,16 +17,19 @@ class Object parts.each do |part| name = File.join name, part - stat = File.stat name rescue nil - if stat and stat.file? + if File.file? name raise ArgumentError, "path component of #{path} is a file" end - unless stat and stat.directory? + unless File.directory? name begin Dir.mkdir name - rescue Errno::EEXIST - raise unless File.directory? name + rescue Errno::EEXIST => e + if File.directory? name + # OK, another process/thread created the same directory + else + raise e + end end end end |