﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	launchpad_bug
1303	allow running Tahoe correctly via other commands such as coverage	davidsarah		"Normally, the command to use [http://nedbatchelder.com/code/coverage/ coverage] to obtain coverage information for another program such as Tahoe would be:
{{{
coverage run <coverage-options> bin/tahoe <tahoe-options>
}}}

For example, with the fix to #1296, you could get branch coverage for the Tahoe test suite with
{{{
coverage run --branch bin/tahoe debug trial
}}}

However, this does not work, for three reasons:
* on Windows, the Unicode arguments hack implemented in [source:src/allmydata/windows/fixups.py] undoes the modification to {{{sys.argv}}} performed by coverage before it runs {{{bin/tahoe}}}. This causes Tahoe to act as though the command line were {{{bin/tahoe run --branch bin/tahoe debug trial}}}.
* the actual Tahoe process is a subprocess of {{{bin/tahoe}}}, but coverage will only obtain coverage information for the {{{bin/tahoe}}} script itself.
* if we tried to work around the previous point by using (on Unix) {{{coverage run --branch support/bin/tahoe debug trial}}}, we wouldn't be setting PYTHONPATH correctly.

The attached patch makes, for example:
{{{
bin/tahoe @coverage run --branch @tahoe debug trial
}}}
do the right thing. (""{{{@tahoe}}}"" will be replaced by the full path to the support script.)

It is more general than just running coverage; you can specify an arbitrary command. For example, to specify the python -3 option (warning about Python 3 incompatibilities):
{{{
bin/tahoe @python -3 @tahoe <command>
}}}

(Again, {{{python -3 bin/tahoe <command>}}} would not work because it would run only the {{{bin/tahoe}}} script with -3.)

Between [source:bin/tahoe-script.template] and [source:src/allmydata/windows/fixups.py], we actually end up having less code with this patch, because it uses a simpler way of deciding which suffix of the arguments to retain."	defect	new	major	soon	code-frontend-cli	1.8.1		trial coverage review-needed		
