LDB:test-generic.sh - fix smaller/greater comparison tests
[mdw/samba.git] / source4 / scripting / bin / subunitrun
1 #!/usr/bin/env python
2
3 # Simple subunit testrunner for python
4
5 # NOTE: This is deprecated - Using the standard subunit runner is
6 # preferred - e.g. "python -m samba.subunit.run YOURMODULE".
7 #
8 # This wrapper will be removed once all tests can be run
9 # without it. At the moment there are various tests which still
10 # get e.g. credentials passed via command-line options to this
11 # script.
12
13 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2014
14 #
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 3 of the License, or
18 # (at your option) any later version.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
27 #
28
29 import sys
30
31 # make sure the script dies immediately when hitting control-C,
32 # rather than raising KeyboardInterrupt. As we do all database
33 # operations using transactions, this is safe.
34 import signal
35 signal.signal(signal.SIGINT, signal.SIG_DFL)
36
37 # Find right directory when running from source tree
38 sys.path.insert(0, "bin/python")
39
40 import optparse
41 import samba
42 from samba.tests.subunitrun import TestProgram, SubunitOptions
43
44 import samba.getopt as options
45 import samba.tests
46
47
48 usage = 'subunitrun [options] <tests>'
49 description = '''
50 This runs a Samba python test suite. The tests are typically located in
51 python/samba/tests/*.py
52
53 To run the tests from one of those modules, specify the test as
54 samba.tests.MODULE. For example, to run the tests in common.py:
55
56    subunitrun samba.tests.common
57
58 To list the tests in that module, use:
59
60    subunitrun -l samba.tests.common
61
62 NOTE: This script is deprecated in favor of "python -m subunit.run". Don't use
63 it unless it can be avoided.
64 '''
65
66 def format_description(formatter):
67     '''hack to prevent textwrap of the description'''
68     return description
69
70 parser = optparse.OptionParser(usage=usage, description=description)
71 parser.format_description = format_description
72 credopts = options.CredentialsOptions(parser)
73 sambaopts = options.SambaOptions(parser)
74 subunitopts = SubunitOptions(parser)
75 parser.add_option_group(credopts)
76 parser.add_option_group(sambaopts)
77 parser.add_option_group(subunitopts)
78
79 opts, args = parser.parse_args()
80
81 if not getattr(opts, "listtests", False):
82     lp = sambaopts.get_loadparm()
83     samba.tests.cmdline_credentials = credopts.get_credentials(lp)
84 if getattr(opts, 'load_list', None):
85     args.insert(0, "--load-list=%s" % opts.load_list)
86
87 TestProgram(module=None, args=args, opts=subunitopts)