mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
Move option parsing to samba.tests.subunitrun.
Change-Id: I2939c1b6ebb9739530efa9bc4667668cff7a7aeb Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
ed4c07b34b
commit
24035a6b3e
@ -28,18 +28,15 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import sys
|
||||
|
||||
# make sure the script dies immediately when hitting control-C,
|
||||
# rather than raising KeyboardInterrupt. As we do all database
|
||||
# operations using transactions, this is safe.
|
||||
import signal
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
|
||||
# Find right directory when running from source tree
|
||||
sys.path.insert(0, "bin/python")
|
||||
|
||||
import optparse
|
||||
import samba
|
||||
import sys
|
||||
samba.ensure_external_module("mimeparse", "mimeparse")
|
||||
samba.ensure_external_module("extras", "extras")
|
||||
samba.ensure_external_module("testtools", "testtools")
|
||||
@ -47,13 +44,27 @@ samba.ensure_external_module("subunit", "subunit/python")
|
||||
import subunit.run
|
||||
|
||||
try:
|
||||
from subunit.run import TestProgram
|
||||
from subunit.run import TestProgram as BaseTestProgram
|
||||
except ImportError:
|
||||
from unittest import TestProgram
|
||||
from unittest import TestProgram as BaseTestProgram
|
||||
|
||||
|
||||
class TestProgram(TestProgram):
|
||||
class SubunitOptions(optparse.OptionGroup):
|
||||
"""Command line options for subunit test runners."""
|
||||
|
||||
def __init__(self, parser):
|
||||
optparse.OptionGroup.__init__(self, parser, "Subunit Options")
|
||||
self.add_option('-l', '--list', dest='listtests', default=False,
|
||||
help='List tests rather than running them.',
|
||||
action="store_true")
|
||||
self.add_option('--load-list', dest='load_list', default=None,
|
||||
help='Specify a filename containing the test ids to use.')
|
||||
|
||||
|
||||
class TestProgram(BaseTestProgram):
|
||||
|
||||
def __init__(self, module=None, argv=None):
|
||||
if argv is None:
|
||||
argv = [sys.argv[0]]
|
||||
super(TestProgram, self).__init__(module=module, argv=argv,
|
||||
testRunner=subunit.run.SubunitTestRunner())
|
||||
|
@ -702,4 +702,4 @@ if getattr(opts, 'load_list', None):
|
||||
args.insert(0, "--load-list=%s" % opts.load_list)
|
||||
|
||||
|
||||
TestProgram(module=__name__, argv=[sys.argv[0]] + args)
|
||||
TestProgram(module=__name__)
|
||||
|
@ -39,7 +39,7 @@ sys.path.insert(0, "bin/python")
|
||||
|
||||
import optparse
|
||||
import samba
|
||||
from samba.tests.subunitrun import TestProgram
|
||||
from samba.tests.subunitrun import TestProgram, SubunitOptions
|
||||
|
||||
import samba.getopt as options
|
||||
import samba.tests
|
||||
@ -71,8 +71,10 @@ parser = optparse.OptionParser(usage=usage, description=description)
|
||||
parser.format_description = format_description
|
||||
credopts = options.CredentialsOptions(parser)
|
||||
sambaopts = options.SambaOptions(parser)
|
||||
subunitopts = SubunitOptions(parser)
|
||||
parser.add_option_group(credopts)
|
||||
parser.add_option_group(sambaopts)
|
||||
parser.add_option_group(subunitopts)
|
||||
|
||||
opts, args = parser.parse_args()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user