[PATCH] [TEST] #2 Add stack trace on error to make test case development easier

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1217262465 25200 # Node ID 9e1d09bf6636d3a0244ee3224b22dcba267425d5 # Parent a39dc855b73eb6f5a960bc377a093d3fa953f926 [TEST] #2 Add stack trace on error to make test case development easier Changes: - Fix whitespace issue Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r a39dc855b73e -r 9e1d09bf6636 lib/CimTest/Globals.py --- a/lib/CimTest/Globals.py Mon Jul 28 09:20:54 2008 -0700 +++ b/lib/CimTest/Globals.py Mon Jul 28 09:27:45 2008 -0700 @@ -25,6 +25,7 @@ import os import logging from optparse import OptionParser +import traceback global CIM_USER global CIM_PASS @@ -143,6 +144,7 @@ rc = f() except Exception, e: logger.error('%s : %s' % (e.__class__.__name__, e)) + logger.error("%s" % traceback.print_exc()) rc = FAIL return rc setattr(do_try, 'options', options)

How or when can we make use of this ? Thanks and Regards, Deepti. Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1217262465 25200 # Node ID 9e1d09bf6636d3a0244ee3224b22dcba267425d5 # Parent a39dc855b73eb6f5a960bc377a093d3fa953f926 [TEST] #2 Add stack trace on error to make test case development easier
Changes: - Fix whitespace issue
Signed-off-by: Dan Smith <danms@us.ibm.com>
diff -r a39dc855b73e -r 9e1d09bf6636 lib/CimTest/Globals.py --- a/lib/CimTest/Globals.py Mon Jul 28 09:20:54 2008 -0700 +++ b/lib/CimTest/Globals.py Mon Jul 28 09:27:45 2008 -0700 @@ -25,6 +25,7 @@ import os import logging from optparse import OptionParser +import traceback
global CIM_USER global CIM_PASS @@ -143,6 +144,7 @@ rc = f() except Exception, e: logger.error('%s : %s' % (e.__class__.__name__, e)) + logger.error("%s" % traceback.print_exc()) rc = FAIL return rc setattr(do_try, 'options', options)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

DK> How or when can we make use of this ? Since the entire test is run in a try..except block, errors and typos while writing tests get squashed down to nothing more than an error message like "IndexError: list index out of range", with no indication of where that is happening. Putting a stack trace in the error output gives you that information. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Deepti B Kalakeri