[Piglit] [Patch v2 09/18] exectest.py: Change the order of environment variable loading

Dylan Baker baker.dylan.c at gmail.com
Mon Jul 28 15:35:18 PDT 2014


This patch changes piglit such that it loads first from the global
environment, then it loads global test options (some of which are passed
as command line arguments, like -p/--platform), and finally any test
specific variables.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/exectest.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/framework/exectest.py b/framework/exectest.py
index b4fb341..27b98ef 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -221,13 +221,23 @@ class Test(object):
         executable isn't found it sets the result to skip.
 
         """
-        # Set the environment for the tests. Use the default settings created
-        # in the Options constructor first, then use any user defined
-        # variables, finally, use any variables set for the test in the test
-        # profile
-        fullenv = self.OPTS.env.copy()
-        for key, value in itertools.chain(self.env.iteritems(),
-                                          os.environ.iteritems()):
+        # Setup the environment for the test. Environment variables are taken
+        # from the following sources, listed in order of increasing precedence:
+        #
+        #   1. This process's current environment.
+        #   2. Global test options. (Some of these are command line options to
+        #      Piglit's runner script).
+        #   3. Per-test environment variables set in all.py.
+        #
+        # Piglit chooses this order because Unix tradition dictates that
+        # command line options (2) override environment variables (1); and
+        # Piglit considers environment variables set in all.py (3) to be test
+        # requirements.
+        #
+        fullenv = dict()
+        for key, value in itertools.chain(os.environ.iteritems(),
+                                          self.OPTS.env.iteritems(),
+                                          self.env.iteritems()):
             fullenv[key] = str(value)
 
         try:
-- 
2.0.2



More information about the Piglit mailing list