1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

Move option handling into samba.tests.subunitrun.

Change-Id: I65a73b74854af636413f4f284147f3bcf28b6f82
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Jelmer Vernooij 2014-11-01 21:17:39 -07:00
parent 24035a6b3e
commit ee281c61d0
4 changed files with 21 additions and 20 deletions

View File

@ -63,8 +63,13 @@ class SubunitOptions(optparse.OptionGroup):
class TestProgram(BaseTestProgram):
def __init__(self, module=None, argv=None):
if argv is None:
argv = [sys.argv[0]]
def __init__(self, module=None, args=None, opts=None):
if args is None:
args = []
if getattr(opts, "listtests", False):
args.insert(0, "--list")
if getattr(opts, 'load_list', None):
args.insert(0, "--load-list=%s" % opts.load_list)
argv = [sys.argv[0]] + args
super(TestProgram, self).__init__(module=module, argv=argv,
testRunner=subunit.run.SubunitTestRunner())

View File

@ -2,7 +2,7 @@
#
# Unit tests for dirsync control
# Copyright (C) Matthieu Patou <mat@matws.net> 2011
#
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2014
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -22,7 +22,7 @@ import optparse
import sys
sys.path.insert(0, "bin/python")
import samba
from samba.tests.subunitrun import TestProgram
from samba.tests.subunitrun import TestProgram, SubunitOptions
import samba.getopt as options
import base64
@ -48,6 +48,8 @@ parser.add_option_group(options.VersionOptions(parser))
# use command line creds if available
credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
subunitopts = SubunitOptions(parser)
parser.add_option_group(subunitopts)
opts, args = parser.parse_args()
if len(args) < 1:
@ -693,13 +695,9 @@ class ExtendedDirsyncTests(SimpleDirsyncTests):
self.assertEqual(str(res[0].dn), "")
if getattr(opts, "listtests", False):
args.insert(0, "--list")
else:
if not getattr(opts, "listtests", False):
lp = sambaopts.get_loadparm()
samba.tests.cmdline_credentials = credopts.get_credentials(lp)
if getattr(opts, 'load_list', None):
args.insert(0, "--load-list=%s" % opts.load_list)
TestProgram(module=__name__)
TestProgram(module=__name__, opts=subunitopts)

View File

@ -10,18 +10,18 @@
# get e.g. credentials passed via command-line options to this
# script.
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2011
#
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2014
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
@ -78,10 +78,8 @@ parser.add_option_group(subunitopts)
opts, args = parser.parse_args()
if getattr(opts, "listtests", False):
args.insert(0, "--list")
else:
if not getattr(opts, "listtests", False):
lp = sambaopts.get_loadparm()
samba.tests.cmdline_credentials = credopts.get_credentials(lp)
TestProgram(module=None, argv=[sys.argv[0]] + args)
TestProgram(module=None, args=args, opts=subunitopts)

View File

@ -470,7 +470,7 @@ planoldpythontestsuite("dc", "dsdb_schema_info",
name="samba4.schemaInfo.python(dc)",
extra_args=['-U"$DOMAIN/$DC_USERNAME%$DC_PASSWORD"'])
plantestsuite("samba4.urgent_replication.python(dc)", "dc:local", [python, os.path.join(samba4srcdir, "dsdb/tests/python/urgent_replication.py"), '$PREFIX_ABS/dc/private/sam.ldb'])
plantestsuite("samba4.ldap.dirsync.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/dirsync.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])
plantestsuite_loadlist("samba4.ldap.dirsync.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/dirsync.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN', '$LOADLIST', '$LISTOPT'])
plantestsuite("samba4.ldap.sites.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/sites.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])
for env in ["dc", "fl2000dc", "fl2003dc", "fl2008r2dc"]:
plantestsuite("samba4.ldap_schema.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap_schema.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])