[Piglit] [PATCH 2/4] framework/summary.py: simplify console output with a helper function

Dylan Baker baker.dylan.c at gmail.com
Mon May 11 14:57:28 PDT 2015


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/summary.py | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/framework/summary.py b/framework/summary.py
index 5d6436c..5b9ba9a 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -563,25 +563,24 @@ class Summary:
         assert mode in ['summary', 'diff', 'incomplete', 'all'], mode
         self.__find_totals(self.results[-1])
 
-        # Print the name of the test and the status from each test run
-        if mode == 'all':
-            for test in self.tests['all']:
+        def printer(list_):
+            """Takes a list of test names to print and prints the name and
+            result.
+
+            """
+            for test in list_:
                 print("{test}: {statuses}".format(
                     test=test,
                     statuses=' '.join(str(i.tests.get(test, {'result': so.SKIP})
                                           ['result']) for i in self.results)))
+
+        # Print the name of the test and the status from each test run
+        if mode == 'all':
+            printer(self.tests['all'])
         elif mode == 'diff':
-            for test in self.tests['changes']:
-                print("{test}: {statuses}".format(
-                    test=test,
-                    statuses=' '.join(str(i.tests.get(test, {'result': so.SKIP})
-                                          ['result']) for i in self.results)))
+            printer(self.tests['changes'])
         elif mode == 'incomplete':
-            for test in self.tests['incomplete']:
-                print("{test}: {statuses}".format(
-                    test=test,
-                    statuses=' '.join(str(i.tests.get(test, {'result': so.SKIP})
-                                          ['result']) for i in self.results)))
+            printer(self.tests['incomplete'])
 
         # Print the summary
         print("summary:\n"
-- 
2.4.0



More information about the Piglit mailing list