On 04/12/2013 04:39 PM, Jon Severinsson wrote:
---
  framework/core.py |    2 +-
  tests/all.tests   |    6 ++++++
  2 filer ändrade, 7 tillägg(+), 1 borttagning(-)

diff --git a/framework/core.py b/framework/core.py
index 744fda4..62b2ed9 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -608,7 +608,7 @@ def loadTestProfile(filename):
                '__file__': filename,
        }
        try:
-               execfile(filename, ns)
+               exec(compile(open(filename,"rb").read(), filename, 'exec'), ns)
        except:
                traceback.print_exc()
                raise Exception('Could not read tests profile')
diff --git a/tests/all.tests b/tests/all.tests
index 8334c7f..0e2bbaa 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -58,6 +58,12 @@ def power_set(s):
                  result.append(p + [s[-1]])
          return result

+try:
+    def execfile(filename):
+        exec(compile(open(filename,"rb").read(), filename, 'exec'))
+except:
+    pass
+
  ######
  # Collecting all tests
  profile = TestProfile()


Two problems here:

1. This leaves the file open...you ought to close it after you're done reading from it. The easiest way to do this is by doing:

with open(filename, 'rb') as f:
    exec(compile(f.read(), filename, 'exec'))

2. You missed a bunch of tests/*.tests files, which all use execfile() as well. I'm not sure the best way to handle this...perhaps create a framework/util.py that defines execfile for Python 3? Then we'd need imports everywhere, though...

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

Reply via email to