Tools: fix lambda test

This commit is contained in:
Pierre Kancir 2019-02-18 12:47:08 +01:00 committed by Peter Barker
parent 25282c2989
commit 7e12f16be6
6 changed files with 14 additions and 9 deletions

View File

@ -57,6 +57,7 @@ class AutoTestRover(AutoTest):
return SITL_START_LOCATION
def init(self):
super(AutoTestRover, self).init(os.path.realpath(__file__))
if self.frame is None:
self.frame = 'rover'

View File

@ -73,6 +73,7 @@ class AutoTestCopter(AutoTest):
return 'ArduCopter'
def init(self):
super(AutoTestCopter, self).init(os.path.realpath(__file__))
if self.frame is None:
self.frame = '+'

View File

@ -53,6 +53,7 @@ class AutoTestPlane(AutoTest):
return SITL_START_LOCATION
def init(self):
super(AutoTestPlane, self).init(os.path.realpath(__file__))
if self.frame is None:
self.frame = 'plane-elevrev'

View File

@ -51,6 +51,7 @@ class AutoTestSub(AutoTest):
return SITL_START_LOCATION
def init(self):
super(AutoTestSub, self).init(os.path.realpath(__file__))
if self.frame is None:
self.frame = 'vectored'

View File

@ -1635,18 +1635,19 @@ class AutoTest(ABC):
# check for lambda: test_function without paranthesis
faulty_strings = re.findall(r"lambda\s*:\s*\w+.\w+\s*\)", f.read())
if faulty_strings:
desc = ("Syntax error in autotest lambda at : " +
faulty_strings)
desc = "Syntax error in autotest lambda at : \n"
for x in range(len(faulty_strings)):
desc += faulty_strings[x] + "\n"
raise ErrorException(desc)
except ErrorException:
self.progress('FAILED: "%s"' % "Check for syntax mistake in autotest lambda")
except ErrorException as msg:
self.progress("FAILED: Check for syntax mistake in autotest lambda. \n" + str(msg))
exit(1)
self.progress('PASSED: "%s"' % "Check for syntax mistake in autotest lambda")
self.progress("PASSED: Check for syntax mistake in autotest lambda")
@abc.abstractmethod
def init(self):
def init(self, file):
"""Initilialize autotest feature."""
pass
self.check_test_syntax(test_file=os.path.realpath(file))
def expect_command_ack(self, command):
m = self.mav.recv_match(type='COMMAND_ACK', blocking=True, timeout=10)
@ -2178,7 +2179,6 @@ switch value'''
def run_tests(self, tests):
"""Autotest vehicle in SITL."""
self.check_test_syntax(test_file=os.path.realpath(__file__))
if self.run_tests_called:
raise ValueError("run_tests called twice")
self.run_tests_called = True

View File

@ -52,6 +52,7 @@ class AutoTestQuadPlane(AutoTest):
self.sitl = None
def init(self):
super(AutoTestQuadPlane, self).init(os.path.realpath(__file__))
if self.frame is None:
self.frame = 'quadplane'