[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Trap exceptions that get raised when running tests



commit 5e46ee69b9039d03b7726772aff2bf27fc347851
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Mon Nov 12 09:39:38 2012 +0100

    Trap exceptions that get raised when running tests
---
 ooni/runner.py |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/ooni/runner.py b/ooni/runner.py
index 1aac145..b27ed63 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -170,6 +170,7 @@ def runTestWithInput(test_class, test_method, test_input, oreporter):
     # call setup on the test
     test_instance.setUp()
     test = getattr(test_instance, test_method)
+
     d = defer.maybeDeferred(test)
     d.addCallback(test_done, test_instance, test_method)
     d.addErrback(test_error, test_instance, test_method)
@@ -195,11 +196,8 @@ def runTestWithInputUnit(test_class,
     log.debug("input unit %s" % input_unit)
     for test_input in input_unit:
         log.debug("running with input: %s" % test_input)
-        try:
-            d = runTestWithInput(test_class, 
-                    test_method, test_input, oreporter)
-        except Exception, e:
-            print e
+        d = runTestWithInput(test_class, 
+                test_method, test_input, oreporter)
         dl.append(d)
     return defer.DeferredList(dl)
 
@@ -241,15 +239,20 @@ def runTestCases(test_cases, options,
     # This deferred list is a deferred list of deferred lists
     # it is used to store all the deferreds of the tests that 
     # are run
-    for input_unit in input_unit_factory:
-        # We do this because generators can't we rewound.
-        input_list = list(input_unit)
-        for test_case in test_cases:
-            log.debug("Processing %s" % test_case[1])
-            test_class = test_case[0]
-            test_method = test_case[1]
-            yield runTestWithInputUnit(test_class,
-                        test_method, input_list,
-                        oreporter)
+    try:
+        for input_unit in input_unit_factory:
+            log.debug("Running this input unit %s" % input_unit)
+            # We do this because generators can't we rewound.
+            input_list = list(input_unit)
+            for test_case in test_cases:
+                log.debug("Processing %s" % test_case[1])
+                test_class = test_case[0]
+                test_method = test_case[1]
+                yield runTestWithInputUnit(test_class,
+                            test_method, input_list,
+                            oreporter)
+    except Exception:
+        log.exception("Problem in running test")
+        reactor.stop()
     oreporter.allDone()
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits