From 7e12f16be6820482e55300177f34d38cd204b759 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Mon, 18 Feb 2019 12:47:08 +0100 Subject: [PATCH] Tools: fix lambda test --- Tools/autotest/apmrover2.py | 1 + Tools/autotest/arducopter.py | 1 + Tools/autotest/arduplane.py | 1 + Tools/autotest/ardusub.py | 1 + Tools/autotest/common.py | 18 +++++++++--------- Tools/autotest/quadplane.py | 1 + 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Tools/autotest/apmrover2.py b/Tools/autotest/apmrover2.py index b0b9ffbe1c..1a64b61f5e 100644 --- a/Tools/autotest/apmrover2.py +++ b/Tools/autotest/apmrover2.py @@ -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' diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index ee9140e139..eac92c2a3c 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -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 = '+' diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index 6d38dbe044..d6f9740d36 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -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' diff --git a/Tools/autotest/ardusub.py b/Tools/autotest/ardusub.py index 359e5096fc..e83ebbbeec 100644 --- a/Tools/autotest/ardusub.py +++ b/Tools/autotest/ardusub.py @@ -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' diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index 61b31c154e..29c262e40b 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -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 diff --git a/Tools/autotest/quadplane.py b/Tools/autotest/quadplane.py index 48d75f30a6..f7e1218f34 100644 --- a/Tools/autotest/quadplane.py +++ b/Tools/autotest/quadplane.py @@ -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'