From: david-sarah Date: Wed, 19 Jan 2011 05:11:37 +0000 (-0800) Subject: Add support to bin/tahoe for invoking a runner command prefixed with @, with the... X-Git-Tag: allmydata-tahoe-1.8.2b1~37 X-Git-Url: https://git.rkrishnan.org/vdrive/%5B%5E?a=commitdiff_plain;h=3798d9946e1f62cc7b9b83c641f6f0eb21864a2c;p=tahoe-lafs%2Ftahoe-lafs.git Add support to bin/tahoe for invoking a runner command prefixed with @, with the Tahoe libraries on the PYTHONPATH. This is documented in 'tahoe debug --help'. --- diff --git a/bin/tahoe-script.template b/bin/tahoe-script.template index 10c8a006..ec9f148b 100644 --- a/bin/tahoe-script.template +++ b/bin/tahoe-script.template @@ -95,7 +95,22 @@ when you run "python setup.py install" (perhaps as "%s"). ''' % (script, perhaps_installed_tahoe) sys.exit(1) -command = prefix + [script] + args +# Support indirection via another "runner" script (e.g. coverage). +# For example: bin/tahoe @RUNNER RUNNER_ARGS @tahoe TAHOE_ARGS + +if len(args) >= 1 and args[0].startswith('@'): + runner = args[0][1:] + if runner.endswith('.py') or runner.endswith('.pyscript'): + prefix = [sys.executable] + else: + prefix = [] + + def _subst(a): + if a == '@tahoe': return script + return a + command = prefix + [runner] + map(_subst, args[1:]) +else: + command = prefix + [script] + args try: res = subprocess.call(command, env=os.environ) diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py index 8073fe78..ac9b28a5 100644 --- a/src/allmydata/scripts/debug.py +++ b/src/allmydata/scripts/debug.py @@ -846,7 +846,22 @@ Subcommands: Please run e.g. 'tahoe debug dump-share --help' for more details on each subcommand. -""" + +Another debugging feature is that bin%stahoe allows executing an arbitrary +"runner" command (typically an installed Python script, such as 'coverage'), +with the Tahoe libraries on the PYTHONPATH. The runner command name is +prefixed with '@', and any occurrences of '@tahoe' in its arguments are +replaced by the full path to the tahoe script. + +For example, if 'coverage' is installed and on the PATH, you can use: + + bin%stahoe @coverage run --branch @tahoe debug trial + +to get branch coverage for the Tahoe test suite. Or, to run python with +the -3 option that warns about Python 3 incompatibilities: + + bin%stahoe @python -3 @tahoe command [options] +""" % (os.sep, os.sep, os.sep) return t subDispatch = {