Changeset 7a887871 in trunk


Ignore:
Timestamp:
2011-01-18T20:46:59Z (14 years ago)
Author:
david-sarah <david-sarah@…>
Branches:
master
Children:
420aadd
Parents:
fc98ade
Message:

src/allmydata/scripts/debug.py: add 'tahoe debug trial' command (rebased for trunk). refs #1296

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/scripts/debug.py

    rfc98ade r7a887871  
    22# do not import any allmydata modules at this level. Do that from inside
    33# individual functions instead.
    4 import struct, time, os
     4import struct, time, os, sys
    55from twisted.python import usage, failure
    66from twisted.internet import defer
     7from twisted.scripts import trial as twisted_trial
    78
    89
     
    785786
    786787
     788DEFAULT_TESTSUITE = 'allmydata'
     789
     790class TrialOptions(twisted_trial.Options):
     791    def getSynopsis(self):
     792        return "Usage: tahoe debug trial [options] [[file|package|module|TestCase|testmethod]...]"
     793
     794    def parseOptions(self, all_subargs, *a, **kw):
     795        self.trial_args = list(all_subargs)
     796        return twisted_trial.Options.parseOptions(self, all_subargs, *a, **kw)
     797
     798    def parseArgs(self, *nonoption_args):
     799        if not nonoption_args:
     800            self.trial_args.append(DEFAULT_TESTSUITE)
     801
     802    def getUsage(self, width=None):
     803        t = twisted_trial.Options.getUsage(self, width)
     804        t += """
     805The 'tahoe debug trial' command uses the correct imports for this instance of
     806Tahoe-LAFS. The default test suite is '%s'.
     807""" % (DEFAULT_TESTSUITE,)
     808        return t
     809
     810def trial(config):
     811    sys.argv = ['trial'] + config.trial_args
     812
     813    # This does not return.
     814    twisted_trial.run()
     815
     816
    787817class DebugCommand(usage.Options):
    788818    subCommands = [
     
    794824        ["corrupt-share", None, CorruptShareOptions, "Corrupt a share by flipping a bit."],
    795825        ["repl", None, ReplOptions, "Open a Python interpreter."],
     826        ["trial", None, TrialOptions, "Run tests using Twisted Trial with the right imports."],
    796827        ]
    797828    def postOptions(self):
     
    810841    tahoe debug corrupt-share   Corrupt a share by flipping a bit.
    811842    tahoe debug repl            Open a Python interpreter.
     843    tahoe debug trial           Run tests using Twisted Trial with the right imports.
    812844
    813845Please run e.g. 'tahoe debug dump-share --help' for more details on each
     
    823855    "corrupt-share": corrupt_share,
    824856    "repl": repl,
     857    "trial": trial,
    825858    }
    826859
Note: See TracChangeset for help on using the changeset viewer.