From 3564031bf220ed784fd83b9fc6af7cc0ddf0ccf2 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Sat, 24 Apr 2010 18:53:25 +0000 Subject: [PATCH] Simplify how k5test scripts get run by importing runenv by pathname (using the imp module) instead of by module name. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23933 dc483132-0cff-0310-8789-dd5450dbe970 --- src/config/pre.in | 4 ++-- src/util/k5test.py | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/config/pre.in b/src/config/pre.in index a4f56896e..d2cad1cd0 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -244,8 +244,8 @@ host=@krb5_cv_host@ DEJAFLAGS = --debug --srcdir $(srcdir) --host $(host) RUNTEST = runtest $(DEJAFLAGS) -RUNPYTEST = PYTHONPATH=$(BUILDTOP):$(top_srcdir)/util \ - VALGRIND="$(VALGRIND)" $(PYTHON) +RUNPYTEST = PYTHONPATH=$(top_srcdir)/util VALGRIND="$(VALGRIND)" \ + $(PYTHON) START_SERVERS = $(STESTDIR)/scripts/start_servers $(TEST_SERVER) $(TEST_PATH) START_SERVERS_LOCAL = $(STESTDIR)/scripts/start_servers_local diff --git a/src/util/k5test.py b/src/util/k5test.py index 74768de9a..9ac1fc845 100644 --- a/src/util/k5test.py +++ b/src/util/k5test.py @@ -307,6 +307,7 @@ import socket import string import subprocess import sys +import imp # Used when most things go wrong (other than programming errors) so # that the user sees an error message rather than a Python traceback, @@ -466,15 +467,25 @@ def _match_cmdnum(cmdnum, ind): # Return an environment suitable for running programs in the build # tree. It is safe to modify the result. def _build_env(): - global buildtop + global buildtop, _runenv env = os.environ.copy() - for (k, v) in runenv.env.iteritems(): + for (k, v) in _runenv.iteritems(): if v.find('./') == 0: env[k] = os.path.join(buildtop, v) else: env[k] = v return env + +def _import_runenv(): + global buildtop + runenv_py = os.path.join(buildtop, 'runenv.py') + if not os.path.exists(runenv_py): + fail('You must run "make fake-install" in %s first.' % buildtop) + module = imp.load_source('runenv', runenv_py) + return module.env + + # Merge the nested dictionaries cfg1 and cfg2 into a new dictionary. # cfg1 or cfg2 may be None, in which case the other is returned. If # cfg2 contains keys mapped to None, the corresponding keys will be @@ -1018,15 +1029,10 @@ _cmd_index = 1 buildtop = _find_buildtop() srctop = _find_srctop() plugins = _find_plugins() +_runenv = _import_runenv() hostname = socket.getfqdn() null_input = open(os.devnull, 'r') -# runenv.py is built in the top level by "make fake-install". Import -# it now (rather than at the beginning of the file) so that we get a -# friendly error message from _find_plugins() if "make fake-install" -# has not been run. -import runenv - krb5kdc = os.path.join(buildtop, 'kdc', 'krb5kdc') kadmind = os.path.join(buildtop, 'kadmin', 'server', 'kadmind') kadmin = os.path.join(buildtop, 'kadmin', 'cli', 'kadmin') -- 2.26.2