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
import os
import sys
import re
import getopt
import unittest
......@@ -54,7 +55,8 @@ Options:
catalog storage).
--run_only=STRING
Run only specified test methods delimited with
commas (e.g. testFoo,testBar).
commas (e.g. testFoo,testBar). This can be regular
expressions.
"""
def getUnitTestFile():
......@@ -253,13 +255,15 @@ def runUnitTestList(test_list):
# Hack the profiler to run only specified test methods.
run_only = os.environ.get('run_only')
if run_only:
if run_only and not save:
test_method_list = run_only.split(',')
from Testing.ZopeTestCase import profiler
run_orig = profiler.Profiled.__call__
def run(self, *args, **kw):
if self.id().rsplit('.', 1)[-1] in test_method_list:
return run_orig(self, *args, **kw)
test_method_name = self.id().rsplit('.', 1)[-1]
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
# 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