mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 15:16:41 +00:00
CLI: remove 'debug trial', 'debug repl'
These are obsolete. Tests are run with 'tox', or by running 'trial allmydata' from a populated virtualenv. A populated virtualenv is also the right way to get a repl: just run 'python'. refs ticket:2735
This commit is contained in:
parent
ff82112b89
commit
8d9afdc27e
docs
src/allmydata
@ -610,14 +610,6 @@ into separate pieces. The most useful aspect of this command is to reveal the
|
||||
storage index for any given URI. This can be used to locate the share files
|
||||
that are holding the encoded+encrypted data for this file.
|
||||
|
||||
"``tahoe debug repl``" will launch an interactive Python interpreter in which
|
||||
the Tahoe-LAFS packages and modules are available on ``sys.path`` (e.g. by using
|
||||
'``import allmydata``'). This is most useful from a source tree: it simply sets
|
||||
the PYTHONPATH correctly and runs the Python executable.
|
||||
|
||||
"``tahoe debug corrupt-share SHAREFILE``" will flip a bit in the given
|
||||
sharefile. This can be used to test the client-side verification/repair code.
|
||||
Obviously, this command should not be used during normal operation.
|
||||
|
||||
"``tahoe debug trial [OPTIONS] [TESTSUITE]``" will run the tests specified by
|
||||
TESTSUITE (defaulting to the whole Tahoe test suite), using Twisted Trial.
|
||||
|
@ -254,16 +254,6 @@ Describe all shares in node dirs.
|
||||
Corrupt a share by flipping a bit.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]repl\f[]
|
||||
Open a Python interpreter.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]trial\f[]
|
||||
Run tests using Twisted Trial with the right imports.
|
||||
.RS
|
||||
.RE
|
||||
.PP
|
||||
Please run e.g.\ `tahoe debug dump-share --help' for more
|
||||
details on each subcommand.
|
||||
|
@ -23,8 +23,6 @@ class BaseOptions(usage.Options):
|
||||
def __init__(self):
|
||||
super(BaseOptions, self).__init__()
|
||||
self.command_name = os.path.basename(sys.argv[0])
|
||||
if self.command_name == 'trial':
|
||||
self.command_name = 'tahoe'
|
||||
|
||||
# Only allow "tahoe --version", not e.g. "tahoe start --version"
|
||||
def opt_version(self):
|
||||
|
@ -4,7 +4,6 @@
|
||||
import struct, time, os, sys
|
||||
from twisted.python import usage, failure
|
||||
from twisted.internet import defer
|
||||
from twisted.scripts import trial as twisted_trial
|
||||
from foolscap.logging import cli as foolscap_cli
|
||||
from allmydata.scripts.common import BaseOptions
|
||||
|
||||
@ -943,48 +942,22 @@ def corrupt_share(options):
|
||||
|
||||
class ReplOptions(BaseOptions):
|
||||
def getSynopsis(self):
|
||||
return "Usage: tahoe [global-options] debug repl"
|
||||
return "Usage: tahoe debug repl (OBSOLETE)"
|
||||
|
||||
def repl(options):
|
||||
import code
|
||||
return code.interact()
|
||||
print >>options.stderr, "'tahoe debug repl' is obsolete. Please run 'python' in a virtualenv."
|
||||
return 1
|
||||
|
||||
|
||||
DEFAULT_TESTSUITE = 'allmydata'
|
||||
|
||||
class TrialOptions(twisted_trial.Options):
|
||||
class TrialOptions(BaseOptions):
|
||||
def getSynopsis(self):
|
||||
return "Usage: tahoe [global-options] debug trial [options] [[file|package|module|TestCase|testmethod]...]"
|
||||
|
||||
def parseOptions(self, all_subargs, *a, **kw):
|
||||
self.trial_args = list(all_subargs)
|
||||
|
||||
# any output from the option parsing will be printed twice, but that's harmless
|
||||
return twisted_trial.Options.parseOptions(self, all_subargs, *a, **kw)
|
||||
|
||||
def parseArgs(self, *nonoption_args):
|
||||
if not nonoption_args:
|
||||
self.trial_args.append(DEFAULT_TESTSUITE)
|
||||
|
||||
longdesc = twisted_trial.Options.longdesc + "\n\n" + (
|
||||
"The 'tahoe debug trial' command uses the correct imports for this "
|
||||
"instance of Tahoe-LAFS. The default test suite is '%s'."
|
||||
% DEFAULT_TESTSUITE)
|
||||
return "Usage: tahoe debug trial (OBSOLETE)"
|
||||
|
||||
def trial(config):
|
||||
sys.argv = ['trial'] + config.trial_args
|
||||
|
||||
from allmydata._version import full_version
|
||||
if full_version.endswith("-dirty"):
|
||||
print >>sys.stderr
|
||||
print >>sys.stderr, "WARNING: the source tree has been modified since the last commit."
|
||||
print >>sys.stderr, "(It is usually preferable to commit, then test, then amend the commit(s)"
|
||||
print >>sys.stderr, "if the tests fail.)"
|
||||
print >>sys.stderr
|
||||
|
||||
# This does not return.
|
||||
twisted_trial.run()
|
||||
|
||||
print >>config.stderr, "'tahoe debug trial' is obsolete. Please run 'tox', or use 'trial' in a virtualenv."
|
||||
return 1
|
||||
|
||||
def fixOptionsClass( (subcmd, shortcut, OptionsClass, desc) ):
|
||||
class FixedOptionsClass(OptionsClass):
|
||||
@ -1037,8 +1010,8 @@ class DebugCommand(BaseOptions):
|
||||
["find-shares", None, FindSharesOptions, "Locate sharefiles in node dirs."],
|
||||
["catalog-shares", None, CatalogSharesOptions, "Describe all shares in node dirs."],
|
||||
["corrupt-share", None, CorruptShareOptions, "Corrupt a share by flipping a bit."],
|
||||
["repl", None, ReplOptions, "Open a Python interpreter."],
|
||||
["trial", None, TrialOptions, "Run tests using Twisted Trial with the right imports."],
|
||||
["repl", None, ReplOptions, "OBSOLETE"],
|
||||
["trial", None, TrialOptions, "OBSOLETE"],
|
||||
["flogtool", None, FlogtoolOptions, "Utilities to access log files."],
|
||||
]
|
||||
def postOptions(self):
|
||||
@ -1053,32 +1026,6 @@ class DebugCommand(BaseOptions):
|
||||
Please run e.g. 'tahoe debug dump-share --help' for more details on each
|
||||
subcommand.
|
||||
"""
|
||||
# See ticket #1441 for why we print different information when
|
||||
# run via /usr/bin/tahoe. Note that argv[0] is the full path.
|
||||
if sys.argv[0] == '/usr/bin/tahoe':
|
||||
t += """
|
||||
To get branch coverage for the Tahoe test suite (on the installed copy of
|
||||
Tahoe), install the 'python-coverage' package and then use:
|
||||
|
||||
python-coverage run --branch /usr/bin/tahoe debug trial
|
||||
"""
|
||||
else:
|
||||
t += """
|
||||
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 = {
|
||||
|
@ -686,11 +686,6 @@ class Help(unittest.TestCase):
|
||||
help = str(create_node.CreateIntroducerOptions())
|
||||
self.failUnlessIn("[options] NODEDIR", help)
|
||||
|
||||
def test_debug_trial(self):
|
||||
help = str(debug.TrialOptions())
|
||||
self.failUnlessIn(" [global-options] debug trial [options] [[file|package|module|TestCase|testmethod]...]", help)
|
||||
self.failUnlessInNormalized("The 'tahoe debug trial' command uses the correct imports", help)
|
||||
|
||||
def test_debug_flogtool(self):
|
||||
options = debug.FlogtoolOptions()
|
||||
help = str(options)
|
||||
|
@ -2345,43 +2345,6 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
d.addCallback(_check_ls)
|
||||
return d
|
||||
|
||||
def test_debug_trial(self):
|
||||
def _check_for_line(lines, result, test):
|
||||
for l in lines:
|
||||
if result in l and test in l:
|
||||
return
|
||||
self.fail("output (prefixed with '##') does not have a line containing both %r and %r:\n## %s"
|
||||
% (result, test, "\n## ".join(lines)))
|
||||
|
||||
def _check_for_outcome(lines, out, outcome):
|
||||
self.failUnlessIn(outcome, out, "output (prefixed with '##') does not contain %r:\n## %s"
|
||||
% (outcome, "\n## ".join(lines)))
|
||||
|
||||
d = self.run_bintahoe(['debug', 'trial', '--reporter=verbose',
|
||||
'allmydata.test.trialtest'])
|
||||
def _check_failure( (out, err, rc) ):
|
||||
self.failUnlessEqual(rc, 1)
|
||||
lines = out.split('\n')
|
||||
_check_for_line(lines, "[SKIPPED]", "test_skip")
|
||||
_check_for_line(lines, "[TODO]", "test_todo")
|
||||
_check_for_line(lines, "[FAIL]", "test_fail")
|
||||
_check_for_line(lines, "[ERROR]", "test_deferred_error")
|
||||
_check_for_line(lines, "[ERROR]", "test_error")
|
||||
_check_for_outcome(lines, out, "FAILED")
|
||||
d.addCallback(_check_failure)
|
||||
|
||||
# the --quiet argument regression-tests a problem in finding which arguments to pass to trial
|
||||
d.addCallback(lambda ign: self.run_bintahoe(['--quiet', 'debug', 'trial', '--reporter=verbose',
|
||||
'allmydata.test.trialtest.Success']))
|
||||
def _check_success( (out, err, rc) ):
|
||||
self.failUnlessEqual(rc, 0)
|
||||
lines = out.split('\n')
|
||||
_check_for_line(lines, "[SKIPPED]", "test_skip")
|
||||
_check_for_line(lines, "[TODO]", "test_todo")
|
||||
_check_for_outcome(lines, out, "PASSED")
|
||||
d.addCallback(_check_success)
|
||||
return d
|
||||
|
||||
def _run_cli(self, argv, stdin=""):
|
||||
#print "CLI:", argv
|
||||
stdout, stderr = StringIO(), StringIO()
|
||||
|
@ -1,30 +0,0 @@
|
||||
|
||||
# This is a dummy test suite that we can use to check that 'tahoe debug trial'
|
||||
# is working properly. Since the module name does not start with 'test_', it
|
||||
# will not be run by the main test suite.
|
||||
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import defer
|
||||
|
||||
|
||||
class Success(unittest.TestCase):
|
||||
def test_succeed(self):
|
||||
pass
|
||||
|
||||
def test_skip(self):
|
||||
raise unittest.SkipTest('skip')
|
||||
|
||||
def test_todo(self):
|
||||
self.fail('umm')
|
||||
test_todo.todo = 'never mind'
|
||||
|
||||
|
||||
class Failure(unittest.TestCase):
|
||||
def test_fail(self):
|
||||
self.fail('fail')
|
||||
|
||||
def test_error(self):
|
||||
raise AssertionError('clang')
|
||||
|
||||
def test_deferred_error(self):
|
||||
return defer.fail(AssertionError('screech'))
|
Loading…
Reference in New Issue
Block a user