Keep the existing results file name if the results input was a file
rather than a directory.

Signed-off-by: Thomas Wood <thomas.w...@intel.com>
---
 framework/backends/json.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/framework/backends/json.py b/framework/backends/json.py
index affd64e..2fedd13 100644
--- a/framework/backends/json.py
+++ b/framework/backends/json.py
@@ -296,10 +296,14 @@ def _update_results(results, filepath):
     results = loop_updates(results)
 
     # Move the old results, and write the current results
-    filedir = os.path.dirname(filepath)
     try:
-        os.rename(filepath, os.path.join(filedir, 'results.json.old'))
-        _write(results, os.path.join(filedir, 'results.json'))
+        if os.path.isfile(filepath):
+            os.rename(filepath, filepath + '.old')
+            _write(results, filepath)
+        else:
+            filedir = os.path.dirname(filepath)
+            os.rename(filepath, os.path.join(filedir, 'results.json.old'))
+            _write(results, os.path.join(filedir, 'results.json'))
     except OSError:
         print("WARNING: Could not write updated results {}".format(filepath),
               file=sys.stderr)
-- 
2.1.0

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to