@@ -596,13 +596,17 @@ def _call_test_function(func, *args, **dargs):
inside test code are considered test failures."""
try:
return func(*args, **dargs)
- except error.AutotestError:
- # Pass already-categorized errors on up as is.
- raise
+ except error.AutotestError, e:
+ # Inject context info and pass already-categorized errors on up.
+ e.context = error.get_context(sys.exc_info()[2])
+ raise sys.exc_info()[0], e, sys.exc_info()[2]
except Exception, e:
- # Other exceptions must be treated as a FAIL when
- # raised during the test functions
- raise error.UnhandledTestFail(e)
+ # Other exceptions are treated as a FAIL when raised during the test
+ # functions. Convert them to UnhandledTestFail, inject context info
+ # and pass them on up.
+ e = error.UnhandledTestFail(e)
+ e.context = error.get_context(sys.exc_info()[2])
+ raise e
def runtest(job, url, tag, args, dargs,