Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more respect to others privacy
[simgrid.git] / buildtools / buildbot / extensions.py
1
2
3 import re        
4 from buildbot.steps.source import SVN
5 from buildbot.steps.shell import ShellCommand
6 from buildbot.steps.transfer import FileDownload
7
8 from buildbot.status import builder
9 from buildbot.status.builder import SUCCESS,FAILURE, EXCEPTION,WARNINGS
10
11 from buildbot.process.properties import WithProperties
12
13
14 # Define a new builder status
15 # Configure return the exit code 77 when the target platform don't
16 # bear ucontext functionnality. In this case the CustomConfigure returns
17 # INCOMPATIBLE_PLATFORM.
18
19 """
20 CustomConfigure class for master-side representation of the
21 custom configure command. This class considers the error (exit code 77)
22 that occurs when the platform target don't bear ucontext functionnality.
23 """
24 class CustomConfigure(ShellCommand):
25
26     name = "configure"
27     description = ["running configure"]
28     descriptionDone = [name]
29     incompatible = False
30
31     # Override evaluateCommand method to handle the case of platform that 
32     # don't support ucontext. The method returns sets self.incompatible
33     # in this case.
34         
35     def evaluateCommand(self, cmd):
36         """Decide whether the command was SUCCESS, FAILURE or incompatible platform"""
37         
38         if cmd.rc == 0:
39                 return SUCCESS
40         elif cmd.rc == 77:
41                 self.incompatible = True
42                 return FAILURE
43         else:
44                 return FAILURE
45            
46      # Override getColor method. The method returns the text "blue" when platform is incompatible
47         
48     def getColor(self, cmd, results):
49         assert results in (SUCCESS, WARNINGS, FAILURE)
50         if results == SUCCESS:
51             return "green"
52         elif results == WARNINGS:
53             return "orange"
54         elif self.incompatible:
55             return "blue"
56         else:
57             return "red"
58             
59         # Override getText method. The method calls describe method
60         # with the text "failed {incompatible platform}" when the platform
61         # don't support ucontext functionnality.
62                
63     def getText(self, cmd, results):
64         if results == SUCCESS:
65             return self.describe(True) + ["Configure success"]
66         elif results == WARNINGS:
67             return self.describe(True) + ["warnings"]
68         elif self.incompatible:
69             return self.describe(True) + ["failed {incompatible platform}"]
70         else:
71             return self.describe(True) + ["failed"]
72             
73     def maybeGetText2(self, cmd, results):
74         if results == SUCCESS:
75             pass
76         elif results == WARNINGS:
77             pass
78         elif self.incompatible:
79             return ["incompatible platform"]
80         else:
81             return self.describe(True) + ["failed"]
82         return []
83
84
85 """
86 Cleanup the build dir, and setup a SVN revision in the waterfall afterward
87 """
88 class CleanupCommand(ShellCommand):
89    name="cleanup"
90    descriptionDone="cleanup"
91    command=["bash","-c","rm -rf * .svn"]
92
93    def maybeGetText2(self,cmd,results):
94        if self.build.getProperty("revision") == None:
95            return ["Missing svn revision"]
96        return ["SVN r%s" % self.build.getProperty("revision")]
97         
98 """
99 Just like a plain SVN, but displays the current revision in the waterfall afterall
100 """
101 class CustomSVN(SVN):        
102    def getText(self,cmd,results):
103        lines = cmd.logs['stdio'].getText()
104        r = re.search(' (\d+).',lines)
105        if results == SUCCESS and r:
106             return self.describe(True) + ["updated to %s" % r.group(1)]
107        elif results == SUCCESS:
108             return self.describe(True) + ["updated to some version"]
109        else:
110             return self.describe(True) + ["failed"]
111         
112    def maybeGetText2(self,cmd,results):
113        lines = cmd.logs['stdio'].getText()
114        r = re.search(' (\d+).',lines)
115        if results == SUCCESS and r:
116            return ["SVN r%s" % r.group(1)]
117        else:
118            return []
119               
120 """
121 CustomCheck class for master-side representation of the checkall results.
122 This class stores and displays the amount of errors in the checks.
123 """
124 class CustomCheck(ShellCommand):
125     name = "check"
126     description = ["running checks"]
127     descriptionDone = [name]
128
129             
130    # Override per step getText method.         
131     def getText(self, cmd, results):
132        lines = cmd.logs['stdio'].getText().split("\n")
133        re.compile('^FAIL:')
134        fail = len( filter(lambda line: re.search('^FAIL:', line), lines) )
135        re.compile('^XFAIL:')
136        xfail = len( filter(lambda line: re.search('^XFAIL:', line), lines) )
137        re.compile('^SKIP:')
138        skip = len( filter(lambda line: re.search('^SKIP:', line), lines) )
139        re.compile('^XPASS:')
140        xpass = len( filter(lambda line: re.search('^XPASS:', line), lines) )
141        re.compile('^PASS:')
142        passed = len( filter(lambda line: re.search('^PASS:', line), lines) )
143        
144        res = ""
145        if fail != 0:
146            res += ("%d failed, " % fail)
147        if skip != 0:
148            res += ("%d skipped, " % skip)
149        if xpass != 0:
150            res += ("%d unexpected success, " % xpass)
151        if xfail != 0:
152            res += ("%d expected failure, " % xfail)
153        res += ("%d total" % (passed + fail + skip + xpass + xfail))
154               
155        if results == SUCCESS:
156             return self.describe(True) + ["Success (%s)" % res]
157        elif results == WARNINGS:
158             return self.describe(True) + ["warnings"]
159        elif fail == 0:
160             return self.describe(True) + ["failed strangly"]
161        else:
162             return self.describe(True) + [res]
163                 
164    # Add some text to the top-column box
165     def getText2(self, cmd, results):
166        lines = cmd.logs['stdio'].getText().split("\n")
167        re.compile('^FAIL:')
168        fail = len( filter(lambda line: re.search('^FAIL:', line), lines) )
169        re.compile('^XFAIL:')
170        xfail = len( filter(lambda line: re.search('^XFAIL:', line), lines) )
171        re.compile('^SKIP:')
172        skip = len( filter(lambda line: re.search('^SKIP:', line), lines) )
173        re.compile('^XPASS:')
174        xpass = len( filter(lambda line: re.search('^XPASS:', line), lines) )
175        re.compile('^PASS:')
176        passed = len( filter(lambda line: re.search('^PASS:', line), lines) )
177        
178        res = ""
179        if fail != 0:
180            res += ("%d failed, " % fail)
181        if skip != 0:
182            res += ("%d skipped, " % skip)
183        if xpass != 0:
184            res += ("%d unexpected success, " % xpass)
185        if xfail != 0:
186            res += ("%d expected failure, " % xfail)
187        res += ("%d total" % (passed + fail + skip + xpass + xfail))
188               
189        if results == SUCCESS:
190             return ["All tests ok (%s)" % res]
191        elif results == WARNINGS:
192             return ["Warnings (%s)" % res]
193        elif fail == 0:
194             return ["Tests failed strangly"]
195        else:
196             return [res]