[Piglit] [PATCH 03/19] results.py: Change JSONWriter methods to be more like Backend

Dylan Baker baker.dylan.c at gmail.com
Thu Aug 28 15:35:31 PDT 2014


This changes initialize_json and close_json to be more like the
constructor and finalize methods of Backend.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/programs/run.py |  9 +++++----
 framework/results.py      | 12 ++++++++----
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/framework/programs/run.py b/framework/programs/run.py
index 0664f02..3efd5bf 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -220,8 +220,9 @@ def run(input_):
         options[key] = value
     if args.platform:
         options['platform'] = args.platform
-    json_writer.initialize_json(options, results.name,
-                                core.collect_system_info())
+    options['name'] = results.name
+    options['env'] = core.collect_system_info()
+    json_writer.initialize_json(options)
 
     profile = framework.profile.merge_test_profiles(args.test_profile)
     profile.results_dir = args.results_path
@@ -270,8 +271,8 @@ def resume(input_):
     results_path = path.join(args.results_path, 'results.json')
     json_writer = framework.results.JSONWriter(open(results_path, 'w+'),
                                                opts.sync)
-    json_writer.initialize_json(results.options, results.name,
-                                core.collect_system_info())
+    results.options['env'] = core.collect_system_info()
+    json_writer.initialize_json(results.options)
 
     for key, value in results.tests.iteritems():
         json_writer.write_dict_item(key, value)
diff --git a/framework/results.py b/framework/results.py
index 490883b..724faf2 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -207,7 +207,7 @@ class JSONWriter(object):
         # is popped and written into the json
         self._open_containers = []
 
-    def initialize_json(self, options, name, env):
+    def initialize_json(self, metadata):
         """ Write boilerplate json code
 
         This writes all of the json except the actual tests.
@@ -222,17 +222,21 @@ class JSONWriter(object):
         """
         self.open_dict()
         self.write_dict_item('results_version', CURRENT_JSON_VERSION)
-        self.write_dict_item('name', name)
+        self.write_dict_item('name', metadata['name'])
 
         self.write_dict_key('options')
         self.open_dict()
-        for key, value in options.iteritems():
+        for key, value in metadata.iteritems():
+            # Dont' write env or name into the options dictionary
+            if key in ['env', 'name']:
+                continue
+
             # Loading a NoneType will break resume, and are a bug
             assert value is not None, "Value {} is NoneType".format(key)
             self.write_dict_item(key, value)
         self.close_dict()
 
-        for key, value in env.iteritems():
+        for key, value in metadata['env'].iteritems():
             self.write_dict_item(key, value)
 
         # Open the tests dictinoary so that tests can be written
-- 
2.1.0



More information about the Piglit mailing list