added funtionality to run selected test only and functionality to show available tests

This commit is contained in:
Martin Diehl 2016-09-20 07:10:07 +02:00
parent 03aebdf958
commit e5ba508080
1 changed files with 28 additions and 13 deletions

View File

@ -23,6 +23,8 @@ class Test():
'keep': False, 'keep': False,
'accept': False, 'accept': False,
'updateRequest': False, 'updateRequest': False,
'show': False,
'select': None,
} }
for arg in defaults.keys(): for arg in defaults.keys():
setattr(self,arg,kwargs.get(arg) if kwargs.get(arg) else defaults[arg]) setattr(self,arg,kwargs.get(arg) if kwargs.get(arg) else defaults[arg])
@ -58,10 +60,18 @@ class Test():
action = "store_true", action = "store_true",
dest = "accept", dest = "accept",
help = "calculate results but always consider test as successfull") help = "calculate results but always consider test as successfull")
self.parser.add_option("-l", "--list",
action = "store_true",
dest = "show",
help = "show all test variants and do no calculation")
self.parser.add_option("-s", "--select",
dest = "select",
help = "run test of given name only")
self.parser.set_defaults(keep = self.keep, self.parser.set_defaults(keep = self.keep,
accept = self.accept, accept = self.accept,
update = self.updateRequest, update = self.updateRequest,
show = self.show,
select = self.select,
) )
@ -73,21 +83,26 @@ class Test():
self.prepareAll() self.prepareAll()
for variant,name in enumerate(self.variants): for variant,name in enumerate(self.variants):
try: if self.options.show:
if not self.options.keep: logging.critical('{}: {}'.format(variant,name))
self.prepare(variant) elif self.options.select is not None and name != self.options.select:
self.run(variant) pass
else:
try:
if not self.options.keep:
self.prepare(variant)
self.run(variant)
self.postprocess(variant) self.postprocess(variant)
if self.options.update: if self.options.update:
if self.update(variant) != 0: logging.critical('update for "{}" failed.'.format(name)) if self.update(variant) != 0: logging.critical('update for "{}" failed.'.format(name))
elif not (self.options.accept or self.compare(variant)): # no update, do comparison elif not (self.options.accept or self.compare(variant)): # no update, do comparison
return variant+1 # return culprit return variant+1 # return culprit
except Exception as e : except Exception as e :
logging.critical('exception during variant execution: {}'.format(e)) logging.critical('exception during variant execution: {}'.format(e))
return variant+1 # return culprit return variant+1 # return culprit
return 0 return 0
def feasible(self): def feasible(self):