Commit a0bdcd9d authored by Jérome Perrin's avatar Jérome Perrin

make --run_only accept regular expressions.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17471 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c6c30a8b
#!/usr/bin/python2.4 #!/usr/bin/python2.4
import os import os
import sys import sys
import re
import getopt import getopt
import unittest import unittest
...@@ -54,7 +55,8 @@ Options: ...@@ -54,7 +55,8 @@ Options:
catalog storage). catalog storage).
--run_only=STRING --run_only=STRING
Run only specified test methods delimited with Run only specified test methods delimited with
commas (e.g. testFoo,testBar). commas (e.g. testFoo,testBar). This can be regular
expressions.
""" """
def getUnitTestFile(): def getUnitTestFile():
...@@ -253,13 +255,15 @@ def runUnitTestList(test_list): ...@@ -253,13 +255,15 @@ def runUnitTestList(test_list):
# Hack the profiler to run only specified test methods. # Hack the profiler to run only specified test methods.
run_only = os.environ.get('run_only') run_only = os.environ.get('run_only')
if run_only: if run_only and not save:
test_method_list = run_only.split(',') test_method_list = run_only.split(',')
from Testing.ZopeTestCase import profiler from Testing.ZopeTestCase import profiler
run_orig = profiler.Profiled.__call__ run_orig = profiler.Profiled.__call__
def run(self, *args, **kw): def run(self, *args, **kw):
if self.id().rsplit('.', 1)[-1] in test_method_list: test_method_name = self.id().rsplit('.', 1)[-1]
return run_orig(self, *args, **kw) for valid_test_method_name_re in test_method_list:
if re.match(valid_test_method_name_re, test_method_name):
return run_orig(self, *args, **kw)
profiler.Profiled.__call__ = run profiler.Profiled.__call__ = run
# change current directory to the test home, to create zLOG.log in this dir. # change current directory to the test home, to create zLOG.log in this dir.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment