Merge lp:~mabac/svammel/add-patterns-for-tags into lp:svammel

Proposed by Mattias Backman
Status: Merged
Approved by: James Westby
Approved revision: 95
Merged at revision: 95
Proposed branch: lp:~mabac/svammel/add-patterns-for-tags
Merge into: lp:svammel
Prerequisite: lp:~mabac/svammel/move-regexmatching-to-utils
Diff against target: 78 lines (+36/-1)
2 files modified
data_parsing.py (+32/-1)
tests/test_fail_filer.py (+4/-0)
To merge this branch: bzr merge lp:~mabac/svammel/add-patterns-for-tags
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+57841@code.launchpad.net

This proposal supersedes a proposal from 2011-04-14.

Description of the change

Hi,

This branch just adds some patterns for setting bug tags depending on contents of the build log. Perhaps there should be some more infrastructure around it where to put more regexps, but for now I think simple is better. If this gets messy I'll have to think of a better solution then.

Thanks,

Mattias

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote : Posted in a previous version of this proposal

Hi,

Can we compile the regexes outside of the loop and so save on repeating those
expensive operations on every build log?

Thanks,

James

review: Needs Fixing
Revision history for this message
Mattias Backman (mabac) wrote : Posted in a previous version of this proposal

> Can we compile the regexes outside of the loop and so save on repeating those
> expensive operations on every build log?

Sure we can. I'm on it.

Thanks,

Mattias

Revision history for this message
Mattias Backman (mabac) wrote :

Hi,

I resubmitted this mp to be able to set lp:~mabac/svammel/move-regexmatching-to-utils as pre-requisite.

Thanks,

Mattias

Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data_parsing.py'
2--- data_parsing.py 2011-04-15 07:40:10 +0000
3+++ data_parsing.py 2011-04-15 10:27:23 +0000
4@@ -23,7 +23,11 @@
5 from launchpadlib.uris import *
6 import apt_pkg
7 import logging
8+import re
9
10+from matching import (
11+ RegexpMatcher,
12+ )
13 from config import (
14 get_base_url,
15 get_base_api_url,
16@@ -42,6 +46,7 @@
17 FAILED_BUILD_STATE = 'Failed to build'
18 SUCCESS_BUILD_STATE = 'Successfully built'
19 logger = logging.getLogger(LOGGER_NAME)
20+matchers = None
21
22
23 class InvalidArchiveError(Exception):
24@@ -52,13 +57,39 @@
25 return repr(self.value)
26
27
28+def init_matchers():
29+ global matchers
30+ matchers = []
31+
32+ logger.debug('Creating pattern matchers for setting tags.')
33+
34+ # Add your patterns here as (pattern, tag) pairs.
35+ regexps_and_tags = [
36+ (r'fatal error: linux/videodev.h: No such file or directory', 'v4l'),
37+ (r'is defined in DSO .*so try adding it to the linker command line', 'no-add-needed'),
38+ (r'NoClassDefFoundError: org/apache/tools/ant/taskdefs/optional/TraXLiaison', 'ant'),
39+ (r'internal compiler error', 'ice'),
40+ (r'No rule to make target .*lib.*\.la., needed by .*lib.*\.la', 'multiarch'),
41+ ]
42+
43+ for regexp, tag in regexps_and_tags:
44+ matchers.append(RegexpMatcher(tag, regexp))
45+
46+
47 def get_tags_for_fail(fail_data=''):
48 """ Determine cause of failure and tag accordingly. """
49
50 tags = []
51 if fail_data != '':
52 # Process build log contents to determine extra tags
53- pass
54+ if matchers is None:
55+ init_matchers()
56+
57+ for matcher in matchers:
58+ if matcher.match(fail_data):
59+ tags.append(matcher.get_name())
60+
61+ logger.debug('Extra bug tags %s.', tags)
62 return tags
63
64
65
66=== modified file 'tests/test_fail_filer.py'
67--- tests/test_fail_filer.py 2011-04-14 12:28:23 +0000
68+++ tests/test_fail_filer.py 2011-04-15 10:27:23 +0000
69@@ -69,6 +69,10 @@
70 tags = get_tags_for_fail("This will never trigger matcher.")
71 self.assertEquals([], tags)
72
73+ def test_ice_match_sets_extra_tag(self):
74+ tags = get_tags_for_fail("internal compiler error")
75+ self.assertIn('ice', tags)
76+
77
78 class TestFilter(TestCaseWithFixtures):
79

Subscribers

People subscribed via source and target branches