From b196315222688e5d5cc78dc679d56ec3920b10ec Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sat, 2 Mar 2019 18:46:00 -0500 Subject: [PATCH] Change -x/-v to only affect top-level targets by default, not recursively. Because redo targets are nicely isolated (unlike make targets), you usually only want to debug one of them at a time. Using -x could be confusing, because you might end up with a dump of output from a dependency you're not interested in. Now, by default we'll disable -x when recursing into sub-targets, so you only see the trace from the targets you are actually trying to debug. To get recursive behaviour, specify -x twice, eg. -xx. Same idea with -v. --- docs/redo.md | 8 ++++++-- redo/builder.py | 6 +++++- redo/cmd_redo.py | 4 ++-- redo/env.py | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/redo.md b/docs/redo.md index 4a4024a..e053e28 100644 --- a/docs/redo.md +++ b/docs/redo.md @@ -62,7 +62,9 @@ option is *not* given and `--no-log` is used. to stderr as it reads them. Most shells will print the exact source line (eg. `echo $3`) and not the substituted value of variables (eg. `echo - mytarget.redo.tmp`). + mytarget.redo.tmp`). Normally this option applies only + to targets you specify on the command line. To recursively + enable verbose mode for sub targets, pass it twice (-vv). -x, --xtrace : pass the -x option to /bin/sh when executing scripts. @@ -70,7 +72,9 @@ option is *not* given and `--no-log` is used. commands are being executed. Most shells will print the substituted variables (eg. `echo mytarget.redo.tmp`) and not the original source line - (eg. `echo $3`). + (eg. `echo $3`). Normally this option applies only + to targets you specify on the command line. To recursively + enable xtrace mode for sub targets, pass it twice (-xx). -k, --keep-going : keep building as many targets as possible even if some diff --git a/redo/builder.py b/redo/builder.py index 9cfa479..f983c67 100644 --- a/redo/builder.py +++ b/redo/builder.py @@ -292,7 +292,7 @@ class _BuildJob(object): jobserver.start(self.t, jobfunc=subtask, donefunc=job_exited) def _subproc(self, dodir, basename, ext, argv): - """The function by jobserver.start to exec the build script. + """The function called by jobserver.start to exec the build script. This is run in the *child* process. """ @@ -306,6 +306,10 @@ class _BuildJob(object): os.environ['REDO_PWD'] = state.relpath(newp, env.v.STARTDIR) os.environ['REDO_TARGET'] = basename + ext os.environ['REDO_DEPTH'] = env.v.DEPTH + ' ' + if env.v.XTRACE == 1: + os.environ['REDO_XTRACE'] = '0' + if env.v.VERBOSE == 1: + os.environ['REDO_VERBOSE'] = '0' cycles.add(self.lock.fid) if dodir: os.chdir(dodir) diff --git a/redo/cmd_redo.py b/redo/cmd_redo.py index fd2cd50..15f5f64 100644 --- a/redo/cmd_redo.py +++ b/redo/cmd_redo.py @@ -53,9 +53,9 @@ def main(): if opt.debug: os.environ['REDO_DEBUG'] = str(opt.debug or 0) if opt.verbose: - os.environ['REDO_VERBOSE'] = '1' + os.environ['REDO_VERBOSE'] = str(opt.verbose) if opt.xtrace: - os.environ['REDO_XTRACE'] = '1' + os.environ['REDO_XTRACE'] = str(opt.xtrace) if opt.keep_going: os.environ['REDO_KEEP_GOING'] = '1' if opt.shuffle: diff --git a/redo/env.py b/redo/env.py index ca416d4..18861d4 100644 --- a/redo/env.py +++ b/redo/env.py @@ -32,8 +32,8 @@ class Env(object): self.DEBUG_LOCKS = _get_bool('REDO_DEBUG_LOCKS', '') self.DEBUG_PIDS = _get_bool('REDO_DEBUG_PIDS', '') self.LOCKS_BROKEN = _get_bool('REDO_LOCKS_BROKEN', '') - self.VERBOSE = _get_bool('REDO_VERBOSE', '') - self.XTRACE = _get_bool('REDO_XTRACE', '') + self.VERBOSE = _get_int('REDO_VERBOSE', '') + self.XTRACE = _get_int('REDO_XTRACE', '') self.KEEP_GOING = _get_bool('REDO_KEEP_GOING', '') self.LOG = _get_int('REDO_LOG', '1') self.LOG_INODE = _get('REDO_LOG_INODE', '')