diff options
author | Andrew Bartlett <abartlet@samba.org> | 2022-12-06 17:16:00 +1300 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2022-12-13 21:37:58 +0100 |
commit | 26249f6c06591ba87d45e2a0f7322082a157fa06 (patch) | |
tree | 72f9372fc1150422c5d41f6656bcc88858605a5e | |
parent | 2ea3f2db8087e0a2c4a18c633b039c722cb6f829 (diff) | |
download | samba-26249f6c06591ba87d45e2a0f7322082a157fa06.tar.gz |
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>
(cherry picked from commit 22128c718cadd34af892df102bd52df6a6b03303)
-rw-r--r-- | selftest/subunithelper.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 2b78d16eb3a..801149f8910 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -236,7 +236,7 @@ class SubunitOps(TestProtocolClient, TestsuiteEnabledTestResult): def read_test_regexes(*names): - ret = {} + ret = [] files = [] for name in names: # if we are given a directory, we read all the files it contains @@ -256,20 +256,18 @@ def read_test_regexes(*names): continue if "#" in l: (regex, reason) = l.split("#", 1) - ret[regex.strip()] = reason.strip() + ret.append(re.compile(regex.strip())) else: - ret[l] = None + ret.append(re.compile(l)) return ret def find_in_list(regexes, fullname): - for regex, reason in regexes.items(): - if re.match(regex, fullname): - if reason is None: - return "" - return reason - return None + for regex in regexes: + if regex.match(fullname): + return True + return False class ImmediateFail(Exception): @@ -344,10 +342,10 @@ class FilterOps(unittest.TestResult): def addFailure(self, test, err=None): test = self._add_prefix(test) - xfail_reason = find_in_list(self.expected_failures, test.id()) - if xfail_reason is None: - xfail_reason = find_in_list(self.flapping, test.id()) - if xfail_reason is not None: + xfail = find_in_list(self.expected_failures, test.id()) + if not xfail: + xfail = find_in_list(self.flapping, test.id()) + if xfail: self.xfail_added += 1 self.total_xfail += 1 self._ops.addExpectedFailure(test, err) @@ -365,8 +363,8 @@ class FilterOps(unittest.TestResult): def addSuccess(self, test): test = self._add_prefix(test) - xfail_reason = find_in_list(self.expected_failures, test.id()) - if xfail_reason is not None: + xfail = find_in_list(self.expected_failures, test.id()) + if xfail: self.uxsuccess_added += 1 self.total_uxsuccess += 1 self._ops.addUnexpectedSuccess(test) @@ -438,11 +436,11 @@ class FilterOps(unittest.TestResult): if expected_failures is not None: self.expected_failures = expected_failures else: - self.expected_failures = {} + self.expected_failures = [] if flapping is not None: self.flapping = flapping else: - self.flapping = {} + self.flapping = [] self.strip_ok_output = strip_ok_output self.xfail_added = 0 self.fail_added = 0 |