[Piglit] [PATCH 2/3] piglit-run.py: Record all attributes of Environment and restore them

Dylan Baker baker.dylan.c at gmail.com
Fri Nov 15 10:24:41 PST 2013


This causes all attributes in the Environment instance env to be dumped
into the json and reloaded on a resume. It adds an __iter__ magic method
to core.Environment to allow this.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/core.py | 5 +++++
 piglit-run.py     | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index 55ce06b..51c0380 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -62,6 +62,8 @@ class PiglitJSONEncoder(json.JSONEncoder):
     def default(self, o):
         if isinstance(o, status.Status):
             return str(o)
+        elif isinstance(o, set):
+            return list(o)
         return json.JSONEncoder.default(self, o)
 
 class JSONWriter:
@@ -414,6 +416,9 @@ class Environment:
         for each in exclude_filter:
             self.exclude_filter.append(re.compile(each))
 
+    def __iter__(self):
+        return self.__dict__.iteritems()
+
     def run(self, command):
         try:
             p = subprocess.Popen(command,
diff --git a/piglit-run.py b/piglit-run.py
index 86448ae..41ee5ca 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -136,8 +136,8 @@ def main():
     json_writer.write_dict_key('options')
     json_writer.open_dict()
     json_writer.write_dict_item('profile', args.test_profile)
-    json_writer.write_dict_item('filter', args.include_tests)
-    json_writer.write_dict_item('exclude_filter', args.exclude_tests)
+    for key, value in env:
+        json_writer.write_dict_item(key, value)
     json_writer.close_dict()
 
     json_writer.write_dict_item('name', results.name)
-- 
1.8.3.2



More information about the Piglit mailing list