mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
uitests: Wire up --coverage
Need to launch the external coverage process to actually measure things
This commit is contained in:
parent
b4a2c46f6a
commit
4b4f532417
17
setup.py
17
setup.py
@ -390,6 +390,7 @@ class TestBaseCommand(distutils.core.Command):
|
|||||||
self._dir = os.getcwd()
|
self._dir = os.getcwd()
|
||||||
self.testfile = None
|
self.testfile = None
|
||||||
self._force_verbose = False
|
self._force_verbose = False
|
||||||
|
self._external_coverage = False
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
if self.debug and "DEBUG_TESTS" not in os.environ:
|
if self.debug and "DEBUG_TESTS" not in os.environ:
|
||||||
@ -423,16 +424,16 @@ class TestBaseCommand(distutils.core.Command):
|
|||||||
cov = None
|
cov = None
|
||||||
if self.coverage:
|
if self.coverage:
|
||||||
import coverage
|
import coverage
|
||||||
# The latter is required to not give errors on f23, probably
|
omit = ["/usr/*", "/*/tests/*"]
|
||||||
# a temporary bug.
|
|
||||||
omit = ["/usr/*", "/*/tests/*", "/builddir/*"]
|
|
||||||
cov = coverage.coverage(omit=omit)
|
cov = coverage.coverage(omit=omit)
|
||||||
cov.erase()
|
cov.erase()
|
||||||
cov.start()
|
if not self._external_coverage:
|
||||||
|
cov.start()
|
||||||
|
|
||||||
import tests as testsmodule
|
import tests as testsmodule
|
||||||
testsmodule.utils.clistate.regenerate_output = bool(
|
testsmodule.utils.clistate.regenerate_output = bool(
|
||||||
self.regenerate_output)
|
self.regenerate_output)
|
||||||
|
testsmodule.utils.clistate.use_coverage = bool(cov)
|
||||||
|
|
||||||
# This makes the test runner report results before exiting from ctrl-c
|
# This makes the test runner report results before exiting from ctrl-c
|
||||||
unittest.installHandler()
|
unittest.installHandler()
|
||||||
@ -466,8 +467,11 @@ class TestBaseCommand(distutils.core.Command):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if cov:
|
if cov:
|
||||||
cov.stop()
|
if self._external_coverage:
|
||||||
cov.save()
|
cov.load()
|
||||||
|
else:
|
||||||
|
cov.stop()
|
||||||
|
cov.save()
|
||||||
|
|
||||||
err = int(bool(len(result.failures) > 0 or
|
err = int(bool(len(result.failures) > 0 or
|
||||||
len(result.errors) > 0))
|
len(result.errors) > 0))
|
||||||
@ -516,6 +520,7 @@ class TestUI(TestBaseCommand):
|
|||||||
def run(self):
|
def run(self):
|
||||||
self._testfiles = self._find_tests_in_dir("tests/uitests", [])
|
self._testfiles = self._find_tests_in_dir("tests/uitests", [])
|
||||||
self._force_verbose = True
|
self._force_verbose = True
|
||||||
|
self._external_coverage = True
|
||||||
TestBaseCommand.run(self)
|
TestBaseCommand.run(self)
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ class NewVM(uiutils.UITestCase):
|
|||||||
###################
|
###################
|
||||||
|
|
||||||
def _open_create_wizard(self):
|
def _open_create_wizard(self):
|
||||||
conn_label = "test testdriver.xml"
|
|
||||||
uiutils.find_pattern(self.app.root, conn_label, "table cell")
|
|
||||||
b = uiutils.find_pattern(self.app.root, "New", "push button",
|
b = uiutils.find_pattern(self.app.root, "New", "push button",
|
||||||
wait_for_focus=True)
|
wait_for_focus=True)
|
||||||
b.click()
|
b.click()
|
||||||
|
@ -90,12 +90,14 @@ class DogtailApp(object):
|
|||||||
stdout = open(os.devnull)
|
stdout = open(os.devnull)
|
||||||
stderr = open(os.devnull)
|
stderr = open(os.devnull)
|
||||||
|
|
||||||
self._proc = subprocess.Popen([sys.executable,
|
cmd = [sys.executable]
|
||||||
os.path.join(os.getcwd(), "virt-manager"),
|
if tests.utils.clistate.use_coverage:
|
||||||
"--test-first-run", "--no-fork", "--connect", self.uri] +
|
cmd += ["-m", "coverage", "run", "--append"]
|
||||||
extra_opts,
|
cmd += [os.path.join(os.getcwd(), "virt-manager"),
|
||||||
stdout=stdout, stderr=stderr)
|
"--test-first-run", "--no-fork", "--connect", self.uri]
|
||||||
|
cmd += extra_opts
|
||||||
|
|
||||||
|
self._proc = subprocess.Popen(cmd, stdout=stdout, stderr=stderr)
|
||||||
self._root = dogtail.tree.root.application("virt-manager")
|
self._root = dogtail.tree.root.application("virt-manager")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
@ -32,6 +32,7 @@ class _CLIState(object):
|
|||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.regenerate_output = False
|
self.regenerate_output = False
|
||||||
|
self.use_coverage = False
|
||||||
clistate = _CLIState()
|
clistate = _CLIState()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user