Tools: autotest: use class map for getting test class for full test name

This commit is contained in:
Peter Barker 2019-03-09 12:28:27 +11:00 committed by Peter Barker
parent a504f9ac8d
commit 2a9e0859c7

View File

@ -295,12 +295,6 @@ def find_specific_test_to_run(step):
(testname, test) = t
return "%s.%s" % (testname, test)
def run_specific_test(step, *args, **kwargs):
t = split_specific_test_step(step)
if t is None:
return []
(testname, test) = t
tester_class_map = {
"fly.ArduCopter": arducopter.AutoTestCopter,
"fly.ArduPlane": arduplane.AutoTestPlane,
@ -311,6 +305,13 @@ def run_specific_test(step, *args, **kwargs):
"dive.ArduSub": ardusub.AutoTestSub,
"test.AntennaTracker": antennatracker.AutoTestTracker,
}
def run_specific_test(step, *args, **kwargs):
t = split_specific_test_step(step)
if t is None:
return []
(testname, test) = t
tester_class = tester_class_map[testname]
tester = tester_class(*args, **kwargs)
@ -380,37 +381,9 @@ def run_step(step):
if opts.speedup is not None:
fly_opts["speedup"] = opts.speedup
if step == 'fly.ArduCopter':
tester = arducopter.AutoTestCopter(binary, **fly_opts)
return tester.autotest()
if step == 'fly.CopterAVC':
tester = arducopter.AutoTestHeli(binary, **fly_opts)
return tester.autotest()
if step == 'fly.ArduPlane':
tester = arduplane.AutoTestPlane(binary, **fly_opts)
return tester.autotest()
if step == 'fly.QuadPlane':
tester = quadplane.AutoTestQuadPlane(binary, **fly_opts)
return tester.autotest()
if step == 'drive.APMrover2':
tester = apmrover2.AutoTestRover(binary, **fly_opts)
return tester.autotest()
if step == 'drive.balancebot':
tester = balancebot.AutoTestBalanceBot(binary, **fly_opts)
return tester.autotest()
if step == 'dive.ArduSub':
tester = ardusub.AutoTestSub(binary, **fly_opts)
return tester.autotest()
if step == 'test.AntennaTracker':
tester = antennatracker.AutoTestTracker(binary, **fly_opts)
return tester.autotest()
# handle "fly.ArduCopter" etc:
if step in tester_class_map:
return tester_class_map[step](binary, **fly_opts).autotest()
specific_test_to_run = find_specific_test_to_run(step)
if specific_test_to_run is not None: