{"action":"created","comment":{"url":"https://api.github.com/repos/colszowka/simplecov/pulls/comments/124932321","pull_request_review_id":47273370,"id":124932321,"diff_hunk":"@@ -0,0 +1,110 @@\n+require \"helper\"\n+\n+if SimpleCov.usable?\n+  describe SimpleCov do\n+    describe \".result\" do\n+      before do\n+        SimpleCov.clear_result!\n+        allow(Coverage).to receive(:result).once.and_return({})\n+        allow(SimpleCov).to receive(:add_not_loaded_files).once.and_return({})\n+      end\n+\n+      context \"with merging disabled\" do\n+        before do\n+          allow(SimpleCov).to receive(:use_merging).once.and_return(false)","path":"spec/simplecov_spec.rb","position":14,"original_position":14,"commit_id":"78c1171e98b7227f6bdd8f76f4c14666fd7fc5ea","original_commit_id":"78c1171e98b7227f6bdd8f76f4c14666fd7fc5ea","user":{"login":"jenseng","id":109489,"avatar_url":"https://avatars2.githubusercontent.com/u/109489?v=3","gravatar_id":"","url":"https://api.github.com/users/jenseng","html_url":"https://github.com/jenseng","followers_url":"https://api.github.com/users/jenseng/followers","following_url":"https://api.github.com/users/jenseng/following{/other_user}","gists_url":"https://api.github.com/users/jenseng/gists{/gist_id}","starred_url":"https://api.github.com/users/jenseng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenseng/subscriptions","organizations_url":"https://api.github.com/users/jenseng/orgs","repos_url":"https://api.github.com/users/jenseng/repos","events_url":"https://api.github.com/users/jenseng/events{/privacy}","received_events_url":"https://api.github.com/users/jenseng/received_events","type":"User","site_admin":false},"body":"i suppose, if we set it back. this feels safer IMO, since we're not changing instance variables of the SimpleCov class, which may have side effects in later specs","created_at":"2017-06-29T23:03:49Z","updated_at":"2017-06-29T23:03:49Z","html_url":"https://github.com/colszowka/simplecov/pull/570#discussion_r124932321","pull_request_url":"https://api.github.com/repos/colszowka/simplecov/pulls/570","_links":{"self":{"href":"https://api.github.com/repos/colszowka/simplecov/pulls/comments/124932321"},"html":{"href":"https://github.com/colszowka/simplecov/pull/570#discussion_r124932321"},"pull_request":{"href":"https://api.github.com/repos/colszowka/simplecov/pulls/570"}}},"pull_request":{"url":"https://api.github.com/repos/colszowka/simplecov/pulls/570","id":114022031,"html_url":"https://github.com/colszowka/simplecov/pull/570","diff_url":"https://github.com/colszowka/simplecov/pull/570.diff","patch_url":"https://github.com/colszowka/simplecov/pull/570.patch","issue_url":"https://api.github.com/repos/colszowka/simplecov/issues/570","number":570,"state":"open","locked":false,"title":"Fix merging race conditions","user":{"login":"jenseng","id":109489,"avatar_url":"https://avatars2.githubusercontent.com/u/109489?v=3","gravatar_id":"","url":"https://api.github.com/users/jenseng","html_url":"https://github.com/jenseng","followers_url":"https://api.github.com/users/jenseng/followers","following_url":"https://api.github.com/users/jenseng/following{/other_user}","gists_url":"https://api.github.com/users/jenseng/gists{/gist_id}","starred_url":"https://api.github.com/users/jenseng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenseng/subscriptions","organizations_url":"https://api.github.com/users/jenseng/orgs","repos_url":"https://api.github.com/users/jenseng/repos","events_url":"https://api.github.com/users/jenseng/events{/privacy}","received_events_url":"https://api.github.com/users/jenseng/received_events","type":"User","site_admin":false},"body":"Ensure we cache appropriately so we don't merge more than once or do unsafe reads of the resultset.\r\n\r\nSee https://gist.github.com/jenseng/62465f674f8c02de09ef776f23d4dca4 for simple repro script.\r\n\r\nFixes #406 and may partially address #559 (though enforcing covered_percentage still requires workarounds à la [this comment](https://github.com/colszowka/simplecov/issues/559#issuecomment-280805651), since any process before the last one won't have all the coverage data)\r\n\r\nBasically there are 3 main problems when using merging:\r\n\r\n1. `SimpleCov.result` doesn't cache the `@result`, so the default `at_exit` behavior causes it to store and merge 3 times.\r\n2. `SimpleCov::ResultMerger.resultset` calls `.stored_data` twice.\r\n3. `SimpleCov::ResultMerger.merged_result` doesn't synchronize or use a cached `.resultset`, so a concurrent `.store_result` call can cause us to read an empty file.\r\n\r\nThis can cause the formatter to miss out on coverage data in our formatters and/or get the wrong values for covered percentages.\r\n\r\nFurthermore, if you use OJ, `JSON.parse(\"\") -> nil`, which means `.resultset` can be nil, causing exceptions as seen in #406. So I went ahead and rolled that fix into this, since `|| {}` is trivial, and the bug can easily be verified with my repro script above.","created_at":"2017-04-03T21:01:37Z","updated_at":"2017-06-29T23:03:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13e31fb6caca4d9cd3bd2b5f6efe3ed7cac06282","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/colszowka/simplecov/pulls/570/commits","review_comments_url":"https://api.github.com/repos/colszowka/simplecov/pulls/570/comments","review_comment_url":"https://api.github.com/repos/colszowka/simplecov/pulls/comments{/number}","comments_url":"https://api.github.com/repos/colszowka/simplecov/issues/570/comments","statuses_url":"https://api.github.com/repos/colszowka/simplecov/statuses/78c1171e98b7227f6bdd8f76f4c14666fd7fc5ea","head":{"label":"jenseng:fix-result-race-condition","ref":"fix-result-race-condition","sha":"78c1171e98b7227f6bdd8f76f4c14666fd7fc5ea","user":{"login":"jenseng","id":109489,"avatar_url":"https://avatars2.githubusercontent.com/u/109489?v=3","gravatar_id":"","url":"https://api.github.com/users/jenseng","html_url":"https://github.com/jenseng","followers_url":"https://api.github.com/users/jenseng/followers","following_url":"https://api.github.com/users/jenseng/following{/other_user}","gists_url":"https://api.github.com/users/jenseng/gists{/gist_id}","starred_url":"https://api.github.com/users/jenseng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenseng/subscriptions","organizations_url":"https://api.github.com/users/jenseng/orgs","repos_url":"https://api.github.com/users/jenseng/repos","events_url":"https://api.github.com/users/jenseng/events{/privacy}","received_events_url":"https://api.github.com/users/jenseng/received_events","type":"User","site_admin":false},"repo":{"id":86865427,"name":"simplecov","full_name":"jenseng/simplecov","owner":{"login":"jenseng","id":109489,"avatar_url":"https://avatars2.githubusercontent.com/u/109489?v=3","gravatar_id":"","url":"https://api.github.com/users/jenseng","html_url":"https://github.com/jenseng","followers_url":"https://api.github.com/users/jenseng/followers","following_url":"https://api.github.com/users/jenseng/following{/other_user}","gists_url":"https://api.github.com/users/jenseng/gists{/gist_id}","starred_url":"https://api.github.com/users/jenseng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenseng/subscriptions","organizations_url":"https://api.github.com/users/jenseng/orgs","repos_url":"https://api.github.com/users/jenseng/repos","events_url":"https://api.github.com/users/jenseng/events{/privacy}","received_events_url":"https://api.github.com/users/jenseng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jenseng/simplecov","description":"Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites","fork":true,"url":"https://api.github.com/repos/jenseng/simplecov","forks_url":"https://api.github.com/repos/jenseng/simplecov/forks","keys_url":"https://api.github.com/repos/jenseng/simplecov/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenseng/simplecov/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenseng/simplecov/teams","hooks_url":"https://api.github.com/repos/jenseng/simplecov/hooks","issue_events_url":"https://api.github.com/repos/jenseng/simplecov/issues/events{/number}","events_url":"https://api.github.com/repos/jenseng/simplecov/events","assignees_url":"https://api.github.com/repos/jenseng/simplecov/assignees{/user}","branches_url":"https://api.github.com/repos/jenseng/simplecov/branches{/branch}","tags_url":"https://api.github.com/repos/jenseng/simplecov/tags","blobs_url":"https://api.github.com/repos/jenseng/simplecov/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenseng/simplecov/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenseng/simplecov/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenseng/simplecov/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenseng/simplecov/statuses/{sha}","languages_url":"https://api.github.com/repos/jenseng/simplecov/languages","stargazers_url":"https://api.github.com/repos/jenseng/simplecov/stargazers","contributors_url":"https://api.github.com/repos/jenseng/simplecov/contributors","subscribers_url":"https://api.github.com/repos/jenseng/simplecov/subscribers","subscription_url":"https://api.github.com/repos/jenseng/simplecov/subscription","commits_url":"https://api.github.com/repos/jenseng/simplecov/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenseng/simplecov/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenseng/simplecov/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenseng/simplecov/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenseng/simplecov/contents/{+path}","compare_url":"https://api.github.com/repos/jenseng/simplecov/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenseng/simplecov/merges","archive_url":"https://api.github.com/repos/jenseng/simplecov/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenseng/simplecov/downloads","issues_url":"https://api.github.com/repos/jenseng/simplecov/issues{/number}","pulls_url":"https://api.github.com/repos/jenseng/simplecov/pulls{/number}","milestones_url":"https://api.github.com/repos/jenseng/simplecov/milestones{/number}","notifications_url":"https://api.github.com/repos/jenseng/simplecov/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenseng/simplecov/labels{/name}","releases_url":"https://api.github.com/repos/jenseng/simplecov/releases{/id}","deployments_url":"https://api.github.com/repos/jenseng/simplecov/deployments","created_at":"2017-03-31T22:35:42Z","updated_at":"2017-03-31T22:35:44Z","pushed_at":"2017-04-04T16:58:58Z","git_url":"git://github.com/jenseng/simplecov.git","ssh_url":"git@github.com:jenseng/simplecov.git","clone_url":"https://github.com/jenseng/simplecov.git","svn_url":"https://github.com/jenseng/simplecov","homepage":"","size":1915,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"colszowka:master","ref":"master","sha":"d8e41a2cffbd929082a8bc10a0367db249007cd8","user":{"login":"colszowka","id":13972,"avatar_url":"https://avatars2.githubusercontent.com/u/13972?v=3","gravatar_id":"","url":"https://api.github.com/users/colszowka","html_url":"https://github.com/colszowka","followers_url":"https://api.github.com/users/colszowka/followers","following_url":"https://api.github.com/users/colszowka/following{/other_user}","gists_url":"https://api.github.com/users/colszowka/gists{/gist_id}","starred_url":"https://api.github.com/users/colszowka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colszowka/subscriptions","organizations_url":"https://api.github.com/users/colszowka/orgs","repos_url":"https://api.github.com/users/colszowka/repos","events_url":"https://api.github.com/users/colszowka/events{/privacy}","received_events_url":"https://api.github.com/users/colszowka/received_events","type":"User","site_admin":false},"repo":{"id":839336,"name":"simplecov","full_name":"colszowka/simplecov","owner":{"login":"colszowka","id":13972,"avatar_url":"https://avatars2.githubusercontent.com/u/13972?v=3","gravatar_id":"","url":"https://api.github.com/users/colszowka","html_url":"https://github.com/colszowka","followers_url":"https://api.github.com/users/colszowka/followers","following_url":"https://api.github.com/users/colszowka/following{/other_user}","gists_url":"https://api.github.com/users/colszowka/gists{/gist_id}","starred_url":"https://api.github.com/users/colszowka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colszowka/subscriptions","organizations_url":"https://api.github.com/users/colszowka/orgs","repos_url":"https://api.github.com/users/colszowka/repos","events_url":"https://api.github.com/users/colszowka/events{/privacy}","received_events_url":"https://api.github.com/users/colszowka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/colszowka/simplecov","description":"Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites","fork":false,"url":"https://api.github.com/repos/colszowka/simplecov","forks_url":"https://api.github.com/repos/colszowka/simplecov/forks","keys_url":"https://api.github.com/repos/colszowka/simplecov/keys{/key_id}","collaborators_url":"https://api.github.com/repos/colszowka/simplecov/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/colszowka/simplecov/teams","hooks_url":"https://api.github.com/repos/colszowka/simplecov/hooks","issue_events_url":"https://api.github.com/repos/colszowka/simplecov/issues/events{/number}","events_url":"https://api.github.com/repos/colszowka/simplecov/events","assignees_url":"https://api.github.com/repos/colszowka/simplecov/assignees{/user}","branches_url":"https://api.github.com/repos/colszowka/simplecov/branches{/branch}","tags_url":"https://api.github.com/repos/colszowka/simplecov/tags","blobs_url":"https://api.github.com/repos/colszowka/simplecov/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/colszowka/simplecov/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/colszowka/simplecov/git/refs{/sha}","trees_url":"https://api.github.com/repos/colszowka/simplecov/git/trees{/sha}","statuses_url":"https://api.github.com/repos/colszowka/simplecov/statuses/{sha}","languages_url":"https://api.github.com/repos/colszowka/simplecov/languages","stargazers_url":"https://api.github.com/repos/colszowka/simplecov/stargazers","contributors_url":"https://api.github.com/repos/colszowka/simplecov/contributors","subscribers_url":"https://api.github.com/repos/colszowka/simplecov/subscribers","subscription_url":"https://api.github.com/repos/colszowka/simplecov/subscription","commits_url":"https://api.github.com/repos/colszowka/simplecov/commits{/sha}","git_commits_url":"https://api.github.com/repos/colszowka/simplecov/git/commits{/sha}","comments_url":"https://api.github.com/repos/colszowka/simplecov/comments{/number}","issue_comment_url":"https://api.github.com/repos/colszowka/simplecov/issues/comments{/number}","contents_url":"https://api.github.com/repos/colszowka/simplecov/contents/{+path}","compare_url":"https://api.github.com/repos/colszowka/simplecov/compare/{base}...{head}","merges_url":"https://api.github.com/repos/colszowka/simplecov/merges","archive_url":"https://api.github.com/repos/colszowka/simplecov/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/colszowka/simplecov/downloads","issues_url":"https://api.github.com/repos/colszowka/simplecov/issues{/number}","pulls_url":"https://api.github.com/repos/colszowka/simplecov/pulls{/number}","milestones_url":"https://api.github.com/repos/colszowka/simplecov/milestones{/number}","notifications_url":"https://api.github.com/repos/colszowka/simplecov/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/colszowka/simplecov/labels{/name}","releases_url":"https://api.github.com/repos/colszowka/simplecov/releases{/id}","deployments_url":"https://api.github.com/repos/colszowka/simplecov/deployments","created_at":"2010-08-15T15:28:56Z","updated_at":"2017-06-29T17:01:18Z","pushed_at":"2017-06-28T10:07:56Z","git_url":"git://github.com/colszowka/simplecov.git","ssh_url":"git@github.com:colszowka/simplecov.git","clone_url":"https://github.com/colszowka/simplecov.git","svn_url":"https://github.com/colszowka/simplecov","homepage":"","size":1979,"stargazers_count":3042,"watchers_count":3042,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":324,"mirror_url":null,"open_issues_count":47,"forks":324,"open_issues":47,"watchers":3042,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/colszowka/simplecov/pulls/570"},"html":{"href":"https://github.com/colszowka/simplecov/pull/570"},"issue":{"href":"https://api.github.com/repos/colszowka/simplecov/issues/570"},"comments":{"href":"https://api.github.com/repos/colszowka/simplecov/issues/570/comments"},"review_comments":{"href":"https://api.github.com/repos/colszowka/simplecov/pulls/570/comments"},"review_comment":{"href":"https://api.github.com/repos/colszowka/simplecov/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/colszowka/simplecov/pulls/570/commits"},"statuses":{"href":"https://api.github.com/repos/colszowka/simplecov/statuses/78c1171e98b7227f6bdd8f76f4c14666fd7fc5ea"}}}}
{"actor":{"display_login":"jenseng"}}