Skip to content

Commit

Permalink
testrunner: try to guess OUTPUT format of unittests and act accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Mar 4, 2021
1 parent 8fdfc08 commit 3cbd517
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions dist/pythonlibs/testrunner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,24 @@ def check_unittests(child, timeout=TIMEOUT, nb_tests=None):
to perform an exact match against that number.
"""
if nb_tests is None:
child.expect(r'OK \((\d+) tests\)', timeout=timeout)
return int(child.match.group(1))
_tests = int(nb_tests)
child.expect_exact('OK ({} tests)'.format(_tests), timeout=timeout)
# need escape sequence so don't use raw string
res = child.expect(['OK(\033\\[21m)? \\((\\d+) tests\\)',
r'<Tests>(\d+)</Tests>'], timeout=timeout)
if res == 0:
_tests = int(child.match.group(2))
else:
_tests = int(child.match.group(1))
else:
_tests = int(nb_tests)
# need escape sequence so don't use raw string
res = child.expect(['OK(\033\\[21m)? \\({} tests\\)'.format(_tests),
r'<Tests>{}</Tests>'.format(_tests)],
timeout=timeout)
if res == 1:
res = child.expect([r'<Failures>\d+</Failures>', '</Statistics>'],
timeout=timeout)
if res == 0:
raise AssertionError("Unittests failed")
return _tests


Expand Down

0 comments on commit 3cbd517

Please sign in to comment.