[Piglit] [PATCH 2/7] python: move TESTS_DIR and GENERATED_TESTS_DIR into shared module

Dylan Baker baker.dylan.c at gmail.com
Mon Jan 12 00:22:27 PST 2015


These are needed in cl.py to make running out of tree possible.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 tests/all.py                  | 13 +------------
 tests/py_modules/__init__.py  |  0
 tests/py_modules/constants.py | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 12 deletions(-)
 create mode 100644 tests/py_modules/__init__.py
 create mode 100644 tests/py_modules/constants.py

diff --git a/tests/all.py b/tests/all.py
index 4b51a84..55e834e 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -14,19 +14,8 @@ from framework.profile import TestProfile
 from framework.test import (PiglitGLTest, GleanTest,
                             add_glsl_parser_test, import_glsl_parser_tests,
                             add_shader_test_dir)
+from py_modules.constants import TESTS_DIR, GENERATED_TESTS_DIR
 
-# Path to tests dir, correct even when not running from the top directory.
-TESTS_DIR = os.path.dirname(__file__)
-if sys.platform == "cygwin":
-    # convert the path to DOS style so it's parsable by shader_runner, etc.
-    TESTS_DIR = subprocess.check_output(['cygpath', '-d', TESTS_DIR]).rstrip()
-
-# Find the generated_tests directory, by looking either in
-# $PIGLIT_BUILD_DIR (if that environment variable exists) or in the
-# parent directory of the directory containing this file.
-GENERATED_TESTS_DIR = os.path.normpath(os.path.join(
-    os.environ.get('PIGLIT_BUILD_DIR', os.path.join(TESTS_DIR, '..')),
-    'generated_tests'))
 
 def add_single_param_test_set(group, name, *params):
     for param in params:
diff --git a/tests/py_modules/__init__.py b/tests/py_modules/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/py_modules/constants.py b/tests/py_modules/constants.py
new file mode 100644
index 0000000..7c54e4d
--- /dev/null
+++ b/tests/py_modules/constants.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2015 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Shared constants for test modules."""
+
+import os
+import sys
+import subprocess
+
+TESTS_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+GENERATED_TESTS_DIR = os.path.abspath(
+    os.path.join(TESTS_DIR, '..', 'generated_tests'))
+
+# If on cygwin convert to a dos style path
+if sys.platform == 'cygwin':
+    def dosify(p):
+        return subprocess.check_output(['cygpath', '-d', p]).rstrip()
+
+    TESTS_DIR = dosify(TESTS_DIR)
+    GENERATED_TESTS_DIR = dosify(GENERATED_TESTS_DIR)
-- 
2.2.1



More information about the Piglit mailing list