[conduit: 60/138] Add some control over which tests are run
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 60/138] Add some control over which tests are run
- Date: Thu, 21 May 2009 03:31:58 -0400 (EDT)
commit 591b61e977f5a133772a5381f8ea093f5e8fd619
Author: John Carr <john carr unrouted co uk>
Date: Fri May 1 01:49:39 2009 -0700
Add some control over which tests are run
---
test/soup/__init__.py | 22 +++++++++++++++++++++-
test/soup/soup | 7 ++++---
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/test/soup/__init__.py b/test/soup/__init__.py
index 782f28c..4a14d18 100644
--- a/test/soup/__init__.py
+++ b/test/soup/__init__.py
@@ -183,6 +183,10 @@ Online = _Online()
class TestLoader(unittest.TestLoader):
+ def __init__(self, include=None, exclude=None):
+ self.include = include or []
+ self.exclude = exclude or []
+
def _flatten(self, tests):
if isinstance(tests, unittest.TestSuite):
for test in tests:
@@ -192,8 +196,24 @@ class TestLoader(unittest.TestLoader):
yield tests
def loadTestsFromModule(self, module):
- return self._flatten(super(TestLoader, self).loadTestsFromModule(module))
+ for test in self._flatten(super(TestLoader, self).loadTestsFromModule(module)):
+ if len(self.include) > 0:
+ is_included = False
+ for i in self.include:
+ if i in test.name():
+ is_included = True
+ if not is_included:
+ continue
+ if len(self.exclude) > 0:
+ is_excluded = False
+ for x in self.exclude:
+ if x in test.name():
+ is_excluded = True
+ if is_excluded:
+ continue
+ yield test
def loadTestsFromMain(self):
""" Load all tests that can be found starting from __main__ """
return self.loadTestsFromModule(__import__('__main__'))
+
diff --git a/test/soup/soup b/test/soup/soup
index b087fd0..ddf6c6d 100755
--- a/test/soup/soup
+++ b/test/soup/soup
@@ -46,7 +46,7 @@ if __name__ == "__main__":
parser = optparse.OptionParser(usage="usage: %prog [options] arg1 arg2")
# Options about which tests are run
- parser.add_option("-x", "--exclude", dest="exclude",
+ parser.add_option("-x", "--exclude", action="append", type="string", dest="exclude",
help="Exclude patterns matching PATTERN", metavar="PATTERN")
# Options about how the tests are run
@@ -64,13 +64,14 @@ if __name__ == "__main__":
help="Run the tests")
# Set parse defaults
- parser.set_defaults(mode="execute", randomize=False, verbose=False, coverage=False)
+ parser.set_defaults(mode="execute", randomize=False, verbose=False, coverage=False,
+ exclude=[])
# And parse..
opts, args = parser.parse_args()
# Figure out which tests to run
- tests = soup.TestLoader().loadTestsFromMain()
+ tests = soup.TestLoader(include=args, exclude=opts.exclude).loadTestsFromMain()
if opts.randomize:
import random
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]