diff --git a/lib/simplecov/result_merger.rb b/lib/simplecov/result_merger.rb index c114463e..c9c05971 100644 --- a/lib/simplecov/result_merger.rb +++ b/lib/simplecov/result_merger.rb @@ -13,7 +13,11 @@ def resultset_path # Loads the cached resultset from YAML and returns it as a Hash def resultset if stored_data - SimpleCov::JSON.parse(stored_data) + begin + SimpleCov::JSON.parse(stored_data) + rescue + {} + end else {} end @@ -66,6 +70,7 @@ def store_result(result) command_name, data = result.to_hash.first new_set[command_name] = data File.open(resultset_path, "w+") do |f| + f.flock(File::LOCK_EX) f.puts SimpleCov::JSON.dump(new_set) end true