{"action":"created","comment":{"url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/comments/53907335","id":53907335,"diff_hunk":"@@ -0,0 +1,87 @@\n+'use strict';\n+\n+var AllureSuite = require('allure-js-commons').Suite,\n+    AllureTest = require('allure-js-commons').Test,\n+    writer = require('allure-js-commons').writer,\n+    mochaUtils = require('./lib/mochaUtils'),\n+    SuiteHolder = require('./lib/suite-holder'),\n+    ALLURE_STATUS = {\n+        passed: 'passed',\n+        failed: 'failed',\n+        pending: 'pending',\n+        broken: 'broken'\n+    },\n+    _suiteHolder,\n+    targetDir;\n+\n+module.exports = function(hermione, opts) {\n+    _suiteHolder = new SuiteHolder();\n+    targetDir = opts.targetDir;\n+    hermione.on(hermione.events.SUITE_BEGIN, _onSuiteBegin);\n+    hermione.on(hermione.events.SUITE_END, _onSuiteEnd);\n+    hermione.on(hermione.events.TEST_BEGIN, _onTestBegin);\n+    hermione.on(hermione.events.TEST_PASS, _onTestPass);\n+    hermione.on(hermione.events.TEST_FAIL, _onTestFail);\n+    hermione.on(hermione.events.TEST_PENDING, _onTestPending);\n+    hermione.on(hermione.events.ERROR, _onError);\n+};\n+\n+function _onSuiteBegin(suite) {\n+    if (!mochaUtils.isTopSuite(suite)) {\n+        return;\n+    }\n+\n+    if (!_suiteHolder.getSuiteEntry(suite.title, suite.browserId)) {\n+        _suiteHolder.addSuiteEntry(new AllureSuite(suite.title), suite.browserId);\n+    }\n+}\n+\n+function _onSuiteEnd(suite) {\n+    if (!mochaUtils.isTopSuite(suite)) {\n+        return;\n+    }\n+    var suiteEntry = _suiteHolder.getSuiteEntry(suite.title, suite.browserId);\n+    if (suiteEntry) {\n+        suiteEntry.allureSuite.end();\n+        suiteEntry.allureSuite.write(writer, targetDir);\n+        _suiteHolder.removeSuiteEntry(suite.title, suite.browserId);\n+    }\n+}\n+\n+function _onTestBegin(test) {\n+    _suiteHolder.removeTest(test);\n+    _suiteHolder.startTest(test);\n+}\n+\n+function _onTestPass(test) {\n+    _suiteHolder.finishTest(test, ALLURE_STATUS.passed);\n+}\n+\n+function _onTestFail(test) {\n+    _suiteHolder.finishTest(test, ALLURE_STATUS.failed, test.err);\n+}\n+\n+function _onTestPending(test) {\n+    var suiteEntry = _suiteHolder.getSuiteEntry(mochaUtils.getTopSuite(test).title, test.browserId),\n+        pendingTest = new AllureTest(mochaUtils.cutTopSuiteTitle(test));\n+    pendingTest.end(ALLURE_STATUS.pending, {message: 'Test ignored'});\n+    suiteEntry.allureSuite.addTest(pendingTest);\n+}\n+\n+function _onError(err, data) {\n+    if (data) {\n+        if (mochaUtils.isBeforeHook(data)) {","path":"index.js","position":73,"original_position":73,"commit_id":"75416757773b115df0f834c2deb429c63ff4738a","original_commit_id":"75416757773b115df0f834c2deb429c63ff4738a","user":{"login":"j0tunn","id":7701229,"avatar_url":"https://avatars.githubusercontent.com/u/7701229?v=3","gravatar_id":"","url":"https://api.github.com/users/j0tunn","html_url":"https://github.com/j0tunn","followers_url":"https://api.github.com/users/j0tunn/followers","following_url":"https://api.github.com/users/j0tunn/following{/other_user}","gists_url":"https://api.github.com/users/j0tunn/gists{/gist_id}","starred_url":"https://api.github.com/users/j0tunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0tunn/subscriptions","organizations_url":"https://api.github.com/users/j0tunn/orgs","repos_url":"https://api.github.com/users/j0tunn/repos","events_url":"https://api.github.com/users/j0tunn/events{/privacy}","received_events_url":"https://api.github.com/users/j0tunn/received_events","type":"User","site_admin":false},"body":"инвертируй условия, будет меньше вложенность","created_at":"2016-02-24T08:30:57Z","updated_at":"2016-02-24T08:30:57Z","html_url":"https://github.com/gemini-testing/hermione-allure-reporter/pull/1#discussion_r53907335","pull_request_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/comments/53907335"},"html":{"href":"https://github.com/gemini-testing/hermione-allure-reporter/pull/1#discussion_r53907335"},"pull_request":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1","id":59961260,"html_url":"https://github.com/gemini-testing/hermione-allure-reporter/pull/1","diff_url":"https://github.com/gemini-testing/hermione-allure-reporter/pull/1.diff","patch_url":"https://github.com/gemini-testing/hermione-allure-reporter/pull/1.patch","issue_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/1","number":1,"state":"open","locked":false,"title":"First version","user":{"login":"pazone","id":3244018,"avatar_url":"https://avatars.githubusercontent.com/u/3244018?v=3","gravatar_id":"","url":"https://api.github.com/users/pazone","html_url":"https://github.com/pazone","followers_url":"https://api.github.com/users/pazone/followers","following_url":"https://api.github.com/users/pazone/following{/other_user}","gists_url":"https://api.github.com/users/pazone/gists{/gist_id}","starred_url":"https://api.github.com/users/pazone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pazone/subscriptions","organizations_url":"https://api.github.com/users/pazone/orgs","repos_url":"https://api.github.com/users/pazone/repos","events_url":"https://api.github.com/users/pazone/events{/privacy}","received_events_url":"https://api.github.com/users/pazone/received_events","type":"User","site_admin":false},"body":"Особенности работы:\r\n`SuiteHolder` - хелпер для асоциирования тестов и съютов в рантайме. Содержит набор запущенных на данный момент сьютов, ассоциированных с тестами.\r\n`SuiteEntry` -  Один запущенный съют, к которому в процессе его работы асоциируются тесты.\r\n\r\n- На каждый верхний describe создается объкт `AllureSuite` и записывается в `SuiteHolder`.\r\n- При завершении сьюта AllureSuite сериализуется в файл, который будет лежать в `targetDir`. После сериализации соответствующая `SuiteEntry` удаляется\r\n- Когда стартует тест, ищестся его сьют, учитывая браузер и он с ним ассоциируется в `suiteHolder`. \r\n- в случае ошибки beforeHook, `ERROR` генерируется до `SUITE_START`. По хуку, в котором произошла ошибка, вычисляем сьюты, на которые он влияет, создаем их, помечаем все их тесты статусом `broken` и сразу записываем сьют.\r\n- при ретраях `SUITE_BEGIN` генерируется повторно. Если это случилось повторно, находим созданный ранее `suiteEntry` и заменяем в нем старый тест на новый, чтобы обновить время старта.\r\n- Дерево mocha-тестов \"выпрямляется\". Внутрениие describe склеиваются с именем кейса.\r\n\r\n@sipayRT @j0tunn \r\n","created_at":"2016-02-19T15:10:10Z","updated_at":"2016-02-24T08:30:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b03c5a17c9694b742d6752c3c0ad29018beeb28","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1/commits","review_comments_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1/comments","review_comment_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/1/comments","statuses_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/statuses/75416757773b115df0f834c2deb429c63ff4738a","head":{"label":"gemini-testing:init_version","ref":"init_version","sha":"75416757773b115df0f834c2deb429c63ff4738a","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":52087613,"name":"hermione-allure-reporter","full_name":"gemini-testing/hermione-allure-reporter","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/hermione-allure-reporter","description":"","fork":false,"url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter","forks_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/forks","keys_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/teams","hooks_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/events","assignees_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/tags","blobs_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/subscription","commits_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/merges","archive_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/downloads","issues_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/releases{/id}","deployments_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/deployments","created_at":"2016-02-19T12:55:45Z","updated_at":"2016-02-19T12:55:45Z","pushed_at":"2016-02-19T15:31:37Z","git_url":"git://github.com/gemini-testing/hermione-allure-reporter.git","ssh_url":"git@github.com:gemini-testing/hermione-allure-reporter.git","clone_url":"https://github.com/gemini-testing/hermione-allure-reporter.git","svn_url":"https://github.com/gemini-testing/hermione-allure-reporter","homepage":null,"size":7,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"gemini-testing:master","ref":"master","sha":"706b15f485cf0e9b41612c7c68c148de554f3bb8","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":52087613,"name":"hermione-allure-reporter","full_name":"gemini-testing/hermione-allure-reporter","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/hermione-allure-reporter","description":"","fork":false,"url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter","forks_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/forks","keys_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/teams","hooks_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/events","assignees_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/tags","blobs_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/subscription","commits_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/merges","archive_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/downloads","issues_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/releases{/id}","deployments_url":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/deployments","created_at":"2016-02-19T12:55:45Z","updated_at":"2016-02-19T12:55:45Z","pushed_at":"2016-02-19T15:31:37Z","git_url":"git://github.com/gemini-testing/hermione-allure-reporter.git","ssh_url":"git@github.com:gemini-testing/hermione-allure-reporter.git","clone_url":"https://github.com/gemini-testing/hermione-allure-reporter.git","svn_url":"https://github.com/gemini-testing/hermione-allure-reporter","homepage":null,"size":7,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1"},"html":{"href":"https://github.com/gemini-testing/hermione-allure-reporter/pull/1"},"issue":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/1"},"comments":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/gemini-testing/hermione-allure-reporter/statuses/75416757773b115df0f834c2deb429c63ff4738a"}}}}