mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-27 14:03:57 +03:00
clitest: Add infrastructure for skipping tests based on support checks
This commit is contained in:
parent
c67bd587b7
commit
c2a4ca66e9
@ -33,6 +33,7 @@ from tests import utils
|
|||||||
os.environ["VIRTCONV_TEST_NO_DISK_CONVERSION"] = "1"
|
os.environ["VIRTCONV_TEST_NO_DISK_CONVERSION"] = "1"
|
||||||
os.environ["LANG"] = "en_US.UTF-8"
|
os.environ["LANG"] = "en_US.UTF-8"
|
||||||
|
|
||||||
|
_defaultconn = utils.open_testdefault()
|
||||||
testuri = "test:///%s/tests/testdriver.xml" % os.getcwd()
|
testuri = "test:///%s/tests/testdriver.xml" % os.getcwd()
|
||||||
|
|
||||||
# There is a hack in virtinst/cli.py to find this magic string and
|
# There is a hack in virtinst/cli.py to find this magic string and
|
||||||
@ -143,6 +144,7 @@ class Command(object):
|
|||||||
self.cmdstr = cmd % test_files
|
self.cmdstr = cmd % test_files
|
||||||
self.check_success = True
|
self.check_success = True
|
||||||
self.compare_file = None
|
self.compare_file = None
|
||||||
|
self.support_check = None
|
||||||
|
|
||||||
app, opts = self.cmdstr.split(" ", 1)
|
app, opts = self.cmdstr.split(" ", 1)
|
||||||
self.argv = [os.path.abspath(app)] + shlex.split(opts)
|
self.argv = [os.path.abspath(app)] + shlex.split(opts)
|
||||||
@ -207,6 +209,13 @@ class Command(object):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
return (-1, "".join(traceback.format_exc()) + str(e))
|
return (-1, "".join(traceback.format_exc()) + str(e))
|
||||||
|
|
||||||
|
def skip_msg(self):
|
||||||
|
if self.support_check is None:
|
||||||
|
return
|
||||||
|
if _defaultconn.check_support(self.support_check):
|
||||||
|
return
|
||||||
|
return "skipped"
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
filename = self.compare_file
|
filename = self.compare_file
|
||||||
err = None
|
err = None
|
||||||
@ -359,7 +368,7 @@ class App(object):
|
|||||||
self.categories[catname] = default_args
|
self.categories[catname] = default_args
|
||||||
return _CategoryProxy(self, catname)
|
return _CategoryProxy(self, catname)
|
||||||
|
|
||||||
def _add(self, catname, testargs, valid, compfile):
|
def _add(self, catname, testargs, valid, compfile, support_check=None):
|
||||||
args = self.categories[catname] + " " + testargs
|
args = self.categories[catname] + " " + testargs
|
||||||
args = self._default_args(args, bool(compfile)) + " " + args
|
args = self._default_args(args, bool(compfile)) + " " + args
|
||||||
cmdstr = "./%s %s" % (self.appname, args)
|
cmdstr = "./%s %s" % (self.appname, args)
|
||||||
@ -368,14 +377,16 @@ class App(object):
|
|||||||
cmd.check_success = valid
|
cmd.check_success = valid
|
||||||
if compfile:
|
if compfile:
|
||||||
cmd.compare_file = "%s/%s.xml" % (compare_xmldir, compfile)
|
cmd.compare_file = "%s/%s.xml" % (compare_xmldir, compfile)
|
||||||
|
cmd.support_check = support_check
|
||||||
self.cmds.append(cmd)
|
self.cmds.append(cmd)
|
||||||
|
|
||||||
def add_valid(self, cat, args):
|
def add_valid(self, cat, args, **kwargs):
|
||||||
self._add(cat, args, True, None)
|
self._add(cat, args, True, None, **kwargs)
|
||||||
def add_invalid(self, cat, args):
|
def add_invalid(self, cat, args, **kwargs):
|
||||||
self._add(cat, args, False, None)
|
self._add(cat, args, False, None, **kwargs)
|
||||||
def add_compare(self, cat, args, compfile):
|
def add_compare(self, cat, args, compfile, **kwargs):
|
||||||
self._add(cat, args, not compfile.endswith("-fail"), compfile)
|
self._add(cat, args, not compfile.endswith("-fail"),
|
||||||
|
compfile, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -878,8 +889,12 @@ class CLITests(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def maketest(cmd):
|
def maketest(cmd):
|
||||||
def cmdtemplate(self, c):
|
def cmdtemplate(self, _cmdobj):
|
||||||
err = c.run()
|
skipmsg = _cmdobj.skip_msg()
|
||||||
|
if skipmsg:
|
||||||
|
self.skipTest(skipmsg)
|
||||||
|
|
||||||
|
err = _cmdobj.run()
|
||||||
if err:
|
if err:
|
||||||
self.fail(err)
|
self.fail(err)
|
||||||
return lambda s: cmdtemplate(s, cmd)
|
return lambda s: cmdtemplate(s, cmd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user