提交 d396ccd5 编写于 作者: C Cleber Rosa

Plugins: port xunit plugin

Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 25f78213
......@@ -40,9 +40,9 @@ from . import output
from . import multiplexer
from . import tree
from . import test
from . import xunit
from .settings import settings
from .plugins import jsonresult
from .plugins import xunit
from ..utils import archive
from ..utils import astring
from ..utils import path
......
......@@ -17,9 +17,8 @@
import datetime
from xml.sax.saxutils import quoteattr
from . import plugin
from .. import output
from ..result import TestResult
from . import output
from .result import TestResult
# We use a subset of the XML format defined in this URL:
......@@ -214,28 +213,3 @@ class xUnitTestResult(TestResult):
else:
with open(self.output, 'w') as xunit_output:
xunit_output.write(contents)
class XUnit(plugin.Plugin):
"""
xUnit output
"""
name = 'xunit'
enabled = True
def configure(self, parser):
self.parser = parser
self.parser.runner.output.add_argument(
'--xunit', type=str, dest='xunit_output', metavar='FILE',
help=('Enable xUnit result format and write it to FILE. '
"Use '-' to redirect to the standard output."))
self.configured = True
def activate(self, app_args):
try:
if app_args.xunit_output:
self.parser.application.set_defaults(xunit_result=xUnitTestResult)
except AttributeError:
pass
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2014
# Author: Ruda Moura <rmoura@redhat.com>
"""xUnit module."""
from avocado.core.xunit import xUnitTestResult
from .base import CLI
class XUnit(CLI):
"""
xUnit output
"""
name = 'xunit'
description = 'xUnit output options'
def configure(self, parser):
run_subcommand_parser = parser.subcommands.choices.get('run', None)
if run_subcommand_parser is None:
return
self.parser = parser
run_subcommand_parser.output.add_argument(
'--xunit', type=str, dest='xunit_output', metavar='FILE',
help=('Enable xUnit result format and write it to FILE. '
"Use '-' to redirect to the standard output."))
def run(self, args):
if 'xunit_output' in args and args.xunit_output is not None:
args.xunit_result = xUnitTestResult
......@@ -103,7 +103,6 @@ class RunnerOperationTest(unittest.TestCase):
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" % (expected_rc, result))
@unittest.skip("Temporary plugin infrastructure removal")
def test_runner_doublefail(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --sysinfo=off --job-results-dir %s --xunit - doublefail' % self.tmpdir
......@@ -145,7 +144,6 @@ class RunnerOperationTest(unittest.TestCase):
result))
self.assertIn('"status": "FAIL"', result.stdout)
@unittest.skip("Temporary plugin infrastructure removal")
def test_runner_timeout(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --sysinfo=off --job-results-dir %s --xunit - timeouttest' % self.tmpdir
......@@ -162,7 +160,6 @@ class RunnerOperationTest(unittest.TestCase):
# Ensure no test aborted error messages show up
self.assertNotIn("TestAbortedError: Test aborted unexpectedly", output)
@unittest.skip("Temporary plugin infrastructure removal")
def test_runner_abort(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --sysinfo=off --job-results-dir %s --xunit - abort' % self.tmpdir
......@@ -669,22 +666,18 @@ class PluginsXunitTest(AbsPluginsTest, unittest.TestCase):
"Unexpected number of test skips, "
"XML:\n%s" % xml_output)
@unittest.skip("Temporary plugin infrastructure removal")
def test_xunit_plugin_passtest(self):
self.run_and_check('passtest', exit_codes.AVOCADO_ALL_OK,
1, 0, 0, 0, 0)
@unittest.skip("Temporary plugin infrastructure removal")
def test_xunit_plugin_failtest(self):
self.run_and_check('failtest', exit_codes.AVOCADO_TESTS_FAIL,
1, 0, 0, 1, 0)
@unittest.skip("Temporary plugin infrastructure removal")
def test_xunit_plugin_skiponsetuptest(self):
self.run_and_check('skiponsetup', exit_codes.AVOCADO_ALL_OK,
1, 0, 0, 0, 1)
@unittest.skip("Temporary plugin infrastructure removal")
def test_xunit_plugin_errortest(self):
self.run_and_check('errortest', exit_codes.AVOCADO_TESTS_FAIL,
1, 1, 0, 0, 0)
......
......@@ -98,21 +98,18 @@ class JobTimeOutTest(unittest.TestCase):
"Unexpected number of test skips, "
"XML:\n%s" % xml_output)
@unittest.skip("Temporary plugin infrastructure removal")
def test_sleep_longer_timeout(self):
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off '
'--xunit - --job-timeout=5 %s examples/tests/passtest.py' %
(self.tmpdir, self.script.path))
self.run_and_check(cmd_line, 0, 2, 0, 0, 0)
@unittest.skip("Temporary plugin infrastructure removal")
def test_sleep_short_timeout(self):
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off '
'--xunit - --job-timeout=1 %s examples/tests/passtest.py' %
(self.tmpdir, self.script.path))
self.run_and_check(cmd_line, exit_codes.AVOCADO_TESTS_FAIL, 2, 1, 0, 1)
@unittest.skip("Temporary plugin infrastructure removal")
def test_sleep_short_timeout_with_test_methods(self):
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off '
'--xunit - --job-timeout=1 %s' %
......
......@@ -84,7 +84,6 @@ class RunnerSimpleTest(unittest.TestCase):
"Avocado did not return rc %d:\n%s" %
(expected_rc, result))
@unittest.skip("Temporary plugin infrastructure removal")
def test_output_tamper_stdout(self):
self.test_output_record_all()
tampered_msg = "I PITY THE FOOL THAT STANDS ON MY WAY!"
......@@ -100,7 +99,6 @@ class RunnerSimpleTest(unittest.TestCase):
(expected_rc, result))
self.assertIn(tampered_msg, result.stdout)
@unittest.skip("Temporary plugin infrastructure removal")
def test_disable_output_check(self):
self.test_output_record_all()
tampered_msg = "I PITY THE FOOL THAT STANDS ON MY WAY!"
......
......@@ -6,7 +6,7 @@ import tempfile
import shutil
from avocado import Test
from avocado.core.plugins import xunit
from avocado.core import xunit
from avocado.core import job
......
......@@ -129,6 +129,7 @@ if __name__ == '__main__':
'avocado.plugins.cli': [
'gdb = avocado.plugins.gdb:GDB',
'wrapper = avocado.plugins.wrapper:Wrapper',
'xunit = avocado.plugins.xunit:XUnit',
],
'avocado.plugins.cli.cmd': [
'config = avocado.plugins.config:Config',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册