summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2014-02-15 02:25:15 -0500
committerIlia Mirkin <imirkin@alum.mit.edu>2014-02-16 23:12:10 -0500
commit20e30bb2f94a947776acdab60fb33420d6b5f28b (patch)
tree8f635962cc66139f8f4bd98375d782bdb1329ca8
parentf4ea4a71173e55086786981b1fda5909e4a75f1b (diff)
framework: keep track of running stats and display them
This will display a line that looks like: [00076/11064] fail: 1, pass: 55, skip: 19 Running Test(s): 00075 Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Dylan Baker <baker.dylan.c@gmail.com>
-rw-r--r--framework/core.py8
-rw-r--r--framework/log.py16
2 files changed, 18 insertions, 6 deletions
diff --git a/framework/core.py b/framework/core.py
index ac2591761..fc59e3c3b 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -435,6 +435,7 @@ class Test(object):
'''
log_current = log.get_current()
+ test_result = None
# Run the test
if env.execute:
try:
@@ -462,15 +463,16 @@ class Test(object):
result['traceback'] = \
"".join(traceback.format_tb(sys.exc_info()[2]))
- if 'subtest' in result and len(result['subtest'].keys()) > 1:
- for test in result['subtest'].keys():
+ test_result = result['result']
+ if 'subtest' in result and len(result['subtest']) > 1:
+ for test in result['subtest']:
result['result'] = result['subtest'][test]
json_writer.write_dict_item(os.path.join(path, test), result)
else:
json_writer.write_dict_item(path, result)
else:
log.log()
- log.mark_complete(log_current)
+ log.mark_complete(log_current, test_result)
class Group(dict):
diff --git a/framework/log.py b/framework/log.py
index d1c75294d..25ecdf501 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -37,6 +37,11 @@ class Log(object):
self.__running = []
self.__generator = (x for x in xrange(self.__total))
self.__pad = len(str(self.__total))
+ self.__summary = {}
+
+ def _summary(self):
+ return ", ".join("{0}: {1}".format(k, self.__summary[k])
+ for k in sorted(self.__summary))
def _running(self):
return "Running Test(s): {}".format(
@@ -47,12 +52,13 @@ class Log(object):
str(self.__total).zfill(self.__pad))
@synchronized_self
- def mark_complete(self, value):
+ def mark_complete(self, value, result):
""" Used to mark a test as complete in the log
Arguments:
value -- the test number to mark complete
-
+ result -- the result of the completed test
+
"""
# Mark running complete
assert value in self.__running
@@ -61,6 +67,9 @@ class Log(object):
# increment the number of completed tests
self.__complete += 1
+ if result:
+ self.__summary[result] = self.__summary.get(result, 0) + 1
+
@synchronized_self
def log(self):
""" Print to the screen
@@ -69,7 +78,8 @@ class Log(object):
over it.
"""
- sys.stdout.write("{0} {1} \r".format(self._percent(), self._running()))
+ sys.stdout.write("{0} {1} {2}\r".format(
+ self._percent(), self._summary(), self._running()))
# Need to flush explicitly, otherwise it all gets buffered without a
# newline.
sys.stdout.flush()