From 3c7b0bfbf62b1d919ca6251f8a246e9cfe64ae41 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Thu, 27 Dec 2012 20:40:54 +0000 Subject: Dump the tree whenever there is an exception --- (limited to 'tests') diff --git a/tests/sugar/shell.py b/tests/sugar/shell.py index 515f98e..33917a9 100644 --- a/tests/sugar/shell.py +++ b/tests/sugar/shell.py @@ -1,6 +1,7 @@ import logging import sys import time +import traceback import tree @@ -83,4 +84,9 @@ def main(): for activity in build_activities_list(): launch_and_stop_activity(activity) -main() +try: + main() +except: + logging.error(traceback.format_exc()) + logging.error("\n%s" % tree.get_root().dump()) + raise diff --git a/tests/sugar/tree.py b/tests/sugar/tree.py index 6a12abc..19206e2 100644 --- a/tests/sugar/tree.py +++ b/tests/sugar/tree.py @@ -30,8 +30,6 @@ def _retry_find(func): time.sleep(5) n_retries = n_retries + 1 - get_root().dump() - return result return wrapped @@ -42,7 +40,9 @@ class Node: self._accessible = accessible def dump(self): - self._crawl_accessible(self, 0) + lines = [] + self._crawl_accessible(self, 0, lines) + return "\n".join(lines) def do_action(self, name): for i in range(self._accessible.get_n_actions()): @@ -130,8 +130,8 @@ class Node: for child in node.get_children(): self._find_all_descendants(child, predicate, matches) - def _crawl_accessible(self, node, depth): - print " " * depth + str(node) + def _crawl_accessible(self, node, depth, lines): + lines.append(" " * depth + str(node)) for child in node.get_children(): - self._crawl_accessible(child, depth + 1) + self._crawl_accessible(child, depth + 1, lines) -- cgit v0.9.1