[Piglit] [PATCH 11/20] framework: Port from execfile to compile & exec (required by python 3.x)

Jon Severinsson jon at severinsson.net
Wed Apr 17 09:14:50 PDT 2013


---
 framework/core.py        |    3 ++-
 tests/all.tests          |   12 ++++++++----
 tests/quick-driver.tests |    3 ++-
 tests/quick.tests        |    3 ++-
 tests/r300.tests         |    3 ++-
 tests/r500.tests         |    3 ++-
 tests/r600.tests         |    3 ++-
 7 filer ändrade, 20 tillägg(+), 10 borttagningar(-)

diff --git a/framework/core.py b/framework/core.py
index 26a44b0..5dc4f51 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -608,7 +608,8 @@ def loadTestProfile(filename):
 		'__file__': filename,
 	}
 	try:
-		execfile(filename, ns)
+		with open(filename, 'rb') as f:
+			exec(compile(f.read(), f.name, '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..b534b41 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -63,7 +63,8 @@ def power_set(s):
 profile = TestProfile()
 
 try:
-	execfile(path.join(testsDir, 'gtf.tests'))
+	with open(os.path.join(testsDir, 'gtf.tests'), 'rb') as f:
+		exec(compile(f.read(), f.name, 'exec'))
 except SystemExit:
 	pass
 
@@ -140,19 +141,22 @@ def add_glsl1(name):
 	testname = 'glsl1-' + name
 	glean[testname] = GleanTest('glsl1')
 	glean[testname].env['PIGLIT_TEST'] = name
-execfile(testsDir + '/glean-glsl1.tests')
+with open(os.path.join(testsDir, 'glean-glsl1.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 def add_fp1(name):
 	testname = 'fp1-' + name
 	glean[testname] = GleanTest('fragProg1')
 	glean[testname].env['PIGLIT_TEST'] = name
-execfile(testsDir + '/glean-fragProg1.tests')
+with open(os.path.join(testsDir, 'glean-fragProg1.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 def add_vp1(name):
 	testname = 'vp1-' + name
 	glean[testname] = GleanTest('vertProg1')
 	glean[testname].env['PIGLIT_TEST'] = name
-execfile(testsDir + '/glean-vertProg1.tests')
+with open(os.path.join(testsDir, 'glean-vertProg1.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 def add_fbo_formats_tests(path, extension, suffix=''):
 	profile.tests[path + '/fbo-generatemipmap-formats' + suffix] = PlainExecTest('fbo-generatemipmap-formats -auto ' + extension)
diff --git a/tests/quick-driver.tests b/tests/quick-driver.tests
index f7c1a0f..7639c20 100644
--- a/tests/quick-driver.tests
+++ b/tests/quick-driver.tests
@@ -4,7 +4,8 @@ import os.path
 
 global profile
 
-execfile(os.path.dirname(__file__) + '/quick.tests')
+with open(os.path.join(os.path.dirname(__file__), 'quick.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 # These take too long
 del profile.tests['shaders']['glsl-fs-inline-explosion']
diff --git a/tests/quick.tests b/tests/quick.tests
index 89ba2c3..8daf01f 100644
--- a/tests/quick.tests
+++ b/tests/quick.tests
@@ -8,6 +8,7 @@ import os.path
 global profile
 global GleanTest
 
-execfile(os.path.dirname(__file__) + '/all.tests')
+with open(os.path.join(os.path.dirname(__file__), 'all.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 GleanTest.globalParams += [ "--quick" ]
diff --git a/tests/r300.tests b/tests/r300.tests
index 78f457f..217fdf2 100644
--- a/tests/r300.tests
+++ b/tests/r300.tests
@@ -6,7 +6,8 @@ import os.path
 
 global profile
 
-execfile(os.path.dirname(__file__) + '/quick-driver.tests')
+with open(os.path.join(os.path.dirname(__file__), 'quick-driver.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 from framework.core import *
 from framework.gleantest import *
diff --git a/tests/r500.tests b/tests/r500.tests
index 6eafa61..c8a310a 100644
--- a/tests/r500.tests
+++ b/tests/r500.tests
@@ -6,7 +6,8 @@ import os.path
 
 global profile
 
-execfile(os.path.dirname(__file__) + '/quick-driver.tests')
+with open(os.path.join(os.path.dirname(__file__), 'quick-driver.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 from framework.core import *
 from framework.gleantest import *
diff --git a/tests/r600.tests b/tests/r600.tests
index 5355883..94c971e 100644
--- a/tests/r600.tests
+++ b/tests/r600.tests
@@ -3,7 +3,8 @@ import os.path
 
 global profile
 
-execfile(os.path.dirname(__file__) + '/quick-driver.tests')
+with open(os.path.join(os.path.dirname(__file__), 'quick-driver.tests'), 'rb') as f:
+	exec(compile(f.read(), f.name, 'exec'))
 
 from framework.core import *
 from framework.gleantest import *
-- 
1.7.10.4



More information about the Piglit mailing list