summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-12-25 13:46:35 +0100
committerLars Wirzenius <liw@liw.fi>2015-12-25 13:49:37 +0100
commit0b12484dc9c100d76908a0c927b34374cbaec534 (patch)
tree89c5d35d8d01b63755521374ff83a2415f646395
parent943d7cce260ab28a24741d043101db8d31266bad (diff)
downloadcmdtest-0b12484dc9c100d76908a0c927b34374cbaec534.tar.gz
Add --cd-datadir setting
-rw-r--r--NEWS4
-rwxr-xr-xyarn12
2 files changed, 15 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index e01387b..56e3bcf 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ Version 0.19, released UNRELEASED
This can be used to use Python instead of sh:
`--shell=/usr/bin/python2 --shell-arg=''`.
+* Yarn now supports the `--cd-datadir` setting to have each step run
+ in `DATADIR` instead of `SRCDIR`. The default remains `SRCDIR`, but
+ at some point in the future, the default will probably change.
+
Version 0.18, released 2015-11-06
---------------------------------
diff --git a/yarn b/yarn
index c6e32cc..0782a8f 100755
--- a/yarn
+++ b/yarn
@@ -100,6 +100,11 @@ class YarnRunner(cliapp.Application):
metavar='ARG',
default=['-xeu'])
+ self.settings.boolean(
+ ['cd-datadir'],
+ 'change to DATADIR when running commands',
+ default=False)
+
def stdout(self, msg):
self.output.write(msg)
self.output.flush()
@@ -448,6 +453,11 @@ class YarnRunner(cliapp.Application):
for i, match in enumerate(m.groups('')):
env['MATCH_%d' % (i+1)] = match
+ if self.settings['cd-datadir']:
+ cwd = datadir
+ else:
+ cwd = '.'
+
fd, shell_script = tempfile.mkstemp()
os.close(fd)
with open(shell_script, 'w') as f:
@@ -460,7 +470,7 @@ class YarnRunner(cliapp.Application):
logging.warning('shell_args: %r', shell_args)
logging.warning('shell_script: %r', shell_script)
exit, stdout, stderr = cliapp.runcmd_unchecked(
- [shell] + shell_args + [shell_script], env=env)
+ [shell] + shell_args + [shell_script], env=env, cwd=cwd)
os.remove(shell_script)
logging.debug('Exit code: %d' % exit)