diff --git a/lib/simplecov.rb b/lib/simplecov.rb index 0db017fe..50739b2d 100644 --- a/lib/simplecov.rb +++ b/lib/simplecov.rb @@ -1,6 +1,8 @@ # # Code coverage for ruby 1.9. Please check out README for a full introduction. # +require 'lockfile' + module SimpleCov # Indicates invalid coverage data class CoverageDataError < StandardError; end; @@ -52,8 +54,12 @@ def result # If we're using merging of results, store the current result # first, then merge the results and return those if use_merging - SimpleCov::ResultMerger.store_result(@result) if @result - return SimpleCov::ResultMerger.merged_result + lockfile = ::Lockfile.new ResultMerger.resultset_path + '.lockfile' + + lockfile.lock do + SimpleCov::ResultMerger.store_result(@result) if @result + return SimpleCov::ResultMerger.merged_result + end else return @result if defined? @result end diff --git a/simplecov.gemspec b/simplecov.gemspec index 65eae894..fa1fb229 100644 --- a/simplecov.gemspec +++ b/simplecov.gemspec @@ -13,6 +13,7 @@ Gem::Specification.new do |gem| gem.summary = gem.description gem.add_dependency 'multi_json', '~> 1.0' + gem.add_dependency 'lockfile' gem.add_dependency 'simplecov-html', '~> 0.7.1' gem.add_development_dependency 'aruba'