[Piglit] [PATCH v2 14/16] shader_test.py: Use generic piglit exceptions
Dylan Baker
baker.dylan.c at gmail.com
Mon May 18 10:57:48 PDT 2015
Largely this just replaces a local exception with a generic one.
Signed-off-by: Dylan Bake <dylanx.c.baker at intel.com>
---
framework/test/shader_test.py | 22 ++++++++++------------
framework/tests/shader_test_tests.py | 3 ++-
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index be2d52a..d06eb2d 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -26,11 +26,11 @@
from __future__ import print_function, absolute_import
import re
+from framework import exceptions
from .piglit_test import PiglitBaseTest
__all__ = [
'ShaderTest',
- 'ShaderTestParserException',
]
@@ -41,14 +41,14 @@ class ShaderTest(PiglitBaseTest):
GLES3 test, and then returns a PiglitTest setup properly.
"""
- def __init__(self, arguments):
+ def __init__(self, filename):
is_gl = re.compile(r'GL (<|<=|=|>=|>) \d\.\d')
# Iterate over the lines in shader file looking for the config section.
# By using a generator this can be split into two for loops at minimal
# cost. The first one looks for the start of the config block or raises
# an exception. The second looks for the GL version or raises an
# exception
- with open(arguments, 'r') as shader_file:
+ with open(filename, 'r') as shader_file:
lines = (l for l in shader_file)
# Find the config section
@@ -60,7 +60,8 @@ class ShaderTest(PiglitBaseTest):
if line.lstrip().startswith('[require]'):
break
else:
- raise ShaderTestParserException("Config block not found")
+ raise exceptions.PiglitFatalError(
+ "In file {}: Config block not found".format(filename))
# Find the OpenGL API to use
for line in lines:
@@ -73,7 +74,8 @@ class ShaderTest(PiglitBaseTest):
# If we don't set gles2 or gles3 continue the loop,
# probably htting the exception in the for/else
else:
- raise ShaderTestParserException("No GL ES version set")
+ raise exceptions.PiglitFatalError(
+ "In File {}: No GL ES version set".format(filename))
break
elif line.startswith('[') or is_gl.match(line):
# In the event that we reach the end of the config black
@@ -82,16 +84,12 @@ class ShaderTest(PiglitBaseTest):
prog = 'shader_runner'
break
else:
- raise ShaderTestParserException("No GL version set")
+ raise exceptions.PiglitFatalError(
+ "In file {}: No GL version set".format(filename))
- super(ShaderTest, self).__init__([prog, arguments], run_concurrent=True)
+ super(ShaderTest, self).__init__([prog, filename], run_concurrent=True)
@PiglitBaseTest.command.getter
def command(self):
""" Add -auto to the test command """
return self._command + ['-auto']
-
-
-class ShaderTestParserException(Exception):
- """ An excpetion to be raised for errors in the ShaderTest parser """
- pass
diff --git a/framework/tests/shader_test_tests.py b/framework/tests/shader_test_tests.py
index 0ed5d80..1c10385 100644
--- a/framework/tests/shader_test_tests.py
+++ b/framework/tests/shader_test_tests.py
@@ -25,6 +25,7 @@ import os
import nose.tools as nt
+from framework import exceptions
import framework.test as testm
import framework.tests.utils as utils
@@ -39,7 +40,7 @@ def test_parse_gl_test_no_decimal():
data = ('[require]\n'
'GL = 2\n')
with utils.tempfile(data) as temp:
- with nt.assert_raises(testm.ShaderTestParserException) as exc:
+ with nt.assert_raises(exceptions.PiglitFatalError) as exc:
testm.ShaderTest(temp)
nt.assert_equal(exc.exception, "No GL version set",
msg="A GL version was passed without a decimal, "
--
2.4.0
More information about the Piglit
mailing list