summaryrefslogtreecommitdiff
path: root/yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-07-31 18:37:33 +0100
committerLars Wirzenius <liw@liw.fi>2013-07-31 18:37:33 +0100
commit8443dc250bb58091c435db2b29e2029c434d1750 (patch)
tree14f16c6ebf75b383c771f791e9fed0667315eb02 /yarn
parent3fb60d86c01ef3bc615d39e69ee0011aef906685 (diff)
downloadcmdtest-8443dc250bb58091c435db2b29e2029c434d1750.tar.gz
Set SRCDIR and clean environment
Diffstat (limited to 'yarn')
-rwxr-xr-xyarn28
1 files changed, 27 insertions, 1 deletions
diff --git a/yarn b/yarn
index 288e23b..6fbd63a 100755
--- a/yarn
+++ b/yarn
@@ -267,6 +267,31 @@ class YarnRunner(cliapp.Application):
return ok
+ def clean_env(self):
+ '''Return a clean environment for running tests.'''
+
+ whitelisted = [
+ 'TERM',
+ 'USER',
+ 'USERNAME',
+ 'PATH',
+ 'HOME',
+ 'LOGNAME',
+ ]
+
+ hardcoded = {
+ 'SHELL': '/bin/sh',
+ 'LC_ALL': 'C',
+ }
+
+ env = {}
+ for key in whitelisted:
+ if key in os.environ:
+ env[key] = os.environ[key]
+ for key in hardcoded:
+ env[key] = hardcoded[key]
+ return env
+
def run_step(self, datadir, scenario, step, shell_prelude, report_error):
self.info('Running step "%s %s"' % (step.what, step.text))
self.ts['step'] = step
@@ -274,8 +299,9 @@ class YarnRunner(cliapp.Application):
m = re.match(step.implementation.regexp, step.text)
assert m is not None
- env = os.environ.copy()
+ env = self.clean_env()
env['DATADIR'] = datadir
+ env['SRCDIR'] = os.getcwd()
for i, match in enumerate(m.groups('')):
env['MATCH_%d' % (i+1)] = match