From 7f888f8e77d3d45feba2243f5b47829f4a6f96f6 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Sun, 14 Jul 2024 23:29:06 +0100 Subject: [PATCH] rename failed as it is not about failure --- qa/bin/functional | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/qa/bin/functional b/qa/bin/functional index f2406e1fc..4ec64c3ce 100755 --- a/qa/bin/functional +++ b/qa/bin/functional @@ -125,14 +125,13 @@ class Exec(object): return False return True - def failed(self, reason='issue with exabgp'): + def report(self, reason='issue with exabgp'): print(reason) print(f'> {self.command}') print(f'return: {self.code}') print(f'stdout: {self.stdout.decode()}') print(f'stderr: {self.stderr.decode()}') print(f'message: {self.message}') - return False def collect(self): if self.stdout: @@ -327,11 +326,16 @@ class EncodingTests(Tests): self.collect() if self.code == 0: if self._check in self.stdout: + if os.getenv('DEBUG', None) != None: + self.report('completed successfully') return True if self._check in self.stderr: + if os.getenv('DEBUG', None) != None: + self.report('completed successfully') return True - return self.failed('completed successfully') + self.report(f'failed with code {self.code}') + return False API = re.compile(r'^\s*run\s+(.*)\s*?;\s*?$') @@ -503,20 +507,24 @@ class DecodingTests(Tests): def success(self): self.collect() if self.stderr: - return self.failed('stderr is \n' + self.stderr) + self.report('stderr is \n' + self.stderr) + return False if not self.stdout: - return self.failed('no stdout received') + self.report('no stdout received') + return False try: decoded = json.loads(self.stdout) self._cleanup(decoded) except Exception: - return self.failed('issue, failed to decode the JSON') + self.report('issue, report to decode the JSON') + return False if decoded != self.conf['json']: from pprint import pformat failure = 'issue, JSON does not match' failure += f'\ndecoded : {pformat(decoded)}\n' failure += f'\nexpected: {pformat(self.conf["json"])}' - return self.failed(failure) + self.report(failure) + return False return True def __init__(self): @@ -605,7 +613,8 @@ class ParsingTests(Tests): def success(self): self.collect() if self.code != 0: - return self.failed('return code is not zero') + self.report('return code is not zero') + return False return self.code == 0 @@ -675,7 +684,6 @@ class ParsingTests(Tests): self.display() return success - def add_test(subparser, name, tests, extra): sub = subparser.add_parser(name, help=f'run {name} test') if 'dry' in extra: