[Piglit] [PATCH] log: Print status of each test

Dylan Baker baker.dylan.c at gmail.com
Sat Feb 15 01:41:32 PST 2014


This presents a logger that is sort of half way between the original
logger, and the one introduced in 0920e380. This logger prints each test
and it's status, along with the total number of tests and the number of
tests completed.

It looks like this:
[<finished>/<ottal>] <status> :: <test name>
[<finished>/<ottal>] <status> :: <test name>
[<finished>/<ottal>] <status> :: <test name>
[<finished>/<ottal>] <status> :: <test name>
...

CC: Daniel Vetter <daniel.vetter at ffwll.ch>
CC: Eric Anholt <eric at anholt.net>
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/core.py |  6 ++----
 framework/log.py  | 40 ++++++++++------------------------------
 2 files changed, 12 insertions(+), 34 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index ac25917..b30920f 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -434,17 +434,16 @@ class Test(object):
             ``spec/glsl-1.30/preprocessor/compiler/keywords/void.frag``.
         '''
 
-        log_current = log.get_current()
         # Run the test
         if env.execute:
             try:
-                log.log()
                 time_start = time.time()
                 dmesg.update_dmesg()
                 self._test_hook_execute_run()
                 result = self.run(env)
                 result = dmesg.update_result(result)
                 time_end = time.time()
+                log.log(path, result['result'])
                 if 'time' not in result:
                     result['time'] = time_end - time_start
                 if 'result' not in result:
@@ -469,8 +468,7 @@ class Test(object):
             else:
                 json_writer.write_dict_item(path, result)
         else:
-            log.log()
-        log.mark_complete(log_current)
+            log.log(path, "dry-run")
 
 
 class Group(dict):
diff --git a/framework/log.py b/framework/log.py
index dcbe345..8d5db2b 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -34,46 +34,26 @@ class Log(object):
     def __init__(self, total):
         self.__total = total
         self.__complete = 1
-        self.__running = []
-        self.__generator = (x for x in xrange(self.__total))
         self.__pad = len(str(self.__total))
 
-    def _running(self):
-        return "Running Test(s): {}".format(
-            " ".join([str(x).zfill(self.__pad) for x in self.__running]))
-
     def _percent(self):
         return "[{0}/{1}]".format(str(self.__complete).zfill(self.__pad),
                                   str(self.__total).zfill(self.__pad))
 
     @synchronized_self
-    def mark_complete(self, value):
-        """ Used to mark a test as complete in the log
+    def log(self, name, status, complete=True):
+        """ Print to the screen 
+
+        Prints in the form [number complete/total] status -- name\n
 
         Arguments:
-        value -- the test number to mark complete
+        name -- the name of the test to print
+        status -- the status of that test
         
         """
-        # Mark running complete
-        assert value in self.__running
-        self.__running.remove(value)
-
-        # increment the number of completed tests
-        self.__complete += 1
-
-    @synchronized_self
-    def log(self):
-        """ Print to the screen 
+        if complete:
+            self.__complete += 1
 
-        Works by moving the cursor back to the front of the line and printing
-        over it.
-        
-        """
-        sys.stdout.write("{0} {1} \r".format(self._percent(), self._running()))
+        sys.stdout.write("{0} {2} :: {1} \n".format(self._percent(), name,
+                                                    status))
 
-    @synchronized_self
-    def get_current(self):
-        """ Returns a new number to know what processes are running """
-        x = self.__generator.next()
-        self.__running.append(x)
-        return x
-- 
1.8.5.4



More information about the Piglit mailing list