summaryrefslogtreecommitdiff
path: root/source4/scripting/bin/subunitrun
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/bin/subunitrun')
-rwxr-xr-xsource4/scripting/bin/subunitrun34
1 files changed, 20 insertions, 14 deletions
diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun
index 62717a78a9..bc7b42c610 100755
--- a/source4/scripting/bin/subunitrun
+++ b/source4/scripting/bin/subunitrun
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# Simple subunit testrunner for python
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
@@ -21,27 +21,33 @@ import sys
# Find right directory when running from source tree
sys.path.insert(0, "bin/python")
-sys.path.insert(1, "../lib/subunit/python")
-from subunit import SubunitTestRunner
-from unittest import TestProgram
import optparse
-import os
-from samba import param
+import samba
+samba.ensure_external_module("testtools", "testtools")
+samba.ensure_external_module("subunit", "subunit/python")
+from subunit.run import SubunitTestRunner
import samba.getopt as options
import samba.tests
+
parser = optparse.OptionParser("subunitrun [options] <tests>")
credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
-sambaopts = options.SambaOptions(parser)
-parser.add_option_group(sambaopts)
-parser.add_option_group(options.VersionOptions(parser))
-
-args = parser.parse_args()[1]
-
-samba.tests.cmdline_loadparm = sambaopts.get_loadparm()
-samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.cmdline_loadparm)
+try:
+ from subunit.run import TestProgram
+except ImportError:
+ from unittest import TestProgram
+else:
+ parser.add_option('-l', '--list', dest='listtests', default=False,
+ help='List tests rather than running them.',
+ action="store_true")
+
+opts, args = parser.parse_args()
+
+samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.env_loadparm())
+if getattr(opts, "listtests", False):
+ args.insert(0, "--list")
runner = SubunitTestRunner()
program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner)