mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
selftest: make filter-subunit much more efficient for large knownfail lists
By compiling the knownfail lists ahead of time we change a 20min test into a 90sec test. This could be improved further by combining this into a single regular expression, but this is enough for now. The 'reason' is thankfully not used. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15258 Pair-programmed-with: Joseph Sutton <josephsutton@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
5259926de7
commit
22128c718c
@ -236,7 +236,7 @@ class SubunitOps(TestProtocolClient, TestsuiteEnabledTestResult):
|
|||||||
|
|
||||||
|
|
||||||
def read_test_regexes(*names):
|
def read_test_regexes(*names):
|
||||||
ret = {}
|
ret = []
|
||||||
files = []
|
files = []
|
||||||
for name in names:
|
for name in names:
|
||||||
# if we are given a directory, we read all the files it contains
|
# if we are given a directory, we read all the files it contains
|
||||||
@ -256,20 +256,18 @@ def read_test_regexes(*names):
|
|||||||
continue
|
continue
|
||||||
if "#" in l:
|
if "#" in l:
|
||||||
(regex, reason) = l.split("#", 1)
|
(regex, reason) = l.split("#", 1)
|
||||||
ret[regex.strip()] = reason.strip()
|
ret.append(re.compile(regex.strip()))
|
||||||
else:
|
else:
|
||||||
ret[l] = None
|
ret.append(re.compile(l))
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def find_in_list(regexes, fullname):
|
def find_in_list(regexes, fullname):
|
||||||
for regex, reason in regexes.items():
|
for regex in regexes:
|
||||||
if re.match(regex, fullname):
|
if regex.match(fullname):
|
||||||
if reason is None:
|
return True
|
||||||
return ""
|
return False
|
||||||
return reason
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class ImmediateFail(Exception):
|
class ImmediateFail(Exception):
|
||||||
@ -344,10 +342,10 @@ class FilterOps(unittest.TestResult):
|
|||||||
|
|
||||||
def addFailure(self, test, err=None):
|
def addFailure(self, test, err=None):
|
||||||
test = self._add_prefix(test)
|
test = self._add_prefix(test)
|
||||||
xfail_reason = find_in_list(self.expected_failures, test.id())
|
xfail = find_in_list(self.expected_failures, test.id())
|
||||||
if xfail_reason is None:
|
if not xfail:
|
||||||
xfail_reason = find_in_list(self.flapping, test.id())
|
xfail = find_in_list(self.flapping, test.id())
|
||||||
if xfail_reason is not None:
|
if xfail:
|
||||||
self.xfail_added += 1
|
self.xfail_added += 1
|
||||||
self.total_xfail += 1
|
self.total_xfail += 1
|
||||||
self._ops.addExpectedFailure(test, err)
|
self._ops.addExpectedFailure(test, err)
|
||||||
@ -365,8 +363,8 @@ class FilterOps(unittest.TestResult):
|
|||||||
|
|
||||||
def addSuccess(self, test):
|
def addSuccess(self, test):
|
||||||
test = self._add_prefix(test)
|
test = self._add_prefix(test)
|
||||||
xfail_reason = find_in_list(self.expected_failures, test.id())
|
xfail = find_in_list(self.expected_failures, test.id())
|
||||||
if xfail_reason is not None:
|
if xfail:
|
||||||
self.uxsuccess_added += 1
|
self.uxsuccess_added += 1
|
||||||
self.total_uxsuccess += 1
|
self.total_uxsuccess += 1
|
||||||
self._ops.addUnexpectedSuccess(test)
|
self._ops.addUnexpectedSuccess(test)
|
||||||
@ -438,11 +436,11 @@ class FilterOps(unittest.TestResult):
|
|||||||
if expected_failures is not None:
|
if expected_failures is not None:
|
||||||
self.expected_failures = expected_failures
|
self.expected_failures = expected_failures
|
||||||
else:
|
else:
|
||||||
self.expected_failures = {}
|
self.expected_failures = []
|
||||||
if flapping is not None:
|
if flapping is not None:
|
||||||
self.flapping = flapping
|
self.flapping = flapping
|
||||||
else:
|
else:
|
||||||
self.flapping = {}
|
self.flapping = []
|
||||||
self.strip_ok_output = strip_ok_output
|
self.strip_ok_output = strip_ok_output
|
||||||
self.xfail_added = 0
|
self.xfail_added = 0
|
||||||
self.fail_added = 0
|
self.fail_added = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user