[Piglit] [PATCH 1/2] glsl_parser_test_tests.py: make tests more robust

Dylan Baker baker.dylan.c at gmail.com
Mon Aug 3 14:53:02 PDT 2015


Rather than loading a file out of the tree (which might be moved,
deleted, etc.) create a temporary file and load that.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/tests/glsl_parser_test_tests.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/framework/tests/glsl_parser_test_tests.py b/framework/tests/glsl_parser_test_tests.py
index bb5c246..70910b7 100644
--- a/framework/tests/glsl_parser_test_tests.py
+++ b/framework/tests/glsl_parser_test_tests.py
@@ -22,6 +22,7 @@
 
 from __future__ import print_function, absolute_import
 import os
+import textwrap
 
 import nose.tools as nt
 
@@ -160,9 +161,17 @@ def test_empty_in_config():
 
 def test_glslparser_initializer():
     """test.glsl_parser_test.GLSLParserTest: clas initializes correctly"""
-    # TODO: use a tempfile and write a temporary test rather than rely on a
-    # real one
-    glsl.GLSLParserTest('tests/spec/glsl-es-1.00/compiler/version-macro.frag')
+    content = textwrap.dedent("""\
+        /*
+         * [config]
+         * expect_result: pass
+         * glsl_version: 1.10
+         * [end config]
+         */
+        """)
+
+    with utils.tempfile(content) as f:
+        glsl.GLSLParserTest(f)
 
 
 def check_config_to_command(config, result):
-- 
2.5.0



More information about the Piglit mailing list