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:
Brian Warner 2016-09-09 15:37:28 -07:00
parent ff82112b89
commit 8d9afdc27e
7 changed files with 9 additions and 154 deletions

View File

@ -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 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. 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 "``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. sharefile. This can be used to test the client-side verification/repair code.
Obviously, this command should not be used during normal operation. 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.

View File

@ -254,16 +254,6 @@ Describe all shares in node dirs.
Corrupt a share by flipping a bit. Corrupt a share by flipping a bit.
.RS .RS
.RE .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 .PP
Please run e.g.\ `tahoe debug dump-share --help' for more Please run e.g.\ `tahoe debug dump-share --help' for more
details on each subcommand. details on each subcommand.

View File

@ -23,8 +23,6 @@ class BaseOptions(usage.Options):
def __init__(self): def __init__(self):
super(BaseOptions, self).__init__() super(BaseOptions, self).__init__()
self.command_name = os.path.basename(sys.argv[0]) 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" # Only allow "tahoe --version", not e.g. "tahoe start --version"
def opt_version(self): def opt_version(self):

View File

@ -4,7 +4,6 @@
import struct, time, os, sys import struct, time, os, sys
from twisted.python import usage, failure from twisted.python import usage, failure
from twisted.internet import defer from twisted.internet import defer
from twisted.scripts import trial as twisted_trial
from foolscap.logging import cli as foolscap_cli from foolscap.logging import cli as foolscap_cli
from allmydata.scripts.common import BaseOptions from allmydata.scripts.common import BaseOptions
@ -943,48 +942,22 @@ def corrupt_share(options):
class ReplOptions(BaseOptions): class ReplOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe [global-options] debug repl" return "Usage: tahoe debug repl (OBSOLETE)"
def repl(options): def repl(options):
import code print >>options.stderr, "'tahoe debug repl' is obsolete. Please run 'python' in a virtualenv."
return code.interact() return 1
DEFAULT_TESTSUITE = 'allmydata' DEFAULT_TESTSUITE = 'allmydata'
class TrialOptions(twisted_trial.Options): class TrialOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe [global-options] debug trial [options] [[file|package|module|TestCase|testmethod]...]" return "Usage: tahoe debug trial (OBSOLETE)"
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)
def trial(config): def trial(config):
sys.argv = ['trial'] + config.trial_args print >>config.stderr, "'tahoe debug trial' is obsolete. Please run 'tox', or use 'trial' in a virtualenv."
return 1
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()
def fixOptionsClass( (subcmd, shortcut, OptionsClass, desc) ): def fixOptionsClass( (subcmd, shortcut, OptionsClass, desc) ):
class FixedOptionsClass(OptionsClass): class FixedOptionsClass(OptionsClass):
@ -1037,8 +1010,8 @@ class DebugCommand(BaseOptions):
["find-shares", None, FindSharesOptions, "Locate sharefiles in node dirs."], ["find-shares", None, FindSharesOptions, "Locate sharefiles in node dirs."],
["catalog-shares", None, CatalogSharesOptions, "Describe all shares in node dirs."], ["catalog-shares", None, CatalogSharesOptions, "Describe all shares in node dirs."],
["corrupt-share", None, CorruptShareOptions, "Corrupt a share by flipping a bit."], ["corrupt-share", None, CorruptShareOptions, "Corrupt a share by flipping a bit."],
["repl", None, ReplOptions, "Open a Python interpreter."], ["repl", None, ReplOptions, "OBSOLETE"],
["trial", None, TrialOptions, "Run tests using Twisted Trial with the right imports."], ["trial", None, TrialOptions, "OBSOLETE"],
["flogtool", None, FlogtoolOptions, "Utilities to access log files."], ["flogtool", None, FlogtoolOptions, "Utilities to access log files."],
] ]
def postOptions(self): def postOptions(self):
@ -1053,32 +1026,6 @@ class DebugCommand(BaseOptions):
Please run e.g. 'tahoe debug dump-share --help' for more details on each Please run e.g. 'tahoe debug dump-share --help' for more details on each
subcommand. 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 return t
subDispatch = { subDispatch = {

View File

@ -686,11 +686,6 @@ class Help(unittest.TestCase):
help = str(create_node.CreateIntroducerOptions()) help = str(create_node.CreateIntroducerOptions())
self.failUnlessIn("[options] NODEDIR", help) 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): def test_debug_flogtool(self):
options = debug.FlogtoolOptions() options = debug.FlogtoolOptions()
help = str(options) help = str(options)

View File

@ -2345,43 +2345,6 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
d.addCallback(_check_ls) d.addCallback(_check_ls)
return d 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=""): def _run_cli(self, argv, stdin=""):
#print "CLI:", argv #print "CLI:", argv
stdout, stderr = StringIO(), StringIO() stdout, stderr = StringIO(), StringIO()

View File

@ -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'))