validate:tools: Veryfy test manager are operationnal before using them

This commit is contained in:
Thibault Saunier 2014-01-09 15:17:53 +01:00
parent e30f6372f9
commit cdff1c93ca
4 changed files with 38 additions and 6 deletions

View file

@ -176,7 +176,7 @@ class GESTestsManager(TestsManager):
def init(self):
if os.system("which ges-launch") == 0:
if which(DEFAULT_GES_LAUNCH):
return True
return False
@ -202,7 +202,6 @@ class GESTestsManager(TestsManager):
projects = list()
if not self.args:
path = self.options.projects_paths
print path
for root, dirs, files in os.walk(path):
for f in files:
if not f.endswith(".xges"):

View file

@ -110,6 +110,12 @@ class GstValidateManager(TestsManager, Loggable):
Loggable.__init__(self)
self._uris = []
def init(self):
if which(DEFAULT_GST_VALIDATE) and which(DEFAULT_GST_VALIDATE_TRANSCODING):
return True
return False
def add_options(self, group):
group.add_option("-c", "--check-discovering", dest="check_discovering",
default=False, action="store_true",

View file

@ -234,6 +234,9 @@ class TestsManager(object):
self.reporter = None
self.wanted_tests_patterns = []
def init(self):
return False
def list_tests(self):
pass
@ -273,8 +276,11 @@ class TestsManager(object):
self.reporter.after_test()
class _TestsLauncher(object):
class _TestsLauncher(Loggable):
def __init__(self):
Loggable.__init__(self)
self.testers = []
self.tests = []
self.reporter = None
@ -299,8 +305,12 @@ class _TestsLauncher(object):
if f.endswith(".py"):
execfile(os.path.join(d, "apps", f), env)
self.testers = [i() for i in get_subclasses(TestsManager, env)]
testers = [i() for i in get_subclasses(TestsManager, env)]
for tester in testers:
if tester.init() is True:
self.testers.append(tester)
else:
self.warning("Can not init tester: %s", tester.name)
def add_options(self, parser):
for tester in self.testers:

View file

@ -61,6 +61,23 @@ def mkdir(directory):
pass
def which(name):
result = []
exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
path = os.environ.get('PATH', None)
if path is None:
return []
for p in os.environ.get('PATH', '').split(os.pathsep):
p = os.path.join(p, name)
if os.access(p, os.X_OK):
result.append(p)
for e in exts:
pext = p + e
if os.access(pext, os.X_OK):
result.append(pext)
return result
def printc(message, color="", title=False):
if title:
length = 0