diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-29 06:53:05 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-29 06:53:05 +0000 |
commit | e0b0b923c68dfdf6552bbca69e856424e678f962 (patch) | |
tree | 97a677d498543758b79b3856e24eb4dd032de8b1 /spec | |
parent | 5689f7c7e4ce0ee21e439ccd3ac15f0af0920c35 (diff) | |
download | ruby-e0b0b923c68dfdf6552bbca69e856424e678f962.tar.gz |
fix race condition
* spec/mspec/lib/mspec/helpers/fs.rb (Object#mkdir_p): fix race
condition when multi_exec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mspec/lib/mspec/helpers/fs.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/mspec/lib/mspec/helpers/fs.rb b/spec/mspec/lib/mspec/helpers/fs.rb index ee33f5fec0..e842896126 100644 --- a/spec/mspec/lib/mspec/helpers/fs.rb +++ b/spec/mspec/lib/mspec/helpers/fs.rb @@ -17,11 +17,18 @@ class Object parts.each do |part| name = File.join name, part - if File.file? name + stat = File.stat name + if stat.file? raise ArgumentError, "path component of #{path} is a file" end - Dir.mkdir name unless File.directory? name + unless stat.directory? + begin + Dir.mkdir name + rescue Errno::EEXIST + raise unless File.directory? name + end + end end end |