Skip to content
Snippets Groups Projects
Commit 2ead5ef3 authored by Hauke Petersen's avatar Hauke Petersen
Browse files

tools/testrunner: minor code beautifications

parent b62ebf5e
No related branches found
No related tags found
No related merge requests found
...@@ -26,9 +26,7 @@ def find_exc_origin(exc_info): ...@@ -26,9 +26,7 @@ def find_exc_origin(exc_info):
pos = list_until(extract_tb(exc_info), pos = list_until(extract_tb(exc_info),
lambda frame: frame[0].startswith(PEXPECT_PATH) lambda frame: frame[0].startswith(PEXPECT_PATH)
)[-1] )[-1]
return pos[3], \ return (pos[3], os.path.relpath(os.path.abspath(pos[0]), RIOTBASE), pos[1])
os.path.relpath(os.path.abspath(pos[0]), RIOTBASE), \
pos[1]
def run(testfunc, timeout=10, echo=True, traceback=False): def run(testfunc, timeout=10, echo=True, traceback=False):
env = os.environ.copy() env = os.environ.copy()
...@@ -49,16 +47,14 @@ def run(testfunc, timeout=10, echo=True, traceback=False): ...@@ -49,16 +47,14 @@ def run(testfunc, timeout=10, echo=True, traceback=False):
try: try:
testfunc(child) testfunc(child)
except pexpect.TIMEOUT: except pexpect.TIMEOUT:
line, filename, lineno = find_exc_origin(sys.exc_info()[2]) trace = find_exc_origin(sys.exc_info()[2])
print("Timeout in expect script at \"%s\" (%s:%d)" % print("Timeout in expect script at \"%s\" (%s:%d)" % trace)
(line, filename, lineno))
if traceback: if traceback:
print_tb(sys.exc_info()[2]) print_tb(sys.exc_info()[2])
return 1 return 1
except pexpect.EOF: except pexpect.EOF:
line, filename, lineno = find_exc_origin(sys.exc_info()[2]) trace = find_exc_origin(sys.exc_info()[2])
print("Unexpected end of file in expect script at \"%s\" (%s:%d)" % print("Unexpected end of file in expect script at \"%s\" (%s:%d)" % trace)
(line, filename, lineno))
if traceback: if traceback:
print_tb(sys.exc_info()[2]) print_tb(sys.exc_info()[2])
return 1 return 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment