allow running Tahoe correctly via other commands such as coverage #1303

Closed
opened 2011-01-13 04:20:49 +00:00 by davidsarah · 8 comments
davidsarah commented 2011-01-13 04:20:49 +00:00
Owner

Normally, the command to use 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.

Normally, the command to use [coverage](http://nedbatchelder.com/code/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.
tahoe-lafs added the
code-frontend-cli
major
defect
1.8.1
labels 2011-01-13 04:20:49 +00:00
tahoe-lafs added this to the undecided milestone 2011-01-13 04:20:49 +00:00
davidsarah commented 2011-01-13 04:24:01 +00:00
Author
Owner

Attachment bin-tahoe-runner-support.darcs.patch (18501 bytes) added

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'.

**Attachment** bin-tahoe-runner-support.darcs.patch (18501 bytes) added 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'.
tahoe-lafs modified the milestone from undecided to soon 2011-01-13 04:29:39 +00:00
david-sarah@jacaranda.org commented 2011-01-19 05:40:51 +00:00
Author
Owner

In changeset:93c1909847e9dc44:

bin/tahoe-script.template, src/windows/fixups.py: simplify the method of stripping initial arguments in sys.argv on Windows. This helps with bb-freeze and running tahoe via 'coverage'. Also includes some wording changes and minor refactoring of bin/tahoe-script.template. refs #585, #1303
In changeset:93c1909847e9dc44: ``` bin/tahoe-script.template, src/windows/fixups.py: simplify the method of stripping initial arguments in sys.argv on Windows. This helps with bb-freeze and running tahoe via 'coverage'. Also includes some wording changes and minor refactoring of bin/tahoe-script.template. refs #585, #1303 ```
zooko modified the milestone from soon to 1.8.2 2011-01-19 05:48:27 +00:00
davidsarah commented 2011-01-19 05:55:50 +00:00
Author
Owner

Attachment bin-tahoe-runner-support.darcs.2.patch (21206 bytes) added

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'.

**Attachment** bin-tahoe-runner-support.darcs.2.patch (21206 bytes) added 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'.

I reviewed changeset:93c1909847e9dc44 and it looks good to me.

I reviewed changeset:93c1909847e9dc44 and it looks good to me.

Oh whoops, I reviewed changeset:93c1909847e9dc44 but didn't realize I needed to review bin-tahoe-runner-support.darcs.2.patch as well before setting this from review-needed to reviewed.

Oh whoops, I reviewed changeset:93c1909847e9dc44 but didn't realize I needed to review [bin-tahoe-runner-support.darcs.2.patch](/tahoe-lafs/trac-2024-07-25/attachments/000078ac-3fc8-63d5-ebe3-6f85f10377cc) as well before setting this from `review-needed` to `reviewed`.

Okay, bin-tahoe-runner-support.darcs.2.patch looks good to me!

Okay, [bin-tahoe-runner-support.darcs.2.patch](/tahoe-lafs/trac-2024-07-25/attachments/000078ac-3fc8-63d5-ebe3-6f85f10377cc) looks good to me!
zooko removed their assignment 2011-01-19 07:31:35 +00:00
warner was assigned by zooko 2011-01-19 07:31:35 +00:00

David-Sarah is going to merge and push into trunk.

David-Sarah is going to merge and push into trunk.
davidsarah commented 2011-01-20 20:28:05 +00:00
Author
Owner

Applied in changeset:3798d9946e1f62cc.

Applied in changeset:3798d9946e1f62cc.
tahoe-lafs added the
fixed
label 2011-01-20 20:28:05 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: tahoe-lafs/trac-2024-07-25#1303
No description provided.