in automation/tinc/main/tinctest/main.py [0:0]
def parseArgs(self, argv):
"""
TINCTestProgram accepts some additional arguments that should be propogated to tests
before they are run. This parses the additional arguments after calling out to
the super class.
"""
if len(argv) > 1 and argv[1].lower() == 'discover':
self._do_discovery(argv[2:])
return
import getopt
long_opts = ['help', 'verbose', 'quiet', 'failfast', 'catch', 'buffer', 'schedule']
# Add custom options
long_opts[len(long_opts):] = ['tincconfig=','jiralist=','codeline=','testconfig=','buildconfig=']
try:
options, args = getopt.getopt(argv[1:], 'hHvqfcbs:', long_opts)
for opt, value in options:
if opt in ('-h','-H','--help'):
self.usageExit()
if opt in ('-q','--quiet'):
self.verbosity = 0
if opt in ('-v','--verbose'):
self.verbosity = 2
if opt in ('-f','--failfast'):
if self.failfast is None:
self.failfast = True
# Should this raise an exception if -f is not valid?
if opt in ('-c','--catch'):
if self.catchbreak is None and installHandler is not None:
self.catchbreak = True
# Should this raise an exception if -c is not valid?
if opt in ('-b','--buffer'):
if self.buffer is None:
self.buffer = True
# Should this raise an exception if -b is not valid?
if opt in ('-s','--schedule'):
self.schedule = value
schedule_obj = TINCSchedule(self.schedule)
if not schedule_obj:
raise TINCExcpetion("Schedule file %s doesn't list any options to tinc.py" %self.schedule)
self.parseArgs([argv[0]] + shlex.split(schedule_obj.options))
return
# Parse custom options
if opt in ('--tincconfig'):
assert os.path.exists(value)
TINCTestProgram.tinc_config = TINCConfig(value)
if opt in ('--buildconfig'):
assert os.path.exists(value)
TINCTestProgram.build_config = TINCBuildConfig(value)
if opt in ('--jiralist'):
# convert comma separated list of jiras into a list
TINCTestCase.test_jira_list.extend(value.split(','))
if opt in ('--testconfig'):
TINCTestCase.test_config.extend(value.split(','))
if len(args) == 0 and self.defaultTest is None:
# createTests will load tests from self.module
self.testNames = None
elif len(args) > 0:
self.testNames = args
if __name__ == '__main__':
# to support python -m unittest ...
self.module = None
else:
self.testNames = (self.defaultTest,)
self.createTests()
except getopt.error, msg:
self.usageExit(msg)