Skip to content

Commit

Permalink
Lock results file while doing merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
jshraibman-mdsol committed Dec 30, 2012
1 parent 87e81cc commit 4f3b4c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/simplecov.rb
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions simplecov.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 4f3b4c7

Please sign in to comment.