diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2014-06-20 00:19:28 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2014-06-23 22:21:01 -0700 |
commit | 4f497a745daee5d71aebb4295659cf477298c3e9 (patch) | |
tree | e99779610999370be93f03beee01761343ac46e3 /piglit | |
parent | 053b716a22e528398744caf57a7dfc7be1066daf (diff) |
framework: Don't rely on os.environ so much
There are some problems with using os.environ, all of which are caused
shell child-variable relationships. Most of these problems are easy to
solve, since we don't actually need to have environment variables set
except during test execution, and that can be passed to Popen (or it's
helper wrappers). This gives us much better assurance that things are
happening in the way we expect.
v7: - use itertools.chain instead of nested iterations
- fix piglit.conf default case
- reorder environment overrides so that variables passed in by the
user (or exported) override the builtin values instead of
vice-versa
Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Diffstat (limited to 'piglit')
-rwxr-xr-x | piglit | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -36,25 +36,24 @@ import os.path as path import sys import argparse -# Setting PIGLIT_SOURCE_DIR (and by extension sys.path) is actually pretty -# complicated, since there are three seperate uses we need to detect: +# Setting sys.path is actually pretty complicated, since there are three +# seperate uses we need to detect: # 1) piglit is being run in the source directory, built in tree # 2) piglit is being run from the source directory outside of it, built in tree # 3) piglit has been built out of tree and installed, and is being run in or # out of the install directory +# Case one is the implicit case. In this event nothing needs to be set, it +# should "just work" (tm) + # It is critical that this block be run before importing anything from # framework (as there is no gaurantee that framework will be in python's path # before this blck is run) -# Case 1 -if path.exists('framework/exectest.py'): - os.environ['PIGLIT_SOURCE_DIR'] = path.abspath(path.curdir) -else: +if not path.exists('framework/exectest.py'): dirpath = path.dirname(path.abspath(__file__)) # Case 2 if path.exists(path.join(dirpath, 'framework/exectest.py')): - os.environ['PIGLIT_SOURCE_DIR'] = dirpath sys.path.append(dirpath) # Case 3 else: @@ -66,8 +65,6 @@ else: # piglits installed as piglit${the_date_of_install}, and we need to # detect that. install_path = path.abspath(path.join(dirpath, '..', 'lib', piglit)) - - os.environ['PIGLIT_SOURCE_DIR'] = install_path sys.path.append(install_path) import framework.programs.run as run |