Skip to content

Commit

Permalink
rename failed as it is not about failure
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Jul 14, 2024
1 parent 4e88dcf commit 7f888f8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions qa/bin/functional
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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*?$')

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7f888f8

Please sign in to comment.