{"action":"created","comment":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/74069906","id":74069906,"diff_hunk":"@@ -10,17 +10,109 @@\n # See LICENSE for more details.\n #\n # Copyright: Red Hat Inc. 2014\n-# Author: Ruda Moura <rmoura@redhat.com>\n+# Authors: Ruda Moura <rmoura@redhat.com>\n+#          Cleber Rosa <crosa@redhat.com>\n \n \"\"\"xUnit module.\"\"\"\n \n+import datetime\n+import logging\n+import os\n+import string\n+from xml.dom.minidom import Document, Element\n+\n from avocado.core.parser import FileOrStdoutAction\n-from avocado.core.plugin_interfaces import CLI\n-from avocado.core.result import register_test_result_class\n-from avocado.core.xunit import xUnitResult\n+from avocado.core.plugin_interfaces import CLI, Result\n+\n+\n+class XUnitResult(Result):\n+\n+    UNKNOWN = '<unknown>'\n+    PRINTABLE = string.ascii_letters + string.digits + string.punctuation + '\\n\\r '\n+\n+    def _escape_attr(self, attrib):\n+        attrib = ''.join(_ if _ in self.PRINTABLE else \"\\\\x%02x\" % ord(_)\n+                         for _ in str(attrib))\n+        return attrib\n+\n+    def _escape_cdata(self, cdata):\n+        cdata = ''.join(_ if _ in self.PRINTABLE else \"\\\\x%02x\" % ord(_)\n+                        for _ in str(cdata))\n+        return cdata.replace(']]>', ']]>]]&gt;<![CDATA[')\n+\n+    def _get_attr(self, container, attrib):\n+        return self._escape_attr(container.get(attrib, self.UNKNOWN))\n+\n+    def _create_testcase_element(self, document, state):\n+        testcase = document.createElement('testcase')\n+        testcase.setAttribute('classname', self._get_attr(state, 'class_name'))\n+        testcase.setAttribute('name', self._get_attr(state, 'name'))\n+        testcase.setAttribute('time', self._get_attr(state, 'time_elapsed'))\n+        return testcase\n \n+    def _create_failure_or_error(self, document, test, element_type):\n+        element = Element(element_type)\n+        element.setAttribute('type', self._get_attr(test, 'fail_class'))\n+        element.setAttribute('message', self._get_attr(test, 'fail_reason'))\n+        traceback_content = self._escape_cdata(test.get('traceback', self.UNKNOWN))\n+        traceback = document.createCDATASection(traceback_content)\n+        element.appendChild(traceback)\n+        system_out = Element('system-out')\n+        system_out_cdata_content = self._escape_cdata(test.get('text_output', self.UNKNOWN))\n+        system_out_cdata = document.createCDATASection(system_out_cdata_content)\n+        system_out.appendChild(system_out_cdata)\n+        element.appendChild(system_out)\n+        return element\n \n-class XUnit(CLI):\n+    def _render(self, result):\n+        document = Document()\n+        testsuite = document.createElement('testsuite')\n+        testsuite.setAttribute('name', 'avocado')\n+        testsuite.setAttribute('tests', self._escape_attr(result.tests_total))\n+        testsuite.setAttribute('errors', self._escape_attr(result.errors + result.interrupted))\n+        testsuite.setAttribute('failures', self._escape_attr(result.failed))\n+        testsuite.setAttribute('skipped', self._escape_attr(result.skipped))\n+        testsuite.setAttribute('time', self._escape_attr(result.tests_total_time))\n+        testsuite.setAttribute('timestamp', self._escape_attr(datetime.datetime.now()))\n+        document.appendChild(testsuite)\n+        for test in result.tests:\n+            testcase = self._create_testcase_element(document, test)\n+            status = test.get('status', 'ERROR')\n+            if status in ('PASS', 'WARN'):\n+                pass\n+            elif status == 'SKIP':\n+                testcase.appendChild(Element('skipped'))\n+            elif status == 'FAIL':\n+                element = self._create_failure_or_error(document, test, 'failure')\n+                testcase.appendChild(element)\n+            else:\n+                element = self._create_failure_or_error(document, test, 'error')\n+                testcase.appendChild(element)\n+            testsuite.appendChild(testcase)\n+        return document.toxml(encoding='UTF-8')","path":"avocado/plugins/xunit.py","position":88,"original_position":88,"commit_id":"5c88b7abdcfdd6e138e0b6b41c8a51a004b51fed","original_commit_id":"43349c112b76aef43be61583455be99d564fb150","user":{"login":"ldoktor","id":1074021,"avatar_url":"https://avatars.githubusercontent.com/u/1074021?v=3","gravatar_id":"","url":"https://api.github.com/users/ldoktor","html_url":"https://github.com/ldoktor","followers_url":"https://api.github.com/users/ldoktor/followers","following_url":"https://api.github.com/users/ldoktor/following{/other_user}","gists_url":"https://api.github.com/users/ldoktor/gists{/gist_id}","starred_url":"https://api.github.com/users/ldoktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldoktor/subscriptions","organizations_url":"https://api.github.com/users/ldoktor/orgs","repos_url":"https://api.github.com/users/ldoktor/repos","events_url":"https://api.github.com/users/ldoktor/events{/privacy}","received_events_url":"https://api.github.com/users/ldoktor/received_events","type":"User","site_admin":false},"body":"https://github.com/avocado-framework/avocado/pull/1361","created_at":"2016-08-09T14:33:24Z","updated_at":"2016-08-09T14:33:24Z","html_url":"https://github.com/avocado-framework/avocado/pull/1352#discussion_r74069906","pull_request_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352","_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/74069906"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/1352#discussion_r74069906"},"pull_request":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352"}}},"pull_request":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352","id":79951678,"html_url":"https://github.com/avocado-framework/avocado/pull/1352","diff_url":"https://github.com/avocado-framework/avocado/pull/1352.diff","patch_url":"https://github.com/avocado-framework/avocado/pull/1352.patch","issue_url":"https://api.github.com/repos/avocado-framework/avocado/issues/1352","number":1352,"state":"closed","locked":false,"title":"Result: make them real plugins [v1]","user":{"login":"clebergnu","id":447178,"avatar_url":"https://avatars.githubusercontent.com/u/447178?v=3","gravatar_id":"","url":"https://api.github.com/users/clebergnu","html_url":"https://github.com/clebergnu","followers_url":"https://api.github.com/users/clebergnu/followers","following_url":"https://api.github.com/users/clebergnu/following{/other_user}","gists_url":"https://api.github.com/users/clebergnu/gists{/gist_id}","starred_url":"https://api.github.com/users/clebergnu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clebergnu/subscriptions","organizations_url":"https://api.github.com/users/clebergnu/orgs","repos_url":"https://api.github.com/users/clebergnu/repos","events_url":"https://api.github.com/users/clebergnu/events{/privacy}","received_events_url":"https://api.github.com/users/clebergnu/received_events","type":"User","site_admin":false},"body":"This work moves the result generation out of the job context, and while doing that, making them real plugins.  It's currently limited to the result writers that can render the complete result at once, based on the full job outcome.\r\n\r\nThe same work for \"streamable\" results, say the Human \"result\", will come next.\r\n\r\n--\r\n\r\nChanges from v0 (#1337):\r\n * Added documentation\r\n * Better commit messages\r\n * Removed `command_line_arg_name` attribute from `avocado.core.result.Result`","created_at":"2016-08-03T18:05:26Z","updated_at":"2016-08-09T14:33:24Z","closed_at":"2016-08-09T14:29:21Z","merged_at":"2016-08-09T14:29:21Z","merge_commit_sha":"5c88b7abdcfdd6e138e0b6b41c8a51a004b51fed","assignee":{"login":"ldoktor","id":1074021,"avatar_url":"https://avatars.githubusercontent.com/u/1074021?v=3","gravatar_id":"","url":"https://api.github.com/users/ldoktor","html_url":"https://github.com/ldoktor","followers_url":"https://api.github.com/users/ldoktor/followers","following_url":"https://api.github.com/users/ldoktor/following{/other_user}","gists_url":"https://api.github.com/users/ldoktor/gists{/gist_id}","starred_url":"https://api.github.com/users/ldoktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldoktor/subscriptions","organizations_url":"https://api.github.com/users/ldoktor/orgs","repos_url":"https://api.github.com/users/ldoktor/repos","events_url":"https://api.github.com/users/ldoktor/events{/privacy}","received_events_url":"https://api.github.com/users/ldoktor/received_events","type":"User","site_admin":false},"assignees":[{"login":"ldoktor","id":1074021,"avatar_url":"https://avatars.githubusercontent.com/u/1074021?v=3","gravatar_id":"","url":"https://api.github.com/users/ldoktor","html_url":"https://github.com/ldoktor","followers_url":"https://api.github.com/users/ldoktor/followers","following_url":"https://api.github.com/users/ldoktor/following{/other_user}","gists_url":"https://api.github.com/users/ldoktor/gists{/gist_id}","starred_url":"https://api.github.com/users/ldoktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldoktor/subscriptions","organizations_url":"https://api.github.com/users/ldoktor/orgs","repos_url":"https://api.github.com/users/ldoktor/repos","events_url":"https://api.github.com/users/ldoktor/events{/privacy}","received_events_url":"https://api.github.com/users/ldoktor/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352/commits","review_comments_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352/comments","review_comment_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/issues/1352/comments","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/5c88b7abdcfdd6e138e0b6b41c8a51a004b51fed","head":{"label":"clebergnu:result_v1","ref":"result_v1","sha":"5c88b7abdcfdd6e138e0b6b41c8a51a004b51fed","user":{"login":"clebergnu","id":447178,"avatar_url":"https://avatars.githubusercontent.com/u/447178?v=3","gravatar_id":"","url":"https://api.github.com/users/clebergnu","html_url":"https://github.com/clebergnu","followers_url":"https://api.github.com/users/clebergnu/followers","following_url":"https://api.github.com/users/clebergnu/following{/other_user}","gists_url":"https://api.github.com/users/clebergnu/gists{/gist_id}","starred_url":"https://api.github.com/users/clebergnu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clebergnu/subscriptions","organizations_url":"https://api.github.com/users/clebergnu/orgs","repos_url":"https://api.github.com/users/clebergnu/repos","events_url":"https://api.github.com/users/clebergnu/events{/privacy}","received_events_url":"https://api.github.com/users/clebergnu/received_events","type":"User","site_admin":false},"repo":{"id":17944017,"name":"avocado","full_name":"clebergnu/avocado","owner":{"login":"clebergnu","id":447178,"avatar_url":"https://avatars.githubusercontent.com/u/447178?v=3","gravatar_id":"","url":"https://api.github.com/users/clebergnu","html_url":"https://github.com/clebergnu","followers_url":"https://api.github.com/users/clebergnu/followers","following_url":"https://api.github.com/users/clebergnu/following{/other_user}","gists_url":"https://api.github.com/users/clebergnu/gists{/gist_id}","starred_url":"https://api.github.com/users/clebergnu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clebergnu/subscriptions","organizations_url":"https://api.github.com/users/clebergnu/orgs","repos_url":"https://api.github.com/users/clebergnu/repos","events_url":"https://api.github.com/users/clebergnu/events{/privacy}","received_events_url":"https://api.github.com/users/clebergnu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/clebergnu/avocado","description":"Avocado Test Runner","fork":true,"url":"https://api.github.com/repos/clebergnu/avocado","forks_url":"https://api.github.com/repos/clebergnu/avocado/forks","keys_url":"https://api.github.com/repos/clebergnu/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clebergnu/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clebergnu/avocado/teams","hooks_url":"https://api.github.com/repos/clebergnu/avocado/hooks","issue_events_url":"https://api.github.com/repos/clebergnu/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/clebergnu/avocado/events","assignees_url":"https://api.github.com/repos/clebergnu/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/clebergnu/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/clebergnu/avocado/tags","blobs_url":"https://api.github.com/repos/clebergnu/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clebergnu/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clebergnu/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/clebergnu/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clebergnu/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/clebergnu/avocado/languages","stargazers_url":"https://api.github.com/repos/clebergnu/avocado/stargazers","contributors_url":"https://api.github.com/repos/clebergnu/avocado/contributors","subscribers_url":"https://api.github.com/repos/clebergnu/avocado/subscribers","subscription_url":"https://api.github.com/repos/clebergnu/avocado/subscription","commits_url":"https://api.github.com/repos/clebergnu/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/clebergnu/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/clebergnu/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/clebergnu/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/clebergnu/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/clebergnu/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clebergnu/avocado/merges","archive_url":"https://api.github.com/repos/clebergnu/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clebergnu/avocado/downloads","issues_url":"https://api.github.com/repos/clebergnu/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/clebergnu/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/clebergnu/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/clebergnu/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clebergnu/avocado/labels{/name}","releases_url":"https://api.github.com/repos/clebergnu/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/clebergnu/avocado/deployments","created_at":"2014-03-20T13:42:05Z","updated_at":"2014-05-02T20:36:30Z","pushed_at":"2016-08-08T18:52:23Z","git_url":"git://github.com/clebergnu/avocado.git","ssh_url":"git@github.com:clebergnu/avocado.git","clone_url":"https://github.com/clebergnu/avocado.git","svn_url":"https://github.com/clebergnu/avocado","homepage":"","size":8844,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"avocado-framework:master","ref":"master","sha":"b0cf1a57bb5eb225481553d8bcf9eb191a0c7beb","user":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":17449498,"name":"avocado","full_name":"avocado-framework/avocado","owner":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avocado-framework/avocado","description":"Avocado Test Framework","fork":false,"url":"https://api.github.com/repos/avocado-framework/avocado","forks_url":"https://api.github.com/repos/avocado-framework/avocado/forks","keys_url":"https://api.github.com/repos/avocado-framework/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avocado-framework/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avocado-framework/avocado/teams","hooks_url":"https://api.github.com/repos/avocado-framework/avocado/hooks","issue_events_url":"https://api.github.com/repos/avocado-framework/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/avocado-framework/avocado/events","assignees_url":"https://api.github.com/repos/avocado-framework/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/avocado-framework/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/avocado-framework/avocado/tags","blobs_url":"https://api.github.com/repos/avocado-framework/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avocado-framework/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avocado-framework/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/avocado-framework/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/avocado-framework/avocado/languages","stargazers_url":"https://api.github.com/repos/avocado-framework/avocado/stargazers","contributors_url":"https://api.github.com/repos/avocado-framework/avocado/contributors","subscribers_url":"https://api.github.com/repos/avocado-framework/avocado/subscribers","subscription_url":"https://api.github.com/repos/avocado-framework/avocado/subscription","commits_url":"https://api.github.com/repos/avocado-framework/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/avocado-framework/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/avocado-framework/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/avocado-framework/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/avocado-framework/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avocado-framework/avocado/merges","archive_url":"https://api.github.com/repos/avocado-framework/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avocado-framework/avocado/downloads","issues_url":"https://api.github.com/repos/avocado-framework/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/avocado-framework/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/avocado-framework/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/avocado-framework/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avocado-framework/avocado/labels{/name}","releases_url":"https://api.github.com/repos/avocado-framework/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/avocado-framework/avocado/deployments","created_at":"2014-03-05T17:52:27Z","updated_at":"2016-08-03T08:05:05Z","pushed_at":"2016-08-09T14:33:17Z","git_url":"git://github.com/avocado-framework/avocado.git","ssh_url":"git@github.com:avocado-framework/avocado.git","clone_url":"https://github.com/avocado-framework/avocado.git","svn_url":"https://github.com/avocado-framework/avocado","homepage":"http://avocado-framework.github.io/","size":14336,"stargazers_count":51,"watchers_count":51,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":6,"forks":62,"open_issues":6,"watchers":51,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/1352"},"issue":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/1352"},"comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/1352/comments"},"review_comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352/comments"},"review_comment":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/1352/commits"},"statuses":{"href":"https://api.github.com/repos/avocado-framework/avocado/statuses/5c88b7abdcfdd6e138e0b6b41c8a51a004b51fed"}}}}
{"actor":{"display_login":"ldoktor"}}