Move option handling into samba.tests.subunitrun.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 2 Nov 2014 04:17:39 +0000 (21:17 -0700)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 22 Nov 2014 01:23:10 +0000 (02:23 +0100)
Change-Id: I65a73b74854af636413f4f284147f3bcf28b6f82
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/subunitrun.py
source4/dsdb/tests/python/dirsync.py
source4/scripting/bin/subunitrun
source4/selftest/tests.py

index abb98813dbf94ff758d4356d90eeb22d049739a9..d45467607e65b3910e873443b0478c46dd1964e5 100644 (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())
index a480518790c4da8c892a9577dd43de8ed1f510bb..e6c5bbab641fa7ab38a28b18d76c51657069396b 100755 (executable)
@@ -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)
index 48b507a7b41cf75731418adde356c64b0215e81f..99d53196eea5114313719c217d3cd4ca1bdba3ae 100755 (executable)
 # 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)
index 910fdbb8762b4f3c68e61c0420a59283ebff2cda..9feb9ad99bb4859e7ba1d7822dc77f9442b6e17b 100755 (executable)
@@ -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'])